diff --git a/addons/mrp/i18n/mrp.pot b/addons/mrp/i18n/mrp.pot index 550db41f8ead14b54d389e22043e64dc01c86b6e..c68d6075250cea0af69c3659d8048594aa823f59 100644 --- a/addons/mrp/i18n/mrp.pot +++ b/addons/mrp/i18n/mrp.pot @@ -4417,6 +4417,15 @@ msgid "" "date, please correct this to save the work order." msgstr "" +#. module: mrp +#: code:addons/mrp/models/mrp_bom.py:0 +#, python-format +msgid "" +"The product has already been used at least once, editing its structure may " +"lead to undesirable behaviours. You should rather archive the product and " +"create a new one with a new bill of materials." +msgstr "" + #. module: mrp #: code:addons/mrp/models/mrp_production.py:0 #, python-format diff --git a/addons/mrp/models/mrp_bom.py b/addons/mrp/models/mrp_bom.py index 4ff2cdb9c4ecb8d1d090f0dca5b0aa679ab8be06..004283a1fc8ae052ebcbbb33849e3e5e27334349 100644 --- a/addons/mrp/models/mrp_bom.py +++ b/addons/mrp/models/mrp_bom.py @@ -132,6 +132,18 @@ class MrpBom(models.Model): if sum(bom.byproduct_ids.mapped('cost_share')) > 100: raise ValidationError(_("The total cost share for a BoM's by-products cannot exceed 100.")) + @api.onchange('bom_line_ids', 'product_qty') + def onchange_bom_structure(self): + if self.type == 'phantom' and self._origin and self.env['stock.move'].search([('bom_line_id', 'in', self._origin.bom_line_ids.ids)], limit=1): + return { + 'warning': { + 'title': _('Warning'), + 'message': _( + 'The product has already been used at least once, editing its structure may lead to undesirable behaviours. ' + 'You should rather archive the product and create a new one with a new bill of materials.'), + } + } + @api.onchange('product_uom_id') def onchange_product_uom_id(self): res = {} diff --git a/addons/purchase_mrp/i18n/purchase_mrp.pot b/addons/purchase_mrp/i18n/purchase_mrp.pot index 8e6491121428915e12376a3226cd64be71578a38..030e11f5905695b2206b531f59d6129ac4d00554 100644 --- a/addons/purchase_mrp/i18n/purchase_mrp.pot +++ b/addons/purchase_mrp/i18n/purchase_mrp.pot @@ -41,6 +41,14 @@ msgstr "" msgid "Manufacturing Source of %s" msgstr "" +#. module: purchase_mrp +#: code:addons/purchase_mrp/models/stock_move.py:0 +#, python-format +msgid "" +"Odoo is not able to generate the anglo saxon entries. The total valuation of" +" %s is zero." +msgstr "" + #. module: purchase_mrp #: model:ir.model,name:purchase_mrp.model_mrp_production msgid "Production Order" diff --git a/addons/purchase_mrp/models/stock_move.py b/addons/purchase_mrp/models/stock_move.py index abcbdb026f0341861ec2169064a6aadf781f281a..e6e3921952a69960066636646c66d58c63a8dbaf 100644 --- a/addons/purchase_mrp/models/stock_move.py +++ b/addons/purchase_mrp/models/stock_move.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import models +from odoo import _, models +from odoo.tools.float_utils import float_is_zero +from odoo.exceptions import UserError class StockMove(models.Model): @@ -25,4 +27,6 @@ class StockMove(models.Model): } valuation_total_qty = self._compute_kit_quantities(related_aml.product_id, order_qty, kit_bom, filters) valuation_total_qty = kit_bom.product_uom_id._compute_quantity(valuation_total_qty, related_aml.product_id.uom_id) + if float_is_zero(valuation_total_qty, precision_rounding=related_aml.product_uom_id.rounding or related_aml.product_id.uom_id.rounding): + raise UserError(_('Odoo is not able to generate the anglo saxon entries. The total valuation of %s is zero.') % related_aml.product_id.display_name) return valuation_price_unit_total, valuation_total_qty