mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
@@ -30,6 +30,7 @@
|
||||
'data/contract_cron.xml',
|
||||
'data/contract_renew_cron.xml',
|
||||
'data/mail_template.xml',
|
||||
'data/mail_message_subtype.xml',
|
||||
'data/ir_ui_menu.xml',
|
||||
'wizards/contract_line_wizard.xml',
|
||||
'wizards/contract_manually_create_invoice.xml',
|
||||
|
||||
7
contract/data/mail_message_subtype.xml
Normal file
7
contract/data/mail_message_subtype.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" ?>
|
||||
<odoo noupdate="1">
|
||||
<record id="mail_message_subtype_invoice_created" model="mail.message.subtype">
|
||||
<field name="name">Invoice created</field>
|
||||
<field name="res_model">contract.contract</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -417,6 +417,18 @@ class ContractContract(models.Model):
|
||||
"""
|
||||
invoices.compute_taxes()
|
||||
|
||||
@api.model
|
||||
def _invoice_followers(self, invoices):
|
||||
invoice_create_subtype = self.sudo().env.ref(
|
||||
'contract.mail_message_subtype_invoice_created'
|
||||
)
|
||||
for item in self:
|
||||
partner_ids = item.message_follower_ids.filtered(
|
||||
lambda x: invoice_create_subtype in x.subtype_ids
|
||||
).mapped('partner_id')
|
||||
if partner_ids:
|
||||
invoices.message_subscribe(partner_ids=partner_ids.ids)
|
||||
|
||||
@api.model
|
||||
def _finalize_and_create_invoices(self, invoices_values):
|
||||
"""This method:
|
||||
@@ -435,6 +447,7 @@ class ContractContract(models.Model):
|
||||
)
|
||||
invoices = self.env['account.invoice'].create(final_invoices_values)
|
||||
self._finalize_invoice_creation(invoices)
|
||||
self._invoice_followers(invoices)
|
||||
return invoices
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
|
||||
* Carlos Dauden <carlos.dauden@tecnativa.com>
|
||||
* Angel Moya <angel.moya@domatix.com>
|
||||
* Dave Lasley <dave@laslabs.com>
|
||||
* Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||
* Miquel Raïch <miquel.raich@eficent.com>
|
||||
* Souheil Bejaoui <souheil.bejaoui@acsone.eu>
|
||||
* Thomas Binsfeld <thomas.binsfeld@acsone.eu>
|
||||
* Rafael Blasco <rafael.blasco@tecnativa.com>
|
||||
* Guillaume Vandamme <guillaume.vandamme@acsone.eu>
|
||||
* Raphaël Reverdy <raphael.reverdy@akretion.com>
|
||||
|
||||
* `Tecnativa <https://www.tecnativa.com>`_:
|
||||
|
||||
* Pedro M. Baeza
|
||||
* Carlos Dauden
|
||||
* Vicent Cubells
|
||||
* Rafael Blasco
|
||||
* Víctor Martínez
|
||||
|
||||
@@ -201,6 +201,21 @@ class TestContract(TestContractBase):
|
||||
)
|
||||
self.assertEqual(self.acct_line.last_date_invoiced, last_date_invoiced)
|
||||
|
||||
def test_contract_invoice_followers(self):
|
||||
self.acct_line.recurring_next_date = '2018-02-23'
|
||||
self.acct_line.recurring_rule_type = 'daily'
|
||||
self.contract.pricelist_id = False
|
||||
self.contract.message_subscribe(
|
||||
partner_ids=self.contract.partner_id.ids,
|
||||
subtype_ids=self.env.ref(
|
||||
'contract.mail_message_subtype_invoice_created'
|
||||
).ids
|
||||
)
|
||||
self.contract.recurring_create_invoice()
|
||||
invoice_daily = self.contract._get_related_invoices()
|
||||
self.assertTrue(invoice_daily)
|
||||
self.assertEqual(len(invoice_daily.message_partner_ids.ids), 2)
|
||||
|
||||
def test_contract_weekly_post_paid(self):
|
||||
recurring_next_date = to_date('2018-03-01')
|
||||
last_date_invoiced = to_date('2018-02-21')
|
||||
|
||||
Reference in New Issue
Block a user