Update on_change and on_change_with field depends | #157053
This commit is contained in:
parent
5bd198b954
commit
89f1303c4c
|
@ -4,6 +4,7 @@
|
|||
from trytond.pool import Pool
|
||||
from . import configuration
|
||||
from . import sale
|
||||
from . import sale_discount
|
||||
|
||||
|
||||
def register():
|
||||
|
@ -13,3 +14,6 @@ def register():
|
|||
sale.Sale,
|
||||
sale.SaleLine,
|
||||
module='sale_margin', type_='model')
|
||||
Pool.register(
|
||||
sale_discount.SaleLine,
|
||||
module='sale_margin', type_='model', depends=['sale_discount'])
|
7
sale.py
7
sale.py
|
@ -98,13 +98,6 @@ class SaleLine(metaclass=PoolMeta):
|
|||
'invisible': ~Eval('type').in_(['line', 'subtotal']),
|
||||
}, depends=['type']), 'on_change_with_margin_percent')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(SaleLine, cls).__setup__()
|
||||
if hasattr(cls, 'gross_unit_price'):
|
||||
cls.margin.on_change_with.add('gross_unit_price')
|
||||
cls.margin_percent.on_change_with.add('gross_unit_price')
|
||||
|
||||
@staticmethod
|
||||
def default_cost_price():
|
||||
return _ZERO
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
from trytond.pool import PoolMeta
|
||||
from trytond.model import fields
|
||||
|
||||
class SaleLine(metaclass=PoolMeta):
|
||||
__name__ = 'sale.line'
|
||||
|
||||
@fields.depends('gross_unit_price')
|
||||
def on_change_with_margin(self, name=None):
|
||||
return super().on_change_with_margin(name)
|
||||
|
||||
@fields.depends('gross_unit_price')
|
||||
def on_change_with_margin_percent(self, name=None):
|
||||
return super().on_change_with_margin_percent(name)
|
|
@ -9,6 +9,6 @@ from trytond.tests.test_tryton import ModuleTestCase
|
|||
class SaleMarginTestCase(CompanyTestMixin, ModuleTestCase):
|
||||
'Test SaleMargin module'
|
||||
module = 'sale_margin'
|
||||
|
||||
extras = ['sale_discount']
|
||||
|
||||
del ModuleTestCase
|
||||
|
|
Loading…
Reference in New Issue