product_usability: make the field seller_id searcheable
This commit is contained in:
@@ -16,6 +16,7 @@ class ProductTemplate(models.Model):
|
|||||||
seller_id = fields.Many2one(
|
seller_id = fields.Many2one(
|
||||||
'res.partner',
|
'res.partner',
|
||||||
compute="_compute_seller_id",
|
compute="_compute_seller_id",
|
||||||
|
search="_search_seller_id",
|
||||||
string='Main Supplier')
|
string='Main Supplier')
|
||||||
|
|
||||||
# in v14, I noticed that the tracking of the fields of product.template
|
# in v14, I noticed that the tracking of the fields of product.template
|
||||||
@@ -34,6 +35,15 @@ class ProductTemplate(models.Model):
|
|||||||
company_id = fields.Many2one(tracking=110)
|
company_id = fields.Many2one(tracking=110)
|
||||||
barcode_type = fields.Char(compute='_compute_template_barcode_type')
|
barcode_type = fields.Char(compute='_compute_template_barcode_type')
|
||||||
|
|
||||||
|
|
||||||
|
def _search_seller_id(self, operator, value):
|
||||||
|
# searching on the first line of a o2m is not that easy
|
||||||
|
# So we search all potential matching products
|
||||||
|
# Then we filter on the seller_id
|
||||||
|
records = self.search([("seller_ids.partner_id", operator, value)])
|
||||||
|
records = records.filtered_domain([("seller_id", operator, value)])
|
||||||
|
return [("id", "in", records.ids)]
|
||||||
|
|
||||||
def _compute_seller_id(self):
|
def _compute_seller_id(self):
|
||||||
for record in self:
|
for record in self:
|
||||||
record.seller_id = fields.first(record.seller_ids).name
|
record.seller_id = fields.first(record.seller_ids).name
|
||||||
|
|||||||
Reference in New Issue
Block a user