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. -->
+
diff --git a/modules/product_price_list_dates/view/price_list_form.xml b/modules/product_price_list/view/price_list_line_context_form.xml
similarity index 55%
rename from modules/product_price_list_dates/view/price_list_form.xml
rename to modules/product_price_list/view/price_list_line_context_form.xml
index fd7fa5bd25..4b58158419 100644
--- a/modules/product_price_list_dates/view/price_list_form.xml
+++ b/modules/product_price_list/view/price_list_line_context_form.xml
@@ -1,8 +1,6 @@
-
-
-
-
-
+
+
diff --git a/modules/product_price_list_dates/product.py b/modules/product_price_list_dates/product.py
index bc45abaf95..0318457573 100644
--- a/modules/product_price_list_dates/product.py
+++ b/modules/product_price_list_dates/product.py
@@ -6,7 +6,7 @@ import datetime as dt
from trytond.config import config
from trytond.model import ModelView, fields
from trytond.pool import Pool, PoolMeta
-from trytond.pyson import Eval, If
+from trytond.pyson import Date, Eval, If, PYSONDecoder, PYSONEncoder
from trytond.transaction import Transaction
_cache_days = config.getint(
@@ -16,18 +16,34 @@ _cache_days = config.getint(
class PriceList(metaclass=PoolMeta):
__name__ = 'product.price_list'
- @classmethod
- def __setup__(cls):
- super(PriceList, cls).__setup__()
- cls._buttons.update({
- 'open_lines': {},
- })
-
@classmethod
@ModelView.button_action(
- 'product_price_list_dates.act_price_list_line_form')
+ 'product_price_list.act_price_list_line_form')
def open_lines(cls, price_lists):
- pass
+ encoder = PYSONEncoder()
+ decoder = PYSONDecoder(noeval=True)
+ action = super().open_lines(price_lists)
+ context_domain = [
+ ['OR',
+ ('start_date', '=', None),
+ ('start_date', '<=', Eval('date', Date())),
+ ],
+ ['OR',
+ ('end_date', '=', None),
+ ('end_date', '>=', Eval('date', Date())),
+ ],
+ ]
+ if isinstance(action, dict):
+ if action.get('context_domain'):
+ context_domain = [
+ decoder.decode(action['context_domain']),
+ context_domain]
+ action['context_domain'] = encoder.encode(context_domain)
+ else:
+ action = {
+ 'context_domain': encoder.encode(context_domain),
+ }
+ return action
def compute(self, product, quantity, uom, pattern=None):
context = Transaction().context
@@ -93,8 +109,7 @@ class PriceListLine(metaclass=PoolMeta):
return super(PriceListLine, self).match(pattern)
-class PriceListLineContext(ModelView):
- "Price List Line Context"
+class PriceListLineContext(metaclass=PoolMeta):
__name__ = 'product.price_list.line.context'
date = fields.Date("Date")
diff --git a/modules/product_price_list_dates/product.xml b/modules/product_price_list_dates/product.xml
index 46e7574f75..674db0305f 100644
--- a/modules/product_price_list_dates/product.xml
+++ b/modules/product_price_list_dates/product.xml
@@ -3,18 +3,6 @@
this repository contains the full copyright notices and license terms. -->
-
- product.price_list
-
- price_list_form
-
-
- product.price_list
- open_lines
- Open Lines
-
-
product.price_list.line
price_list_line_tree_sequence
-
- 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_dates/view/price_list_line_context_form.xml b/modules/product_price_list_dates/view/price_list_line_context_form.xml
index e65847939d..1049cc20b2 100644
--- a/modules/product_price_list_dates/view/price_list_line_context_form.xml
+++ b/modules/product_price_list_dates/view/price_list_line_context_form.xml
@@ -1,7 +1,11 @@
-
+
+
+
+
+
+
+
+