Skip to content
Snippets Groups Projects
Commit 96b56ea3 authored by Andrea Grazioso (agr-odoo)'s avatar Andrea Grazioso (agr-odoo)
Browse files

[FIX] sale_mrp: MO link missing with 3steps manufacture


- Storable product with MTO and manufacture route;
- On your warehouse set 3 steps manufacture
- Create a SO for this product > Confirm

The smart button linking the Manufacturing order does not appear on
the MO.

opw-2634309

closes odoo/odoo#76485

Signed-off-by: default avatarRémy Voet <ryv-odoo@users.noreply.github.com>
Co-authored-by: default avatarArnold Moyaux <arm@odoo.com>
parent abc9fdaa
No related branches found
No related tags found
No related merge requests found
......@@ -89,7 +89,11 @@ class StockRule(models.Model):
# Create now the procurement group that will be assigned to the new MO
# This ensure that the outgoing move PostProduction -> Stock is linked to its MO
# rather than the original record (MO or SO)
procurement.values['group_id'] = self.env["procurement.group"].create({'name': name})
group = procurement.values.get('group_id')
if group:
procurement.values['group_id'] = group.copy({'name': name})
else:
procurement.values['group_id'] = self.env["procurement.group"].create({'name': name})
return super()._run_pull(procurements)
def _get_custom_move_fields(self):
......
......@@ -14,12 +14,16 @@ class SaleOrder(models.Model):
@api.depends('procurement_group_id.stock_move_ids.created_production_id.procurement_group_id.mrp_production_ids')
def _compute_mrp_production_count(self):
data = self.env['procurement.group'].read_group([('sale_id', 'in', self.ids), ('mrp_production_ids', '!=', False)], ['id'], ['sale_id'])
mrp_count = dict()
for item in data:
mrp_count[item['sale_id'][0]] = item['sale_id_count']
for sale in self:
sale.mrp_production_count = len(sale.procurement_group_id.stock_move_ids.created_production_id.procurement_group_id.mrp_production_ids)
sale.mrp_production_count = mrp_count.get(sale.id)
def action_view_mrp_production(self):
self.ensure_one()
mrp_production_ids = self.procurement_group_id.stock_move_ids.created_production_id.procurement_group_id.mrp_production_ids.ids
mrp_production_ids = self.env['mrp.production'].search([('procurement_group_id.sale_id', '=', self.id)]).ids
action = {
'res_model': 'mrp.production',
'type': 'ir.actions.act_window',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment