[IMP] account: tests framework: add explicit label to invoice lines created with only amount, to avoid crashing in some tests

We also inject a context key to ignore prediction in case account_predictive_bills (enterprise) is installed. This way, having the same label on invoice lines generated by the helper will still behave in the same way, even if enterprise is installed.

closes odoo/odoo#67998

X-original-commit: b6c37754532ae6a7cc1f68a345fde6258abdc893
Related: odoo/enterprise#17125
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
This commit is contained in:
oco-odoo
2021-03-17 09:30:39 +00:00
parent a1200768d1
commit 5925001c19
+4 -1
View File
@@ -363,7 +363,7 @@ class AccountTestInvoicingCommon(TransactionCase):
@classmethod
def init_invoice(cls, move_type, partner=None, invoice_date=None, post=False, products=[], amounts=[], taxes=None):
move_form = Form(cls.env['account.move'].with_context(default_move_type=move_type))
move_form = Form(cls.env['account.move'].with_context(default_move_type=move_type, account_predictive_bills_disable_prediction=True))
move_form.invoice_date = invoice_date or fields.Date.from_string('2019-01-01')
move_form.partner_id = partner or cls.partner_a
@@ -376,6 +376,9 @@ class AccountTestInvoicingCommon(TransactionCase):
for amount in amounts:
with move_form.invoice_line_ids.new() as line_form:
line_form.name = "test line"
# We use account_predictive_bills_disable_prediction context key so that
# this doesn't trigger prediction in case enterprise (hence account_predictive_bills) is installed
line_form.price_unit = amount
if taxes:
line_form.tax_ids.clear()