feat: Se añade campo rate in SaleLine
This commit is contained in:
parent
0bc83265e1
commit
c2b590b052
19
sale.py
19
sale.py
@ -2,6 +2,7 @@ from trytond.pool import Pool, PoolMeta
|
|||||||
from trytond.model import ModelView, fields
|
from trytond.model import ModelView, fields
|
||||||
from trytond.transaction import Transaction
|
from trytond.transaction import Transaction
|
||||||
from trytond.modules.currency.fields import Monetary
|
from trytond.modules.currency.fields import Monetary
|
||||||
|
from trytond.pyson import Eval
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@ -23,6 +24,7 @@ class Sale(metaclass=PoolMeta):
|
|||||||
"Total Tip", digits='currency', currency='currency'),
|
"Total Tip", digits='currency', currency='currency'),
|
||||||
'get_amount')
|
'get_amount')
|
||||||
total_tip_cache = fields.Numeric("Total Tip cache", digits="currency")
|
total_tip_cache = fields.Numeric("Total Tip cache", digits="currency")
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __setup__(cls):
|
def __setup__(cls):
|
||||||
@ -340,7 +342,19 @@ class Line(metaclass=PoolMeta):
|
|||||||
pizza = fields.Integer("Pizza")
|
pizza = fields.Integer("Pizza")
|
||||||
impreso = fields.Boolean("Impreso")
|
impreso = fields.Boolean("Impreso")
|
||||||
bought_pizza = fields.Boolean("Sold pizza")
|
bought_pizza = fields.Boolean("Sold pizza")
|
||||||
|
rate = fields.Numeric(
|
||||||
|
"Rate", digits=(16, 4),
|
||||||
|
states={
|
||||||
|
'invisible': Eval('type') != 'line',
|
||||||
|
'readonly': Eval('sale_state') != 'draft',
|
||||||
|
},
|
||||||
|
depends=['type', 'sale_state'])
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def default_rate(cls):
|
||||||
|
return 0
|
||||||
|
|
||||||
@fields.depends('product', 'unit', 'sale',
|
@fields.depends('product', 'unit', 'sale',
|
||||||
'_parent_sale.party', '_parent_sale.invoice_party',
|
'_parent_sale.party', '_parent_sale.invoice_party',
|
||||||
'_parent_sale.pizza_number',
|
'_parent_sale.pizza_number',
|
||||||
@ -359,3 +373,8 @@ class Line(metaclass=PoolMeta):
|
|||||||
Production = super(Line, self).get_production()
|
Production = super(Line, self).get_production()
|
||||||
|
|
||||||
return Production
|
return Production
|
||||||
|
|
||||||
|
@fields.depends('discount_rate')
|
||||||
|
def on_change_discount_rate(self):
|
||||||
|
if self.discount_rate:
|
||||||
|
self.rate = self.discount_rate
|
||||||
|
@ -10,4 +10,8 @@
|
|||||||
<label name="bought_pizza"/>
|
<label name="bought_pizza"/>
|
||||||
<field name="bought_pizza"/>
|
<field name="bought_pizza"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
<xpath expr="//field[@name='discount_rate']" position="after">
|
||||||
|
<label name="discount_rate"/>
|
||||||
|
<field name="discount_rate" factor="100"/>
|
||||||
|
</xpath>
|
||||||
</data>
|
</data>
|
||||||
|
Loading…
Reference in New Issue
Block a user