line: funktion für 'balance' + test
reconciliation: rec_name + test
This commit is contained in:
parent
f86db6dea3
commit
fd36a3f4ce
6 changed files with 206 additions and 3 deletions
|
@ -4,9 +4,10 @@
|
|||
# full copyright notices and license terms.
|
||||
|
||||
|
||||
from trytond.pool import PoolMeta
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.model import fields
|
||||
from trytond.pyson import Eval
|
||||
from trytond.report import Report
|
||||
from decimal import Decimal
|
||||
|
||||
|
||||
|
@ -31,6 +32,20 @@ class Reconciliation(metaclass=PoolMeta):
|
|||
readonly=True, model_name='product.uom'),
|
||||
'on_change_with_quantity_uom')
|
||||
|
||||
def get_rec_name(self, name):
|
||||
""" add quantities - if its a asset-cashbook
|
||||
"""
|
||||
recname = super(Reconciliation, self).get_rec_name(name)
|
||||
if self.cashbook.feature == 'asset':
|
||||
recname += ' | %(start_quantity)s %(uom_symbol)s - %(end_quantity)s %(uom_symbol)s' % {
|
||||
'start_quantity': Report.format_number(self.start_quantity or 0.0, None,
|
||||
digits=self.quantity_digits),
|
||||
'end_quantity': Report.format_number(self.end_quantity or 0.0, None,
|
||||
digits=self.quantity_digits),
|
||||
'uom_symbol': self.quantity_uom.symbol,
|
||||
}
|
||||
return recname
|
||||
|
||||
@fields.depends('cashbook', '_parent_cashbook.quantity_uom')
|
||||
def on_change_with_quantity_uom(self, name=None):
|
||||
""" get quantity-unit of asset
|
||||
|
@ -71,7 +86,11 @@ class Reconciliation(metaclass=PoolMeta):
|
|||
def get_values_wfcheck(cls, reconciliation):
|
||||
""" get values for 'to_write' in wf-check
|
||||
"""
|
||||
Line = Pool().get('cashbook.line')
|
||||
|
||||
values = super(Reconciliation, cls).get_values_wfcheck(reconciliation)
|
||||
if reconciliation.cashbook.feature != 'asset':
|
||||
return values
|
||||
|
||||
if reconciliation.predecessor:
|
||||
values['start_quantity'] = reconciliation.predecessor.end_quantity
|
||||
|
@ -84,9 +103,10 @@ class Reconciliation(metaclass=PoolMeta):
|
|||
if len(values['lines']) != 1:
|
||||
raise ValueError('invalid number of values')
|
||||
|
||||
lines_records = Line.browse(values['lines'][0][1])
|
||||
values['end_quantity'] += sum([
|
||||
x.quantity_credit - x.quantity_debit
|
||||
for x in values['lines'][0][1]
|
||||
for x in lines_records
|
||||
])
|
||||
|
||||
# add quantities of already linked lines
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue