mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 02:52:04 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -3,3 +3,5 @@
|
|||
|
||||
from . import test_crm_lead_convert_quotation
|
||||
from . import test_crm_lead_merge
|
||||
from . import test_res_partner
|
||||
from . import test_sale_crm
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ class TestLeadConvertToTicket(crm_common.TestCrmCommon):
|
|||
self.assertEqual(lead.partner_id, self.contact_2)
|
||||
# TDE TODO: have a real sync assert for lead / contact
|
||||
self.assertEqual(lead.email_from, self.contact_2.email)
|
||||
self.assertEqual(lead.mobile, self.contact_2.mobile)
|
||||
self.assertEqual(action['context']['default_partner_id'], self.contact_2.id)
|
||||
|
||||
@users('user_sales_salesman')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
from odoo.addons.crm.tests.common import TestCrmCommon
|
||||
from odoo.tests import tagged, users
|
||||
|
||||
|
||||
@tagged('res_partner', 'post_install', '-at_install')
|
||||
class TestResPartner(TestCrmCommon):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.contact_1_1, cls.contact_1_2 = cls.env['res.partner'].create([
|
||||
{
|
||||
'name': 'Philip J Fry Bouffe-tête',
|
||||
'email': 'bouffe.tete@test.example.com',
|
||||
'function': 'Bouffe-Tête',
|
||||
'lang': cls.lang_en.code,
|
||||
'phone': False,
|
||||
'parent_id': cls.contact_1.id,
|
||||
'is_company': False,
|
||||
'street': 'Same as Fry',
|
||||
'city': 'New York',
|
||||
'country_id': cls.env.ref('base.us').id,
|
||||
'zip': '54321',
|
||||
}, {
|
||||
'name': 'Philip J Fry Banjo',
|
||||
'email': 'banjo@test.example.com',
|
||||
'function': 'Being a banjo',
|
||||
'lang': cls.lang_en.code,
|
||||
'phone': False,
|
||||
'parent_id': cls.contact_1.id,
|
||||
'is_company': False,
|
||||
'street': 'Same as Fry',
|
||||
'city': 'New York',
|
||||
'country_id': cls.env.ref('base.us').id,
|
||||
'zip': '54321',
|
||||
}
|
||||
])
|
||||
|
||||
cls.test_product = cls.env['product.template'].create({
|
||||
'list_price': 100.0,
|
||||
'name': 'Test product1',
|
||||
})
|
||||
cls.test_pricelist = cls.env['product.pricelist'].create({
|
||||
'currency_id': cls.env.ref('base.USD').id,
|
||||
'name': 'My',
|
||||
})
|
||||
|
||||
cls.test_leads = cls.env['crm.lead'].create([
|
||||
{
|
||||
'name': 'CompanyLead',
|
||||
'type': 'lead',
|
||||
'partner_id': cls.contact_company_1.id,
|
||||
}, {
|
||||
'name': 'ChildLead',
|
||||
'type': 'lead',
|
||||
'partner_id': cls.contact_1.id,
|
||||
}, {
|
||||
'name': 'GrandChildLead',
|
||||
'type': 'lead',
|
||||
'partner_id': cls.contact_1_1.id,
|
||||
}, {
|
||||
'name': 'GrandChildOpp',
|
||||
'type': 'opportunity',
|
||||
'partner_id': cls.contact_1_1.id,
|
||||
}, {
|
||||
'name': 'Nobody',
|
||||
'type': 'opportunity',
|
||||
},
|
||||
])
|
||||
|
||||
cls.test_so = cls.env['sale.order'].create([
|
||||
{
|
||||
'partner_id': cls.contact_company_1.id,
|
||||
'pricelist_id': cls.test_pricelist.id,
|
||||
'order_line': [
|
||||
(0, 0, {
|
||||
'product_id': cls.test_product.product_variant_id.id,
|
||||
})
|
||||
],
|
||||
}, {
|
||||
'partner_id': cls.contact_1.id,
|
||||
'pricelist_id': cls.test_pricelist.id,
|
||||
'order_line': [
|
||||
(0, 0, {
|
||||
'product_id': cls.test_product.product_variant_id.id,
|
||||
})
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
@users('user_sales_manager')
|
||||
def test_application_stat_info(self):
|
||||
(
|
||||
contact_company_1, contact_1, contact_1_1, contact_1_2
|
||||
) = (
|
||||
self.contact_company_1 + self.contact_1 + self.contact_1_1 + self.contact_1_2
|
||||
).with_env(self.env)
|
||||
self.assertEqual(contact_company_1.opportunity_count, 4, 'Should contain own + children leads')
|
||||
self.assertEqual(contact_1.opportunity_count, 3, 'Should contain own + child leads')
|
||||
self.assertEqual(contact_1_1.opportunity_count, 2, 'Should contain own, aka 2')
|
||||
self.assertEqual(contact_1_2.opportunity_count, 0, 'Should contain own, aka none')
|
||||
|
||||
for partner, expected in zip(
|
||||
(contact_company_1, contact_1, contact_1_1, contact_1_2),
|
||||
(
|
||||
[{'iconClass': 'fa-star', 'label': 'Opportunities', 'value': 4, 'tagClass': 'o_tag_color_8'},
|
||||
{'iconClass': 'fa-usd', 'label': 'Sale Orders', 'value': 2, 'tagClass': 'o_tag_color_2'}],
|
||||
[{'iconClass': 'fa-star', 'label': 'Opportunities', 'value': 3, 'tagClass': 'o_tag_color_8'},
|
||||
{'iconClass': 'fa-usd', 'label': 'Sale Orders', 'value': 1, 'tagClass': 'o_tag_color_2'}],
|
||||
[{'iconClass': 'fa-star', 'label': 'Opportunities', 'value': 2, 'tagClass': 'o_tag_color_8'}],
|
||||
False,
|
||||
),
|
||||
strict=True,
|
||||
):
|
||||
with self.subTest(pname=partner.name):
|
||||
self.assertEqual(partner.application_statistics, expected)
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
from odoo.addons.crm.tests.common import TestCrmCommon
|
||||
from odoo.fields import Command
|
||||
|
||||
|
||||
class TestSaleCrm(TestCrmCommon):
|
||||
|
||||
def test_sale_crm_revenue(self):
|
||||
""" Test the updation of the expected_revenue when the is confirmed.
|
||||
If the expected_revenue of the lead is smaller than the total of quote which we are confirming, update it with that.
|
||||
e.g. if the lead has a expected revenue of 40 $
|
||||
Quotes - q1 = 45$
|
||||
===> The expected_revenue would be updated, from 40 to 45$.
|
||||
"""
|
||||
product1, product2 = self.env['product.template'].create([{
|
||||
'name': 'Test product1',
|
||||
'list_price': 100.0,
|
||||
}, {
|
||||
'name': 'Test product2',
|
||||
'list_price': 200.0,
|
||||
}])
|
||||
|
||||
my_pricelist = self.env['product.pricelist'].create({
|
||||
'name': 'Rupee',
|
||||
'currency_id': self.ref('base.INR')
|
||||
})
|
||||
pricelist_expected_by_lead = self.env['product.pricelist'].create({
|
||||
'name': 'Rupee',
|
||||
'currency_id': self.ref('base.USD')
|
||||
})
|
||||
|
||||
so_values = {
|
||||
'partner_id': self.env.user.partner_id.id,
|
||||
'opportunity_id': self.lead_1.id,
|
||||
}
|
||||
so1, so2 = self.env['sale.order'].create([{
|
||||
**so_values,
|
||||
'pricelist_id': my_pricelist.id,
|
||||
'order_line': [
|
||||
Command.create({
|
||||
'product_id': product1.product_variant_id.id,
|
||||
}),
|
||||
],
|
||||
}, {
|
||||
**so_values,
|
||||
'pricelist_id': pricelist_expected_by_lead.id,
|
||||
'order_line': [
|
||||
Command.create({
|
||||
'product_id': product2.product_variant_id.id,
|
||||
}),
|
||||
],
|
||||
}])
|
||||
|
||||
self.assertEqual(self.lead_1.expected_revenue, 0)
|
||||
|
||||
# Revenue should not be updated when the currency of sale order is different from lead.
|
||||
so1.action_confirm()
|
||||
self.assertEqual(self.lead_1.expected_revenue, 0)
|
||||
# Revenue should be updated when the currency is same.
|
||||
so2.action_confirm()
|
||||
self.assertEqual(self.lead_1.expected_revenue, 200)
|
||||
Loading…
Add table
Add a link
Reference in a new issue