Skip to Content
Menu
This question has been flagged
602 Views

Hello,

I want the lowest mrp name from one2many field in kanban view

.py

class Productproduct(models.Model):
_inherit = 'product.product'

all_mrp = fields.Char(String="MRP",compute='compute_all_mrp_values')


# @api.depends('product_mrp_ids','product_mrp_ids.mrp','name')
def compute_all_mrp_values(self):
for i in self:
if len(i.product_mrp_ids) > 1:
# for mrp in self.product_id.product_mrp_ids:
recs_sorted = i.product_mrp_ids.sorted(key=lambda r: r.mrp)
mrp_value = recs_sorted[0]
i.all_mrp = mrp_value.name + ' ' + 'more'


elif len(i.product_mrp_ids) == 1:
# for mrp in self.product_id.product_mrp_ids:
recs_sorted = i.product_mrp_ids.sorted(key=lambda r: r.mrp)
mrp_value = recs_sorted[0]
i.all_mrp = mrp_value.name


else:
i.all_mrp = ""

return

from this code all_mrp field shows values in form view . but in kanban view it shows only for one product why? when i write store= True compute function is not working.how can i get the char field in kanban view for all products?

Avatar
Discard