05.03.26
This commit is contained in:
@@ -19,6 +19,9 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<label name="concentration"/>
|
<label name="concentration"/>
|
||||||
<field name="concentration"/>
|
<field name="concentration"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
|
<label name="attributes"/>
|
||||||
|
<field name="attributes"/>
|
||||||
|
<newline/>
|
||||||
<label name="del_period"/>
|
<label name="del_period"/>
|
||||||
<field name="del_period"/>
|
<field name="del_period"/>
|
||||||
<label name="period_at"/>
|
<label name="period_at"/>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from trytond.model import ModelSingleton, ModelSQL, ModelView, fields
|
from trytond.model import ModelSingleton, ModelSQL, ModelView, fields
|
||||||
|
from trytond.i18n import gettext
|
||||||
from trytond.report import Report
|
from trytond.report import Report
|
||||||
from trytond.pool import Pool, PoolMeta
|
from trytond.pool import Pool, PoolMeta
|
||||||
from trytond.pyson import Bool, Eval, Id, If, PYSONEncoder
|
from trytond.pyson import Bool, Eval, Id, If, PYSONEncoder
|
||||||
@@ -484,6 +485,42 @@ class Line(metaclass=PoolMeta):
|
|||||||
premium = fields.Numeric("Premium/Discount",digits='unit')
|
premium = fields.Numeric("Premium/Discount",digits='unit')
|
||||||
fee_ = fields.Many2One('fee.fee',"Fee")
|
fee_ = fields.Many2One('fee.fee',"Fee")
|
||||||
|
|
||||||
|
attributes = fields.Dict('product.attribute', 'Attributes',
|
||||||
|
domain=[
|
||||||
|
('sets', '=', Eval('product._parent_template', {}).get('attribute_set',
|
||||||
|
Eval('attribute_set', -1))),
|
||||||
|
],
|
||||||
|
states={
|
||||||
|
'readonly': (~Eval('attribute_set')
|
||||||
|
& ~Eval('product._parent_template', {}).get('attribute_set')),
|
||||||
|
},
|
||||||
|
depends={'product.template'},
|
||||||
|
help="Add attributes to the variant.")
|
||||||
|
|
||||||
|
attributes_name = fields.Function(fields.Char(
|
||||||
|
"Attributes Name",
|
||||||
|
states={
|
||||||
|
'invisible': ~Eval('attribute_set'),
|
||||||
|
}),
|
||||||
|
'on_change_with_attributes_name')
|
||||||
|
|
||||||
|
@fields.depends('product', 'attributes')
|
||||||
|
def on_change_with_attributes_name(self, name=None):
|
||||||
|
if not self.product.attribute_set or not self.attributes:
|
||||||
|
return
|
||||||
|
|
||||||
|
def key(attribute):
|
||||||
|
return getattr(attribute, 'sequence', attribute.name)
|
||||||
|
|
||||||
|
values = []
|
||||||
|
for attribute in sorted(self.product.attribute_set.attributes, key=key):
|
||||||
|
if attribute.name in self.attributes:
|
||||||
|
value = self.attributes[attribute.name]
|
||||||
|
values.append(gettext('product_attribute.msg_label_value',
|
||||||
|
label=attribute.string,
|
||||||
|
value=attribute.format(value)))
|
||||||
|
return " | ".join(filter(None, values))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default_price_type(cls):
|
def default_price_type(cls):
|
||||||
return 'priced'
|
return 'priced'
|
||||||
|
|||||||
Reference in New Issue
Block a user