Skip to content

Commit

Permalink
Merge 96a1733 into 97b5456
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Pigeon (ACSONE) committed Dec 3, 2019
2 parents 97b5456 + 96a1733 commit ef860d1
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions stock_available_mrp/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,36 @@ class ProductProduct(models.Model):
def _compute_available_quantities(self):
super(ProductProduct, self)._compute_available_quantities()

@api.multi
def _get_bom_id_domain(self):
"""
Real multi domain
:return:
"""
return [
'|',
('product_id', 'in', self.ids),
'&',
('product_id', '=', False),
('product_tmpl_id', 'in', self.mapped('product_tmpl_id.id'))
]

@api.multi
@api.depends('product_tmpl_id')
def _compute_bom_id(self):
for one in self:
one.bom_id = self.env["mrp.bom"]._bom_find(product=one)
bom_obj = self.env['mrp.bom']
boms = bom_obj.search(
self._get_bom_id_domain(),
order='sequence, product_id',
)
for product in self:
product_boms = boms.filtered(
lambda b: b.product_id == product or
(not b.product_id and
b.product_tmpl_id == product.product_tmpl_id)
)
if product_boms:
product.bom_id = first(product_boms)

@api.multi
def _compute_available_quantities_dict(self):
Expand Down

0 comments on commit ef860d1

Please sign in to comment.