This commit is contained in:
2026-04-01 21:40:32 +02:00
parent ac988a714a
commit ea2627c9ae
6 changed files with 109 additions and 94 deletions

View File

@@ -1087,14 +1087,17 @@ class Line(metaclass=PoolMeta):
enable_linked_currency = fields.Boolean("Linked currencies")
linked_price = fields.Numeric("Price", digits='unit',states={
'invisible': (~Eval('enable_linked_currency')),
'required': Eval('enable_linked_currency'),
'readonly': Eval('price_type') == 'basis',
}, depends=['enable_linked_currency', 'price_type'])
linked_currency = fields.Many2One('currency.linked',"Currency",states={
'invisible': (~Eval('enable_linked_currency')),
})
linked_unit = fields.Many2One('product.uom', 'Unit',states={
'invisible': (~Eval('enable_linked_currency')),
})
'required': Eval('enable_linked_currency'),
}, depends=['enable_linked_currency'])
linked_unit = fields.Many2One('product.uom', 'Unit',states={
'invisible': (~Eval('enable_linked_currency')),
'required': Eval('enable_linked_currency'),
}, depends=['enable_linked_currency'])
premium = fields.Numeric("Premium/Discount",digits='unit')
fee_ = fields.Many2One('fee.fee',"Fee")

View File

@@ -632,14 +632,17 @@ class SaleLine(metaclass=PoolMeta):
enable_linked_currency = fields.Boolean("Linked currencies")
linked_price = fields.Numeric("Price", digits='unit',states={
'invisible': (~Eval('enable_linked_currency')),
'required': Eval('enable_linked_currency'),
'readonly': Eval('price_type') == 'basis',
}, depends=['enable_linked_currency', 'price_type'])
linked_currency = fields.Many2One('currency.linked',"Currency",states={
'invisible': (~Eval('enable_linked_currency')),
})
linked_unit = fields.Many2One('product.uom', 'Unit',states={
'invisible': (~Eval('enable_linked_currency')),
})
'required': Eval('enable_linked_currency'),
}, depends=['enable_linked_currency'])
linked_unit = fields.Many2One('product.uom', 'Unit',states={
'invisible': (~Eval('enable_linked_currency')),
'required': Eval('enable_linked_currency'),
}, depends=['enable_linked_currency'])
premium = fields.Numeric("Premium/Discount",digits='unit')
fee_ = fields.Many2One('fee.fee',"Fee")
@@ -1095,14 +1098,15 @@ class SaleLine(metaclass=PoolMeta):
return super().copy(lines, default=default)
@classmethod
def validate(cls, salelines):
LotQtHist = Pool().get('lot.qt.hist')
LotQtType = Pool().get('lot.qt.type')
super(SaleLine, cls).validate(salelines)
for line in salelines:
if line.price_components:
for pc in line.price_components:
if pc.triggers:
def validate(cls, salelines):
LotQtHist = Pool().get('lot.qt.hist')
LotQtType = Pool().get('lot.qt.type')
Pnl = Pool().get('valuation.valuation')
super(SaleLine, cls).validate(salelines)
for line in salelines:
if line.price_components:
for pc in line.price_components:
if pc.triggers:
for tr in pc.triggers:
line.check_from_to(tr)
line.check_pricing()
@@ -1139,18 +1143,22 @@ class SaleLine(metaclass=PoolMeta):
fl.sale_line = line.id
FeeLots.save([fl])
#generate valuation for purchase and sale
LotQt = Pool().get('lot.qt')
if line.lots:
for lot in line.lots:
lqts = LotQt.search([('lot_s','=',lot.id),('lot_p','>',0)])
logger.info("VALIDATE_SL:%s",lqts)
if lqts:
purchase_lines = [e.lot_p.line for e in lqts]
if purchase_lines:
for pl in purchase_lines:
Pnl = Pool().get('valuation.valuation')
Pnl.generate(pl)
#generate valuation for purchase and sale
LotQt = Pool().get('lot.qt')
line = cls(line.id)
generated_purchase_side = False
if line.lots:
for lot in line.lots:
lqts = LotQt.search([('lot_s','=',lot.id),('lot_p','>',0)])
logger.info("VALIDATE_SL:%s",lqts)
if lqts:
generated_purchase_side = True
purchase_lines = [e.lot_p.line for e in lqts]
if purchase_lines:
for pl in purchase_lines:
Pnl.generate(pl)
if line.lots and not generated_purchase_side:
Pnl.generate_from_sale_line(line)
class SaleCreatePurchase(Wizard):
"Create mirror purchase"

View File

