From d977d238e3a208e853c7d28a4870a2148929d1db Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 2 Oct 2023 16:10:42 +0200 Subject: [PATCH 1/2] [FIX] contract: Apply some values directly in Form If not applied, they will not be taken into account in the lines operations. We have needed to add an auxiliary form that adds the fields without groups. TT45329 --- contract/__manifest__.py | 1 + contract/models/contract.py | 10 +++++----- contract/views/account_move_views.xml | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 contract/views/account_move_views.xml diff --git a/contract/__manifest__.py b/contract/__manifest__.py index 7628c3189..9297e1446 100644 --- a/contract/__manifest__.py +++ b/contract/__manifest__.py @@ -37,6 +37,7 @@ "wizards/contract_contract_terminate.xml", "views/contract_tag.xml", "views/abstract_contract_line.xml", + "views/account_move_views.xml", "views/contract.xml", "views/contract_line.xml", "views/contract_template.xml", diff --git a/contract/models/contract.py b/contract/models/contract.py index 12765dbe5..d419b004b 100644 --- a/contract/models/contract.py +++ b/contract/models/contract.py @@ -438,9 +438,13 @@ class ContractContract(models.Model): move_form = Form( self.env["account.move"] .with_company(self.company_id) - .with_context(default_move_type=invoice_type) + .with_context(default_move_type=invoice_type), + view="contract.view_account_move_contract_helper_form", ) move_form.partner_id = self.invoice_partner_id + move_form.journal_id = journal + move_form.currency_id = self.currency_id + move_form.invoice_date = date_invoice if self.payment_term_id: move_form.invoice_payment_term_id = self.payment_term_id if self.fiscal_position_id: @@ -451,10 +455,6 @@ class ContractContract(models.Model): invoice_vals.update( { "ref": self.code, - "company_id": self.company_id.id, - "currency_id": self.currency_id.id, - "invoice_date": date_invoice, - "journal_id": journal.id, "invoice_origin": self.name, } ) diff --git a/contract/views/account_move_views.xml b/contract/views/account_move_views.xml new file mode 100644 index 000000000..c97bbe415 --- /dev/null +++ b/contract/views/account_move_views.xml @@ -0,0 +1,15 @@ + + + + + + account.move + primary + +
+ + + + +
+
From e38559580f7c5b37d4f4f38c6f7009382fe0f0bf Mon Sep 17 00:00:00 2001 From: Maximilien TANTIN Date: Wed, 20 Jul 2022 14:46:35 +0200 Subject: [PATCH 2/2] [IMP] contract: Set name='/' for contract invoices --- contract/models/contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contract/models/contract.py b/contract/models/contract.py index d419b004b..d4f235b82 100644 --- a/contract/models/contract.py +++ b/contract/models/contract.py @@ -438,7 +438,7 @@ class ContractContract(models.Model): move_form = Form( self.env["account.move"] .with_company(self.company_id) - .with_context(default_move_type=invoice_type), + .with_context(default_move_type=invoice_type, default_name="/"), view="contract.view_account_move_contract_helper_form", ) move_form.partner_id = self.invoice_partner_id