我想在产品中使用名称搜索,通过搜索stock.production.lot
中的批次名称来获得产品
relation stock_quant_ids,product_id,lot_id
class ProductProduct(models.Model):
_inherit = 'product.product'
@api.model
def name_search(self, name='', args=None, operator='ilike', limit=100):
args = args or []
print('arg ',args)
recs = self.search([('???', operator, name)] args, limit=limit) #stock_quant_ids.lot_id.name
print('recs ', recs)
if not recs.ids:
return super(ProductProduct, self).name_search(name=name, args=args,
operator=operator,
limit=limit)
return recs.name_get()
试试这个:
相关问题 更多 >
编程相关推荐