@@ -1,3 +1,4 @@
|
||||
* Add button to open price list lines
|
||||
|
||||
Version 7.2.0 - 2024-04-29
|
||||
--------------------------
|
||||
|
||||
@@ -12,4 +12,5 @@ def register():
|
||||
Pool.register(
|
||||
price_list.PriceList,
|
||||
price_list.PriceListLine,
|
||||
price_list.PriceListLineContext,
|
||||
module='product_price_list', type_='model')
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -54,6 +54,12 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="perm_delete" eval="True"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.model.button" id="price_list_open_lines_button">
|
||||
<field name="model">product.price_list</field>
|
||||
<field name="name">open_lines</field>
|
||||
<field name="string">Open Lines</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.rule.group" id="rule_group_price_list_companies">
|
||||
<field name="name">User in companies</field>
|
||||
<field name="model">product.price_list</field>
|
||||
@@ -85,5 +91,27 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">price_list_line_tree_sequence</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.act_window" id="act_price_list_line_form">
|
||||
<field name="name">Price List Lines</field>
|
||||
<field name="res_model">product.price_list.line</field>
|
||||
<field name="context_model">product.price_list.line.context</field>
|
||||
<field name="domain" eval="[('price_list', '=', Eval('active_id'))]" pyson="1"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_price_list_line_form_view1">
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="view" ref="price_list_line_view_tree_sequence"/>
|
||||
<field name="act_window" ref="act_price_list_line_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view" id="act_price_list_line_form_view2">
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="view" ref="price_list_line_view_form"/>
|
||||
<field name="act_window" ref="act_price_list_line_form"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="price_list_line_context_view_form">
|
||||
<field name="model">product.price_list.line.context</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">price_list_line_context_form</field>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
||||
|
||||
@@ -26,6 +26,7 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<page name="lines">
|
||||
<field name="lines" colspan="4"
|
||||
view_ids="product_price_list.price_list_line_view_tree_sequence"/>
|
||||
<button name="open_lines" colspan="4"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
|
||||
+3
-5
@@ -1,8 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<data>
|
||||
<xpath expr="//field[@name='lines']" position="after">
|
||||
<button name="open_lines" colspan="4"/>
|
||||
</xpath>
|
||||
</data>
|
||||
<form>
|
||||
</form>
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -3,18 +3,6 @@
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="price_list_view_form">
|
||||
<field name="model">product.price_list</field>
|
||||
<field name="inherit"
|
||||
ref="product_price_list.price_list_view_form"/>
|
||||
<field name="name">price_list_form</field>
|
||||
</record>
|
||||
<record model="ir.model.button" id="price_list_open_lines_button">
|
||||
<field name="model">product.price_list</field>
|
||||
<field name="name">open_lines</field>
|
||||
<field name="string">Open Lines</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="price_list_line_view_form">
|
||||
<field name="model">product.price_list.line</field>
|
||||
<field name="inherit"
|
||||
@@ -36,35 +24,9 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="name">price_list_line_tree_sequence</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.action.act_window" id="act_price_list_line_form">
|
||||
<field name="name">Lines</field>
|
||||
<field name="res_model">product.price_list.line</field>
|
||||
<field name="context_model">product.price_list.line.context</field>
|
||||
<field name="domain"
|
||||
eval="[('price_list', '=', Eval('active_id'))]"
|
||||
pyson="1"/>
|
||||
<field name="context_domain"
|
||||
eval="[['OR', ('start_date', '=', None), ('start_date', '<=', Eval('date', Date()))], ['OR', ('end_date', '=', None), ('end_date', '>=', Eval('date', Date()))]]"
|
||||
pyson="1"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view"
|
||||
id="act_price_list_line_form_view1">
|
||||
<field name="sequence" eval="10"/>
|
||||
<field name="view"
|
||||
ref="product_price_list.price_list_line_view_tree_sequence"/>
|
||||
<field name="act_window" ref="act_price_list_line_form"/>
|
||||
</record>
|
||||
<record model="ir.action.act_window.view"
|
||||
id="act_price_list_line_form_view2">
|
||||
<field name="sequence" eval="20"/>
|
||||
<field name="view"
|
||||
ref="product_price_list.price_list_line_view_form"/>
|
||||
<field name="act_window" ref="act_price_list_line_form"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="price_list_line_context_view_form">
|
||||
<field name="model">product.price_list.line.context</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit" ref="product_price_list.price_list_line_context_view_form"/>
|
||||
<field name="name">price_list_line_context_form</field>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="date"/>
|
||||
<field name="date"/>
|
||||
</form>
|
||||
<data>
|
||||
<xpath expr="/form" position="inside">
|
||||
<newline/>
|
||||
<label name="date"/>
|
||||
<field name="date"/>
|
||||
<newline/>
|
||||
</xpath>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user