[IMP] mrp: forecast widget

Add the forecast widget for the manufacture orders' components.

task-2058495
This commit is contained in:
svs-odoo
2020-07-31 12:36:55 +00:00
parent 89625df828
commit 372b900fe3
3 changed files with 15 additions and 4 deletions
+6
View File
@@ -317,6 +317,12 @@ class StockMove(models.Model):
vals['state'] = 'assigned'
return vals
@api.model
def _consuming_picking_types(self):
res = super()._consuming_picking_types()
res.append('mrp_operation')
return res
def _get_source_document(self):
res = super()._get_source_document()
return res or self.production_id or self.raw_material_production_id
+8 -3
View File
@@ -869,13 +869,18 @@ class TestMrpOrder(TestMrpCommon):
mo_form = Form(mo)
mo_form.qty_producing = 3
self.assertEqual(sum([x['quantity_done'] for x in mo_form.move_raw_ids._records]), 15, 'Update the produce quantity should change the components quantity.')
self.assertEqual(sum([x['reserved_availability'] for x in mo_form.move_raw_ids._records]), 5, 'Update the produce quantity should not change the components reserved quantity.')
mo = mo_form.save()
self.assertEqual(sum(mo.move_raw_ids.mapped('reserved_availability')), 5, 'Update the produce quantity should not change the components reserved quantity.')
mo_form = Form(mo)
mo_form.qty_producing = 4
self.assertEqual(sum([x['quantity_done'] for x in mo_form.move_raw_ids._records]), 20, 'Update the produce quantity should change the components quantity.')
self.assertEqual(sum([x['reserved_availability'] for x in mo_form.move_raw_ids._records]), 5, 'Update the produce quantity should not change the components reserved quantity.')
mo = mo_form.save()
self.assertEqual(sum(mo.move_raw_ids.mapped('reserved_availability')), 5, 'Update the produce quantity should not change the components reserved quantity.')
mo_form = Form(mo)
mo_form.qty_producing = 1
self.assertEqual(sum([x['quantity_done'] for x in mo_form.move_raw_ids._records]), 5, 'Update the produce quantity should change the components quantity.')
self.assertEqual(sum([x['reserved_availability'] for x in mo_form.move_raw_ids._records]), 5, 'Update the produce quantity should not change the components reserved quantity.')
mo = mo_form.save()
self.assertEqual(sum(mo.move_raw_ids.mapped('reserved_availability')), 5, 'Update the produce quantity should not change the components reserved quantity.')
# try adding another product that doesn't belong to the BoM
with mo_form.move_raw_ids.new() as move:
move.product_id = self.product_4
+1 -1
View File
@@ -254,7 +254,7 @@
<field name="state" invisible="1" force_save="1"/>
<field name="should_consume_qty" invisible="1"/>
<field name="product_uom_qty" widget="mrp_should_consume" string="To Consume" attrs="{'readonly': ['&amp;', ('parent.state', '!=', 'draft'), '|', ('parent.state', 'not in', ('confirmed', 'planned', 'progress', 'to_close')), ('parent.is_locked', '=', True)]}" width="1"/>
<field name="reserved_availability" attrs="{'invisible': [('is_done', '=', True)], 'column_invisible': [('parent.state', 'in', ('draft', 'done'))]}" string="Reserved" decoration-danger="not is_done and reserved_availability &lt; product_uom_qty and product_uom_qty - reserved_availability &gt; 0.0001"/>
<field name="json_forecast" string="Reserved" attrs="{'column_invisible': [('parent.state', 'in', ['draft', 'done'])]}" widget="forecast_widget"/>
<field name="is_quantity_done_editable" invisible="1"/>
<field name="quantity_done" string="Consumed"
decoration-success="not is_done and (quantity_done - should_consume_qty == 0)"