diff --git a/addons/purchase_stock/models/account_invoice.py b/addons/purchase_stock/models/account_invoice.py index 4dce189cfff..ac44ad6d5b2 100644 --- a/addons/purchase_stock/models/account_invoice.py +++ b/addons/purchase_stock/models/account_invoice.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, fields, models -from odoo.tools.float_utils import float_compare +from odoo import api, fields, models, _ +from odoo.tools.float_utils import float_compare, float_is_zero +from odoo.exceptions import UserError class AccountMove(models.Model): @@ -82,6 +83,9 @@ class AccountMove(models.Model): move.company_id, valuation_date, round=False, ) valuation_total_qty += layers_qty + + if float_is_zero(valuation_total_qty, precision_rounding=line.product_uom_id.rounding or line.product_id.uom_id.rounding): + raise UserError(_('Odoo is not able to generate the anglo saxon entries. The total valuation of %s is zero.') % line.product_id.display_name) valuation_price_unit = valuation_price_unit_total / valuation_total_qty valuation_price_unit = line.product_id.uom_id._compute_price(valuation_price_unit, line.product_uom_id)