[FIX] account: allow invoices with a 0 total to be saved.

fixes #44687

closes odoo/odoo#45648

X-original-commit: 17fdda67e17ace6dc088aa33bddfd85aeac546bd
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
This commit is contained in:
qdp-odoo
2020-02-18 14:39:04 +00:00
parent a2489f7c59
commit e6d2b8e782
5 changed files with 11 additions and 7 deletions
+5 -1
View File
@@ -2857,8 +2857,12 @@ class AccountMoveLine(models.Model):
'discount': 0.0,
'price_unit': balance / (quantity or 1.0),
}
else:
elif not discount_factor:
# balance of line is 0, but discount == 100% so we display the normal unit_price
vals = {}
else:
# balance is 0, so unit price is 0 as well
vals = {'price_unit': 0.0}
return vals
# -------------------------------------------------------------------------
@@ -477,8 +477,8 @@ class TestAccountMoveInInvoiceOnchanges(AccountTestInvoicingCommon):
def test_in_invoice_line_onchange_business_fields_1(self):
move_form = Form(self.invoice)
with move_form.invoice_line_ids.edit(0) as line_form:
# Current price_unit is 1000.
# We set quantity = 4, discount = 50%, price_unit = 400 because (4 * 400) * 0.5 = 800.
# Current price_unit is 800.
# We set quantity = 4, discount = 50%, price_unit = 400. The debit/credit fields don't change because (4 * 400) * 0.5 = 800.
line_form.quantity = 4
line_form.discount = 50
line_form.price_unit = 400
@@ -189,8 +189,8 @@ class TestAccountMoveInRefundOnchanges(AccountTestInvoicingCommon):
def test_in_refund_line_onchange_business_fields_1(self):
move_form = Form(self.invoice)
with move_form.invoice_line_ids.edit(0) as line_form:
# Current price_unit is 1000.
# We set quantity = 4, discount = 50%, price_unit = 400 because (4 * 400) * 0.5 = 800.
# Current price_unit is 800.
# We set quantity = 4, discount = 50%, price_unit = 400. The debit/credit fields don't change because (4 * 400) * 0.5 = 800.
line_form.quantity = 4
line_form.discount = 50
line_form.price_unit = 400
@@ -480,7 +480,7 @@ class TestAccountMoveOutInvoiceOnchanges(AccountTestInvoicingCommon):
move_form = Form(self.invoice)
with move_form.invoice_line_ids.edit(0) as line_form:
# Current price_unit is 1000.
# We set quantity = 4, discount = 50%, price_unit = 500 because (4 * 500) * 0.5 = 1000.
# We set quantity = 4, discount = 50%, price_unit = 400. The debit/credit fields don't change because (4 * 500) * 0.5 = 1000.
line_form.quantity = 4
line_form.discount = 50
line_form.price_unit = 500
@@ -190,7 +190,7 @@ class TestAccountMoveOutRefundOnchanges(AccountTestInvoicingCommon):
move_form = Form(self.invoice)
with move_form.invoice_line_ids.edit(0) as line_form:
# Current price_unit is 1000.
# We set quantity = 4, discount = 50%, price_unit = 500 because (4 * 500) * 0.5 = 1000.
# We set quantity = 4, discount = 50%, price_unit = 400. The debit/credit fields don't change because (4 * 500) * 0.5 = 1000.
line_form.quantity = 4
line_form.discount = 50
line_form.price_unit = 500