Skip to content

Commit

Permalink
fixup! [IMP] #310 don't recompute tax_ids on portal vendor bill lines
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Aug 11, 2023
1 parent 11bb4d2 commit 6f464d5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions bankayma_account/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def _portal_create_vendor_bill(self, post_data, uploaded_files):
}
)
invoice.invoice_line_ids.write(line_vals)
invoice.invoice_line_ids.invalidate_recordset()
attachments = self.env["ir.attachment"]
for uploaded_file in uploaded_files.getlist("upload"):
attachments += self.env["ir.attachment"].create(
Expand Down
19 changes: 15 additions & 4 deletions bankayma_account/tests/test_bankayma_account_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from werkzeug.datastructures import MultiDict

from odoo.tests.common import TransactionCase
from odoo.tests.common import Form, TransactionCase


class TestBankaymaAccountPortal(TransactionCase):
Expand All @@ -17,7 +17,7 @@ def test_vendor_bill(self):
[("company_id", "=", self.env.company.id)], limit=1
)
fpos.bankayma_tax_id = self.env["account.tax"].search(
[("type_tax_use", "=", "purchase")], limit=1
[("type_tax_use", "=", "purchase"), ("sequence", ">=", 0)], limit=1
)
fpos.bankayma_deduct_tax = True
invoice = (
Expand Down Expand Up @@ -51,6 +51,17 @@ def test_vendor_bill(self):
]
)
self.assertTrue(attachment)
self.assertEqual(len(invoice.invoice_line_ids.tax_ids), 2)
self.assertIn(fpos.bankayma_tax_id, invoice.invoice_line_ids.tax_ids)
taxes = invoice.invoice_line_ids.tax_ids
self.assertEqual(len(taxes), 2)
self.assertEqual(fpos.bankayma_tax_id, invoice.invoice_line_ids.tax_ids[-1:])
self.assertEqual(invoice.invoice_line_ids.tax_ids[:1].sequence, -1)
self.assertTrue(invoice.partner_id.bankayma_vendor_max_amount, 424242)
with Form(invoice) as invoice_form:
invoice_form.invoice_line_ids.product_id = self.env[
"product.product"
].search(
[
("id", "!=", invoice.invoice_line_ids.product_id.id),
]
)
self.assertEqual(taxes, invoice.invoice_line_ids.tax_ids)

0 comments on commit 6f464d5

Please sign in to comment.