[IMP] mrp: planning with components availability

added a contextual action to call action_plan_with_components_availability()
if each component line of a production order has a forecast_expected_date,
the date_start of the production order will be the latest forecasted date
task 3395161

Part-of: odoo/odoo#129933
This commit is contained in:
snd
2023-09-21 08:59:42 +00:00
parent 7230d53964
commit abe429ca57
2 changed files with 20 additions and 0 deletions
+10
View File
@@ -2199,6 +2199,16 @@ class MrpProduction(models.Model):
'res_id': production.id,
}
def action_plan_with_components_availability(self):
for production in self.filtered(lambda p: p.state in ('draft', 'confirmed')):
if production.state == 'draft':
production.action_confirm()
expected_date = max(production.move_raw_ids.filtered('forecast_expected_date').mapped('forecast_expected_date'), default=False)
if expected_date:
production.date_start = expected_date
self.button_plan()
def _has_workorders(self):
return self.workorder_ids
+10
View File
@@ -79,6 +79,16 @@
<field name="code">action = records.action_split()</field>
</record>
<record id="action_plan_with_components_availability" model="ir.actions.server">
<field name="name">Plan based on Components Availability</field>
<field name="groups_id" eval="[(4, ref('mrp.group_mrp_routings'))]"/>
<field name="model_id" ref="mrp.model_mrp_production"/>
<field name="binding_model_id" ref="mrp.model_mrp_production"/>
<field name="binding_view_types">list,form</field>
<field name="state">code</field>
<field name="code">action = records.action_plan_with_components_availability()</field>
</record>
<record id="action_production_order_merge" model="ir.actions.server">
<field name="name">Merge</field>
<field name="model_id" ref="mrp.model_mrp_production"/>