This commit is contained in:
2026-03-09 15:17:34 +01:00
parent 372d04b30f
commit 83ef3c6ae9
9 changed files with 246 additions and 1791 deletions

View File

@@ -258,6 +258,7 @@ class Sale(metaclass=PoolMeta):
operator = fields.Many2One('party.party',"Operator")
our_reference = fields.Char("Our Reference")
company_visible = fields.Function(fields.Boolean("Visible"),'get_company_info')
lc_date = fields.Date("LC date")
def get_company_info(self,name):
return (self.company.party.name == 'MELYA')
@@ -279,7 +280,10 @@ class Sale(metaclass=PoolMeta):
@property
def report_price(self):
if self.lines:
return amount_to_currency_words(self.lines[0].unit_price)
if self.lines[0].price_type == 'fixed':
return amount_to_currency_words(self.lines[0].unit_price)
elif self.lines[0].price_type == 'basis':
return amount_to_currency_words(self.lines[0].unit_price) + ' ' + self.lines[0].get_pricing_text()
else:
return ''
@@ -511,6 +515,52 @@ class SaleLine(metaclass=PoolMeta):
premium = fields.Numeric("Premium/Discount",digits='unit')
fee_ = fields.Many2One('fee.fee',"Fee")
attributes = fields.Dict(
'product.attribute', 'Attributes',
domain=[
('sets', '=', Eval('attribute_set')),
],
states={
'readonly': ~Eval('attribute_set'),
},
depends=['product', 'attribute_set'],
help="Add attributes to the variant."
)
attribute_set = fields.Function(
fields.Many2One('product.attribute.set', "Attribute Set"),
'on_change_with_attribute_set'
)
attributes_name = fields.Function(
fields.Char("Attributes Name"),
'on_change_with_attributes_name'
)
@fields.depends('product')
def on_change_with_attribute_set(self, name=None):
if self.product and self.product.template and self.product.template.attribute_set:
return self.product.template.attribute_set.id
@fields.depends('product', 'attributes')
def on_change_with_attributes_name(self, name=None):
if not self.product or 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
def default_price_type(cls):
return 'priced'
@@ -532,6 +582,14 @@ class SaleLine(metaclass=PoolMeta):
LotQt = Pool().get('lot.qt')
return LotQt.search([('lot_s','=',self.lots[0].id),('lot_p','>',0)])
def get_pricing_text(self):
pricing_text = ''
if self.price_components:
for pc in self.price_components:
if pc.price_index:
pricing_text += ' ' + pc.price_index.description
return pricing_text
def get_date(self,trigger_event):
trigger_date = None
if self.estimated_date: