bemade_multiple_billing_contacts: incorporating views
This commit is contained in:
parent
866f650ffe
commit
8974d412de
5 changed files with 24 additions and 10 deletions
|
|
@ -31,7 +31,8 @@
|
||||||
'account',
|
'account',
|
||||||
'bemade_partner_root_ancestor',
|
'bemade_partner_root_ancestor',
|
||||||
],
|
],
|
||||||
'data': [],
|
'data': ['views/account_move_views.xml',
|
||||||
|
'views/res_partner_views.xml'],
|
||||||
'demo': [],
|
'demo': [],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
'auto_install': False,
|
'auto_install': False,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ class AccountMove(models.Model):
|
||||||
string="Billing Contacts",
|
string="Billing Contacts",
|
||||||
compute='_compute_billing_contacts',
|
compute='_compute_billing_contacts',
|
||||||
inverse='_inverse_billing_contacts',
|
inverse='_inverse_billing_contacts',
|
||||||
store=True)
|
store=True,)
|
||||||
|
|
||||||
@api.depends('line_ids.sale_line_ids.order_id', 'partner_id')
|
@api.depends('line_ids.sale_line_ids.order_id', 'partner_id')
|
||||||
def _compute_billing_contacts(self):
|
def _compute_billing_contacts(self):
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,14 @@ class Partner(models.Model):
|
||||||
comodel_name='res.partner',
|
comodel_name='res.partner',
|
||||||
compute='_compute_billing_contacts',
|
compute='_compute_billing_contacts',
|
||||||
inverse='_inverse_billing_contacts')
|
inverse='_inverse_billing_contacts')
|
||||||
|
potential_billing_contacts = fields.Many2many(comodel_name='res.partner',
|
||||||
|
compute='_compute_billing_contacts')
|
||||||
|
|
||||||
@api.depends('child_ids.type')
|
@api.depends('child_ids.type')
|
||||||
def _compute_billing_contacts(self):
|
def _compute_billing_contacts(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.billing_contacts = rec.child_ids.filtered(lambda r: r.type == 'invoice')
|
rec.billing_contacts = rec.child_ids.filtered(lambda r: r.type == 'invoice')
|
||||||
|
rec.potential_billing_contacts = rec.child_ids | rec.parent_id.child_ids if rec.is_company else None
|
||||||
|
|
||||||
@api.depends('billing_contacts')
|
@api.depends('billing_contacts')
|
||||||
def _inverse_billing_contacts(self):
|
def _inverse_billing_contacts(self):
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,11 @@ class TestBillingContacts(TransactionCase):
|
||||||
'parent_id': cls.parent_co.id,
|
'parent_id': cls.parent_co.id,
|
||||||
'type': 'contact',
|
'type': 'contact',
|
||||||
})
|
})
|
||||||
cls.product = cls.env['product.product'].with_company(cls.parent_co.company_id).create({
|
cls.product = cls.env['product.product'].with_company(
|
||||||
|
cls.parent_co.company_id).create({
|
||||||
'name': 'Product',
|
'name': 'Product',
|
||||||
'categ_id': cls.env['product.category'].create({'name': 'Product Category'}).id,
|
'categ_id': cls.env['product.category'].create(
|
||||||
|
{'name': 'Product Category'}).id,
|
||||||
'list_price': 100.0,
|
'list_price': 100.0,
|
||||||
'type': 'service',
|
'type': 'service',
|
||||||
'uom_id': cls.env.ref('uom.product_uom_unit').id,
|
'uom_id': cls.env.ref('uom.product_uom_unit').id,
|
||||||
|
|
@ -70,19 +72,23 @@ class TestBillingContacts(TransactionCase):
|
||||||
self.assertTrue(self.non_billing_contact not in self.parent_co.billing_contacts)
|
self.assertTrue(self.non_billing_contact not in self.parent_co.billing_contacts)
|
||||||
|
|
||||||
def test_sale_order_default_billing_contacts(self):
|
def test_sale_order_default_billing_contacts(self):
|
||||||
self.assertTrue(self.sale_order.billing_contacts == self.parent_co.billing_contacts)
|
self.assertTrue(
|
||||||
|
self.sale_order.billing_contacts == self.parent_co.billing_contacts)
|
||||||
|
|
||||||
def test_sale_order_change_contacts(self):
|
def test_sale_order_change_contacts(self):
|
||||||
# Test that changing the billing contacts on an SO doesn't change them on the partner
|
# Test that changing the billing contacts on an SO doesn't change them on the partner
|
||||||
self.sale_order.write({'billing_contacts': [Command.link(self.non_billing_contact.id)]})
|
self.sale_order.write(
|
||||||
self.assertTrue(all([c in self.sale_order.billing_contacts for c in self.parent_co.billing_contacts]))
|
{'billing_contacts': [Command.link(self.non_billing_contact.id)]})
|
||||||
|
self.assertTrue(all([c in self.sale_order.billing_contacts for c in
|
||||||
|
self.parent_co.billing_contacts]))
|
||||||
self.assertTrue(self.non_billing_contact not in self.parent_co.billing_contacts)
|
self.assertTrue(self.non_billing_contact not in self.parent_co.billing_contacts)
|
||||||
self.assertTrue(self.non_billing_contact in self.sale_order.billing_contacts)
|
self.assertTrue(self.non_billing_contact in self.sale_order.billing_contacts)
|
||||||
|
|
||||||
def test_sale_order_to_invoice_contacts(self):
|
def test_sale_order_to_invoice_contacts(self):
|
||||||
# Test that the invoices created from sales orders take the billing contacts configured on the SO
|
# Test that the invoices created from sales orders take the billing contacts configured on the SO
|
||||||
|
|
||||||
self.sale_order.write({'billing_contacts': [Command.link(self.non_billing_contact.id)]})
|
self.sale_order.write(
|
||||||
|
{'billing_contacts': [Command.link(self.non_billing_contact.id)]})
|
||||||
self.sale_order.action_confirm()
|
self.sale_order.action_confirm()
|
||||||
|
|
||||||
wiz = self.env['sale.advance.payment.inv'].create({})
|
wiz = self.env['sale.advance.payment.inv'].create({})
|
||||||
|
|
@ -99,10 +105,12 @@ class TestBillingContacts(TransactionCase):
|
||||||
self.assertTrue(self.parent_co.billing_contacts == invoice.billing_contacts)
|
self.assertTrue(self.parent_co.billing_contacts == invoice.billing_contacts)
|
||||||
|
|
||||||
def test_invoice_followers_on_validate(self):
|
def test_invoice_followers_on_validate(self):
|
||||||
|
# Make sure all billing contacts get added as followers upon validating the invoice
|
||||||
self.sale_order.action_confirm()
|
self.sale_order.action_confirm()
|
||||||
wiz = self.env['sale.advance.payment.inv'].create({})
|
wiz = self.env['sale.advance.payment.inv'].create({})
|
||||||
invoice = wiz._create_invoice(self.sale_order, self.sale_order.order_line[0],
|
invoice = wiz._create_invoice(self.sale_order, self.sale_order.order_line[0],
|
||||||
self.sale_order.order_line.price_total)
|
self.sale_order.order_line.price_total)
|
||||||
invoice.write({'date': datetime.date.today()})
|
invoice.write({'date': datetime.date.today()})
|
||||||
invoice.action_post()
|
invoice.action_post()
|
||||||
self.assertTrue(all([r in invoice.message_partner_ids for r in self.parent_co.billing_contacts]))
|
self.assertTrue(all([r in invoice.message_partner_ids for r in
|
||||||
|
self.parent_co.billing_contacts]))
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@
|
||||||
<page name="default_contacts" string="Default Contacts"
|
<page name="default_contacts" string="Default Contacts"
|
||||||
help="Settings for default contacts to whom different correspondence should be sent.">
|
help="Settings for default contacts to whom different correspondence should be sent.">
|
||||||
<group>
|
<group>
|
||||||
<field name="billing_contacts" attrs="{'invisible': [('company_type', '=', 'person')]}">
|
<field name="billing_contacts"
|
||||||
|
domain="[('parent_id', '=', id),
|
||||||
|
('is_company', '=', False)]">
|
||||||
<tree editable="bottom">
|
<tree editable="bottom">
|
||||||
<field name="name" widget="res_partner_many2one" />
|
<field name="name" widget="res_partner_many2one" />
|
||||||
<field name="email" widget="email"/>
|
<field name="email" widget="email"/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue