Skip to content

Commit bf187dc

Browse files
committed
Merge PR #5219 into 16.0
Signed-off-by tafaRU
2 parents 0d3fc10 + 5dbe66e commit bf187dc

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

l10n_it_account_stamp/models/account_move.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from odoo import _, api, fields, models
55
from odoo.exceptions import UserError
6+
from odoo.fields import Command
67

78

89
class 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

0 commit comments

Comments
 (0)