line: rec_name with quantity, optimize get_counterpart_values(),
splitline: rec_name with quantity, optimize list/form, add tests
This commit is contained in:
parent
a397fe22a2
commit
03c552a29c
6 changed files with 927 additions and 22 deletions
18
splitline.py
18
splitline.py
|
@ -7,6 +7,7 @@
|
|||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.model import fields
|
||||
from trytond.pyson import Eval, Or, And
|
||||
from trytond.report import Report
|
||||
from trytond.modules.cashbook.line import STATES
|
||||
from .mixin import SecondUomMixin
|
||||
from .line import STATESQ1, DEPENDSQ1
|
||||
|
@ -34,13 +35,28 @@ class SplitLine(SecondUomMixin, metaclass=PoolMeta):
|
|||
readonly=True, model_name='product.uom'),
|
||||
'on_change_with_quantity_uom')
|
||||
|
||||
@fields.depends('line', '_parent_line.cashbook')
|
||||
def get_rec_name(self, name):
|
||||
""" add quantities - if its a asset-cashbook
|
||||
"""
|
||||
recname = super(SplitLine, self).get_rec_name(name)
|
||||
if self.line.cashbook.feature == 'asset':
|
||||
recname += '|%(quantity)s %(uom_symbol)s' % {
|
||||
'quantity': Report.format_number(self.quantity or 0.0, None,
|
||||
digits=self.quantity_digits),
|
||||
'uom_symbol': self.quantity_uom.symbol,
|
||||
}
|
||||
return recname
|
||||
|
||||
@fields.depends('line', '_parent_line.cashbook', 'booktransf', '_parent_booktransf.quantity_uom')
|
||||
def on_change_with_quantity_uom(self, name=None):
|
||||
""" get quantity-unit of asset
|
||||
"""
|
||||
if self.line:
|
||||
if self.line.cashbook.quantity_uom:
|
||||
return self.cashbook.quantity_uom.id
|
||||
if self.booktransf:
|
||||
if self.booktransf.quantity_uom:
|
||||
return self.booktransf.quantity_uom.id
|
||||
|
||||
@fields.depends('line', '_parent_line.cashbook')
|
||||
def on_change_with_quantity_digits(self, name=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue