File tree Expand file tree Collapse file tree
l10n_it_account_stamp/models Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44from odoo import _ , api , fields , models
55from odoo .exceptions import UserError
6+ from odoo .fields import Command
67
78
89class AccountMove (models .Model ):
@@ -176,17 +177,18 @@ def _post(self, soft=True):
176177 if inv .state == "posted" :
177178 posted = True
178179 inv .state = "draft"
179- line_model = self .env ["account.move.line" ]
180180 stamp_product_id = inv .company_id .with_context (
181181 lang = inv .partner_id .lang
182182 ).tax_stamp_product_id
183183 if not stamp_product_id :
184184 raise UserError (_ ("Missing tax stamp product in company settings!" ))
185185 income_vals , expense_vals = inv ._build_tax_stamp_lines (stamp_product_id )
186- income_vals ["move_id" ] = inv .id
187- expense_vals ["move_id" ] = inv .id
188- line_model .with_context (check_move_validity = False ).create (income_vals )
189- line_model .with_context (check_move_validity = False ).create (expense_vals )
186+
187+ inv .line_ids = [
188+ Command .create (income_vals ),
189+ Command .create (expense_vals ),
190+ ]
191+
190192 if posted :
191193 inv .state = "posted"
192194 return res
You can’t perform that action at this time.
0 commit comments