@@ -2,37 +2,37 @@
<!-- 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="/form/notebook/page[@id='general']/field[@name='unit']" position="after">
<newline/>
<label name="quantity_theorical"/>
<field name="quantity_theorical"/>
<label name="finished"/>
<field name="finished"/>
<newline/>
<label name="enable_linked_currency"/>
<field name="enable_linked_currency"/>
<newline/>
<label name="linked_price"/>
<field name="linked_price"/>
<label name="linked_currency"/>
<field name="linked_currency"/>
<label name="linked_unit"/>
<field name="linked_unit"/>
<newline/>
</xpath>
<xpath expr="/form/notebook/page[@id='general']/field[@name='amount']" position="after">
<newline/>
<label name="price_type"/>
<field name="price_type"/>
<label name="progress"/>
<field name="progress" widget="progressbar"/>
<newline/>
<label name="premium"/>
<field name="premium"/>
<newline/>
<label name="inherit_tol"/>
<field name="inherit_tol"/>
<newline/>
<xpath expr="/form/notebook/page[@id='general']/field[@name='unit']" position="after">
<newline/>
<label name="quantity_theorical"/>
<field name="quantity_theorical"/>
<label name="finished"/>
<field name="finished"/>
<newline/>
<label name="price_type"/>
<field name="price_type"/>
<label name="enable_linked_currency"/>
<field name="enable_linked_currency"/>
<newline/>
<label name="linked_currency"/>
<field name="linked_currency"/>
<label name="linked_unit"/>
<field name="linked_unit"/>
<newline/>
<label name="linked_price"/>
<field name="linked_price"/>
<label name="premium"/>
<field name="premium"/>
<newline/>
</xpath>
<xpath expr="/form/notebook/page[@id='general']/field[@name='amount']" position="after">
<newline/>
<label name="progress"/>
<field name="progress" widget="progressbar"/>
<newline/>
<label name="inherit_tol"/>
<field name="inherit_tol"/>
<newline/>
<label name="tol_min"/>
<field name="tol_min"/>
<label name="tol_min_v"/>
@@ -105,4 +105,4 @@ this repository contains the full copyright notices and license terms. -->
<field name="optional" />
</page>
</xpath>
</data>
</data>

View File

@@ -3,9 +3,11 @@
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="//field[@name='product']" position="after">
<field name="premium"/>
<field name="del_period"/>
<field name="from_del"/>
<field name="to_del"/>
</xpath>
<xpath expr="//field[@name='unit_price']" position="after">
<field name="premium"/>
</xpath>
</data>

View File

@@ -2,37 +2,37 @@
<!-- 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="/form/notebook/page[@id='general']/field[@name='unit']" position="after">
<newline/>
<label name="quantity_theorical"/>
<field name="quantity_theorical"/>
<label name="finished"/>
<field name="finished"/>
<newline/>
<label name="enable_linked_currency"/>
<field name="enable_linked_currency"/>
<newline/>
<label name="linked_price"/>
<field name="linked_price"/>
<label name="linked_currency"/>
<field name="linked_currency"/>
<label name="linked_unit"/>
<field name="linked_unit"/>
<newline/>
</xpath>
<xpath expr="/form/notebook/page[@id='general']/field[@name='amount']" position="after">
<newline/>
<label name="price_type"/>
<field name="price_type"/>
<label name="progress"/>
<field name="progress" widget="progressbar"/>
<newline/>
<label name="premium"/>
<field name="premium"/>
<newline/>
<label name="inherit_tol"/>
<field name="inherit_tol"/>
<newline/>
<xpath expr="/form/notebook/page[@id='general']/field[@name='unit']" position="after">
<newline/>
<label name="quantity_theorical"/>
<field name="quantity_theorical"/>
<label name="finished"/>
<field name="finished"/>
<newline/>
<label name="price_type"/>
<field name="price_type"/>
<label name="enable_linked_currency"/>
<field name="enable_linked_currency"/>
<newline/>
<label name="linked_currency"/>
<field name="linked_currency"/>
<label name="linked_unit"/>
<field name="linked_unit"/>
<newline/>
<label name="linked_price"/>
<field name="linked_price"/>
<label name="premium"/>
<field name="premium"/>
<newline/>
</xpath>
<xpath expr="/form/notebook/page[@id='general']/field[@name='amount']" position="after">
<newline/>
<label name="progress"/>
<field name="progress" widget="progressbar"/>
<newline/>
<label name="inherit_tol"/>
<field name="inherit_tol"/>
<newline/>
<label name="tol_min"/>
<field name="tol_min"/>
<label name="tol_min_v"/>
@@ -91,4 +91,4 @@ this repository contains the full copyright notices and license terms. -->
<field name="estimated_date" />
</page>
</xpath>
</data>
</data>

View File

@@ -3,9 +3,11 @@
this repository contains the full copyright notices and license terms. -->
<data>
<xpath expr="//field[@name='product']" position="after">
<field name="premium"/>
<field name="del_period"/>
<field name="from_del"/>
<field name="to_del"/>
</xpath>
<xpath expr="//field[@name='unit_price']" position="after">
<field name="premium"/>
</xpath>
</data>