line/book: add quantity/uom to rec_name

This commit is contained in:
Frederik Jaeckel 2023-01-15 12:15:54 +01:00
parent 4ef14cd44b
commit 90fbfa3fde
3 changed files with 76 additions and 34 deletions

13
line.py
View file

@ -9,6 +9,7 @@ from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval, Or, If
from trytond.exceptions import UserError
from trytond.i18n import gettext
from trytond.report import Report
from trytond.modules.cashbook.line import STATES, DEPENDS
from .mixin import SecondUomMixin
@ -65,6 +66,18 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
}, depends=['quantity_digits', 'feature']),
'on_change_with_quantity_balance')
def get_rec_name(self, name):
""" add quantities - if its a asset-cashbook
"""
recname = super(Line, self).get_rec_name(name)
if self.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
@classmethod
def get_debit_credit(cls, values, line=None):
""" compute quantity_debit/quantity_credit from quantity