From eb0b35c83214b98320f74bb65b6f56c25e5e3883 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=80ngel=20=C3=80lvarez=20Serra?= Date: Wed, 29 Mar 2023 16:00:47 +0200 Subject: [PATCH] add vintage to rec_name and product_list_view #157618 --- product.py | 14 ++++++++++++++ view/product_list.xml | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/product.py b/product.py index b289924..132fab7 100644 --- a/product.py +++ b/product.py @@ -128,6 +128,11 @@ class Product(WineMixin, metaclass=PoolMeta): 'get_wine_history', searcher='search_wine_history') wine_history_duration = fields.Function(fields.Text("History Duration"), 'get_wine_history', searcher='search_wine_history') + vintages_str = fields.Function(fields.Char("Vintage"), 'get_vintages_str') + + def get_vintages_str(self, name): + return ', '.join([v.name for v in self.vintages]) + @classmethod def deactivate_no_stock_variants_cron(cls): @@ -226,6 +231,15 @@ class Product(WineMixin, metaclass=PoolMeta): return [('id', 'in', query)] + def get_rec_name(self, name): + rec_name = super().get_rec_name(name) + if not self.vintages: + return rec_name + + aging = ",".join(x.name for x in self.vintages) + rec_name = rec_name + "-" + aging + return rec_name + class Cron(metaclass=PoolMeta): __name__ = 'ir.cron' diff --git a/view/product_list.xml b/view/product_list.xml index 31000ae..b81ee17 100644 --- a/view/product_list.xml +++ b/view/product_list.xml @@ -1,4 +1,9 @@ + + + + +