[IMP] mrp: add production capacity in split wizard
Add in the split wizard the quantity of MO that can be produced using the available quantity of components. closes odoo/odoo#88855 Pr: https://github.com/odoo/odoo/pull/88855 Task-id: 2773895 Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
@@ -234,6 +234,7 @@ class MrpProduction(models.Model):
|
||||
('available', 'Available'),
|
||||
('expected', 'Expected'),
|
||||
('late', 'Late')], compute='_compute_components_availability')
|
||||
production_capacity = fields.Float(compute='_compute_production_capacity', help="Quantity that can be produced with the current stock of components")
|
||||
show_lot_ids = fields.Boolean('Display the serial number shortcut on the moves', compute='_compute_show_lot_ids')
|
||||
forecasted_issue = fields.Boolean(compute='_compute_forecasted_issue')
|
||||
show_serial_mass_produce = fields.Boolean('Display the serial mass produce wizard action', compute='_compute_show_serial_mass_produce')
|
||||
@@ -356,6 +357,15 @@ class MrpProduction(models.Model):
|
||||
if production.bom_id and production._origin.bom_id != production.bom_id:
|
||||
production.product_qty = production.bom_id.product_qty
|
||||
|
||||
@api.depends('move_raw_ids')
|
||||
def _compute_production_capacity(self):
|
||||
for production in self:
|
||||
production.production_capacity = production.product_qty
|
||||
moves = production.move_raw_ids.filtered(lambda move: move.unit_factor and move.product_id.type != 'consu')
|
||||
if moves:
|
||||
production_capacity = min(moves.mapped(lambda move: move.product_id.uom_id._compute_quantity(move.product_id.qty_available, move.product_uom) / move.unit_factor))
|
||||
production.production_capacity = min(production.product_qty, float_round(production_capacity, precision_rounding=production.product_id.uom_id.rounding))
|
||||
|
||||
@api.depends('move_finished_ids.date_deadline')
|
||||
def _compute_date_deadline(self):
|
||||
for production in self:
|
||||
|
||||
@@ -21,6 +21,7 @@ class MrpProductionSplit(models.TransientModel):
|
||||
product_id = fields.Many2one(related='production_id.product_id')
|
||||
product_qty = fields.Float(related='production_id.product_qty')
|
||||
product_uom_id = fields.Many2one(related='production_id.product_uom_id')
|
||||
production_capacity = fields.Float(related='production_id.production_capacity')
|
||||
counter = fields.Integer(
|
||||
"Split #", default=0, compute="_compute_counter",
|
||||
store=True, readonly=False)
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
<field name="production_id"/>
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom_id"/>
|
||||
<field name="production_capacity"/>
|
||||
<field name="product_uom_id" groups="uom.group_uom"/>
|
||||
<button name="action_prepare_split" type="object" icon="fa-scissors" width="0.1" title="Split Production"/>
|
||||
</tree>
|
||||
</field>
|
||||
@@ -35,12 +36,22 @@
|
||||
</group>
|
||||
<group>
|
||||
<field name="product_id"/>
|
||||
<field name="product_qty"/>
|
||||
<field name="product_uom_id"/>
|
||||
<label for="product_qty"/>
|
||||
<div class="o_row">
|
||||
<span><field name="product_qty"/></span>
|
||||
<span><field name="product_uom_id" groups="uom.group_uom"/></span>
|
||||
</div>
|
||||
</group>
|
||||
<group>
|
||||
<field name="counter"/>
|
||||
</group>
|
||||
<group>
|
||||
<label for="production_capacity"/>
|
||||
<div class="o_row">
|
||||
<span><field name="production_capacity"/></span>
|
||||
<span><field name="product_uom_id" groups="uom.group_uom"/></span>
|
||||
</div>
|
||||
</group>
|
||||
</group>
|
||||
<field name="production_detailed_vals_ids" attrs="{'invisible': [('counter', '=', 0)]}">
|
||||
<tree editable="top">
|
||||
|
||||
Reference in New Issue
Block a user