mirror of
https://github.com/bringout/oca-ocb-mrp.git
synced 2026-04-25 13:32:03 +02:00
19.0 vanilla
This commit is contained in:
parent
accf5918df
commit
6e65e8c877
688 changed files with 225434 additions and 199401 deletions
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
from odoo import _, fields, models, api
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools import float_compare, float_is_zero
|
||||
|
||||
|
||||
class MrpConsumptionWarning(models.TransientModel):
|
||||
|
|
@ -46,33 +45,31 @@ class MrpConsumptionWarning(models.TransientModel):
|
|||
if line.product_id != move.product_id:
|
||||
continue
|
||||
qty_expected = line.product_uom_id._compute_quantity(line.product_expected_qty_uom, move.product_uom)
|
||||
qty_compare_result = float_compare(qty_expected, move.quantity_done, precision_rounding=move.product_uom.rounding)
|
||||
qty_compare_result = move.product_uom.compare(qty_expected, move.quantity)
|
||||
if qty_compare_result != 0:
|
||||
if (move.has_tracking in ('lot', 'serial')
|
||||
and not production.use_auto_consume_components_lots
|
||||
and qty_compare_result > 0):
|
||||
problem_tracked_products |= line.product_id
|
||||
break
|
||||
move.quantity_done = qty_expected
|
||||
move.quantity = qty_expected
|
||||
# move should be set to picked to correctly consume the product
|
||||
move.picked = True
|
||||
# in case multiple lines with same product => set others to 0 since we have no way to know how to distribute the qty done
|
||||
line.product_expected_qty_uom = 0
|
||||
# move was deleted before confirming MO or force deleted somehow
|
||||
if not float_is_zero(line.product_expected_qty_uom, precision_rounding=line.product_uom_id.rounding):
|
||||
if line.product_id.tracking in ('lot', 'serial') and not line.mrp_production_id.use_auto_consume_components_lots:
|
||||
problem_tracked_products |= line.product_id
|
||||
continue
|
||||
if not line.product_uom_id.is_zero(line.product_expected_qty_uom):
|
||||
missing_move_vals.append({
|
||||
'product_id': line.product_id.id,
|
||||
'product_uom': line.product_uom_id.id,
|
||||
'product_uom_qty': line.product_expected_qty_uom,
|
||||
'quantity_done': line.product_expected_qty_uom,
|
||||
'quantity': line.product_expected_qty_uom,
|
||||
'raw_material_production_id': line.mrp_production_id.id,
|
||||
'additional': True,
|
||||
'picked': True,
|
||||
})
|
||||
if problem_tracked_products:
|
||||
products_list = "".join(f"\n- {product_name}" for product_name in problem_tracked_products.mapped("name"))
|
||||
raise UserError(
|
||||
_("Values cannot be set and validated because a Lot/Serial Number needs to be specified for a tracked product that is having its consumed amount increased:\n- ") +
|
||||
"\n- ".join(problem_tracked_products.mapped('name'))
|
||||
_(
|
||||
"Values cannot be set and validated because a Lot/Serial Number needs to be specified for a tracked product that is having its consumed amount increased:%(products)s",
|
||||
products=products_list,
|
||||
),
|
||||
)
|
||||
if missing_move_vals:
|
||||
self.env['stock.move'].create(missing_move_vals)
|
||||
|
|
@ -88,6 +85,7 @@ class MrpConsumptionWarning(models.TransientModel):
|
|||
'target': 'main',
|
||||
}
|
||||
|
||||
|
||||
class MrpConsumptionWarningLine(models.TransientModel):
|
||||
_name = 'mrp.consumption.warning.line'
|
||||
_description = "Line of issue consumption"
|
||||
|
|
@ -97,6 +95,6 @@ class MrpConsumptionWarningLine(models.TransientModel):
|
|||
consumption = fields.Selection(related="mrp_production_id.consumption")
|
||||
|
||||
product_id = fields.Many2one('product.product', "Product", readonly=True, required=True)
|
||||
product_uom_id = fields.Many2one('uom.uom', "Unit of Measure", related="product_id.uom_id", readonly=True)
|
||||
product_uom_id = fields.Many2one('uom.uom', "Unit", related="product_id.uom_id", readonly=True)
|
||||
product_consumed_qty_uom = fields.Float("Consumed", readonly=True)
|
||||
product_expected_qty_uom = fields.Float("To Consume", readonly=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue