[IMP] mrp: when quantity, location, lot changed log note should be logged
This commit is contained in:
@@ -57,7 +57,7 @@ class MrpProduction(models.Model):
|
||||
product_qty = fields.Float(
|
||||
'Quantity To Produce',
|
||||
default=1.0, digits=dp.get_precision('Product Unit of Measure'),
|
||||
readonly=True, required=True,
|
||||
readonly=True, required=True, track_visibility='onchange',
|
||||
states={'confirmed': [('readonly', False)]})
|
||||
product_uom_id = fields.Many2one(
|
||||
'product.uom', 'Product Unit of Measure',
|
||||
|
||||
@@ -32,11 +32,13 @@ class StockMoveLine(models.Model):
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
if 'lot_id' in vals:
|
||||
for movelot in self:
|
||||
movelot.move_id.production_id.move_raw_ids.mapped('move_line_ids')\
|
||||
.filtered(lambda r: r.done_wo and not r.done_move and r.lot_produced_id == movelot.lot_id)\
|
||||
for move_line in self:
|
||||
if move_line.production_id and 'lot_id' in vals:
|
||||
move_line.production_id.move_raw_ids.mapped('move_line_ids')\
|
||||
.filtered(lambda r: r.done_wo and not r.done_move and r.lot_produced_id == move_line.lot_id)\
|
||||
.write({'lot_produced_id': vals['lot_id']})
|
||||
if move_line.production_id and move_line.state == 'done' and any(field in vals for field in ('lot_id', 'location_id', 'qty_done')):
|
||||
move_line._log_message(move_line.production_id, move_line, 'mrp.track_production_move_template', vals)
|
||||
return super(StockMoveLine, self).write(vals)
|
||||
|
||||
|
||||
|
||||
@@ -89,4 +89,21 @@
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
||||
|
||||
<template id="production_message">
|
||||
<t t-if="move.move_id.raw_material_production_id">
|
||||
<t t-set="message">Consumed</t>
|
||||
</t>
|
||||
<t t-if="move.move_id.production_id">
|
||||
<t t-set="message">Produced</t>
|
||||
</t>
|
||||
<strong><t t-esc="message"/> quantity has been updated.</strong>
|
||||
</template>
|
||||
|
||||
<template id="track_production_move_template">
|
||||
<div>
|
||||
<t t-call="mrp.production_message"/>
|
||||
<t t-call="stock.message_body"/>
|
||||
</div>
|
||||
</template>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user