17 lines
763 B
Python
17 lines
763 B
Python
from odoo import models
|
|
from odoo.osv.expression import AND
|
|
|
|
|
|
class MrpBom(models.Model):
|
|
_inherit = 'mrp.bom'
|
|
|
|
def _bom_subcontract_find(self, product, picking_type=None, company_id=False, bom_type='subcontract', subcontractor=False):
|
|
domain = self._bom_find_domain(product, picking_type=picking_type, company_id=company_id, bom_type=bom_type)
|
|
if self.env.context.get('stock_picking') == 'outsourcing':
|
|
return self.search(domain, order='sequence, product_id, id', limit=1)
|
|
if subcontractor:
|
|
domain = AND([domain, [('subcontractor_ids', 'parent_of', subcontractor.ids)]])
|
|
return self.search(domain, order='sequence, product_id, id', limit=1)
|
|
else:
|
|
return self.env['mrp.bom']
|