mirror of
https://github.com/bringout/oca-ocb-sale.git
synced 2026-04-27 20:12:04 +02:00
19.0 vanilla
This commit is contained in:
parent
79f83631d5
commit
73afc09215
6267 changed files with 1534193 additions and 1130106 deletions
|
|
@ -17,17 +17,13 @@ class SaleOrder(models.Model):
|
|||
string='Manufacturing orders associated with this sales order.',
|
||||
groups='mrp.group_mrp_user')
|
||||
|
||||
@api.depends('procurement_group_id.stock_move_ids.created_production_id.procurement_group_id.mrp_production_ids')
|
||||
@api.depends('stock_reference_ids.production_ids')
|
||||
def _compute_mrp_production_ids(self):
|
||||
data = self.env['procurement.group'].read_group([('sale_id', 'in', self.ids)], ['ids:array_agg(id)'], ['sale_id'])
|
||||
mrp_productions = dict()
|
||||
for item in data:
|
||||
procurement_groups = self.env['procurement.group'].browse(item['ids'])
|
||||
mrp_productions[item['sale_id'][0]] = procurement_groups.stock_move_ids.created_production_id.procurement_group_id.mrp_production_ids | procurement_groups.mrp_production_ids
|
||||
for sale in self:
|
||||
mrp_production_ids = mrp_productions.get(sale.id, self.env['mrp.production'])
|
||||
sale.mrp_production_count = len(mrp_production_ids)
|
||||
sale.mrp_production_ids = mrp_production_ids
|
||||
# We want only manufacturing orders of first level
|
||||
mos = sale.stock_reference_ids.production_ids
|
||||
sale.mrp_production_ids = mos.filtered(lambda mo: not mo.production_group_id.parent_ids and mo.state != 'cancel')
|
||||
sale.mrp_production_count = len(sale.mrp_production_ids)
|
||||
|
||||
def action_view_mrp_production(self):
|
||||
self.ensure_one()
|
||||
|
|
@ -44,6 +40,6 @@ class SaleOrder(models.Model):
|
|||
action.update({
|
||||
'name': _("Manufacturing Orders Generated by %s", self.name),
|
||||
'domain': [('id', 'in', self.mrp_production_ids.ids)],
|
||||
'view_mode': 'tree,form',
|
||||
'view_mode': 'list,form',
|
||||
})
|
||||
return action
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue