From d9b275e181137265bfe499c9cfce643a677d6e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 18 Sep 2024 18:14:58 +0200 Subject: [PATCH] Move "Open Lines" button to product price list module Closes #13527 --- modules/product_price_list/CHANGELOG | 1 + modules/product_price_list/__init__.py | 1 + modules/product_price_list/price_list.py | 18 +++++++++ modules/product_price_list/price_list.xml | 28 +++++++++++++ .../view/price_list_form.xml | 1 + .../view/price_list_line_context_form.xml} | 8 ++-- modules/product_price_list_dates/product.py | 39 ++++++++++++------ modules/product_price_list_dates/product.xml | 40 +------------------ .../view/price_list_line_context_form.xml | 12 ++++-- 9 files changed, 88 insertions(+), 60 deletions(-) rename modules/{product_price_list_dates/view/price_list_form.xml => product_price_list/view/price_list_line_context_form.xml} (55%) diff --git a/modules/product_price_list/CHANGELOG b/modules/product_price_list/CHANGELOG index 97d822783b..f90da410d9 100644 --- a/modules/product_price_list/CHANGELOG +++ b/modules/product_price_list/CHANGELOG @@ -1,3 +1,4 @@ +* Add button to open price list lines Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/product_price_list/__init__.py b/modules/product_price_list/__init__.py index 7a82f2dd25..23cbc2447e 100644 --- a/modules/product_price_list/__init__.py +++ b/modules/product_price_list/__init__.py @@ -12,4 +12,5 @@ def register(): Pool.register( price_list.PriceList, price_list.PriceListLine, + price_list.PriceListLineContext, module='product_price_list', type_='model') diff --git a/modules/product_price_list/price_list.py b/modules/product_price_list/price_list.py index 7a75124afc..f96a2beb33 100644 --- a/modules/product_price_list/price_list.py +++ b/modules/product_price_list/price_list.py @@ -66,6 +66,13 @@ class PriceList(DeactivableMixin, ModelSQL, ModelView): help="Add price formulas for different criteria.\n" "The first matching line is used.") + @classmethod + def __setup__(cls): + super().__setup__() + cls._buttons.update({ + 'open_lines': {}, + }) + @staticmethod def default_company(): return Transaction().context.get('company') @@ -102,6 +109,12 @@ class PriceList(DeactivableMixin, ModelSQL, ModelView): def get_uom(self, product): return product.default_uom + @classmethod + @ModelView.button_action( + 'product_price_list.act_price_list_line_form') + def open_lines(cls, price_lists): + return {} + def compute(self, product, quantity, uom, pattern=None): Uom = Pool().get('product.uom') @@ -206,3 +219,8 @@ class PriceListLine(sequence_ordered(), ModelSQL, ModelView, MatchMixin): 'Return unit price (as Decimal)' context.setdefault('functions', {})['Decimal'] = Decimal return simple_eval(decistmt(self.formula), **context) + + +class PriceListLineContext(ModelView): + "Price List Line Context" + __name__ = 'product.price_list.line.context' diff --git a/modules/product_price_list/price_list.xml b/modules/product_price_list/price_list.xml index 4795b514d8..79cc0c680a 100644 --- a/modules/product_price_list/price_list.xml +++ b/modules/product_price_list/price_list.xml @@ -54,6 +54,12 @@ this repository contains the full copyright notices and license terms. --> + + product.price_list + open_lines + Open Lines + + User in companies product.price_list @@ -85,5 +91,27 @@ this repository contains the full copyright notices and license terms. --> price_list_line_tree_sequence + + Price List Lines + product.price_list.line + product.price_list.line.context + + + + + + + + + + + + + + + product.price_list.line.context + form + price_list_line_context_form + diff --git a/modules/product_price_list/view/price_list_form.xml b/modules/product_price_list/view/price_list_form.xml index b4806a79bd..e14d9966fb 100644 --- a/modules/product_price_list/view/price_list_form.xml +++ b/modules/product_price_list/view/price_list_form.xml @@ -26,6 +26,7 @@ this repository contains the full copyright notices and license terms. --> +