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
book.py
View file

@ -8,6 +8,7 @@ from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval, Or, Len, Bool, If
from trytond.modules.cashbook.book import STATES2, DEPENDS2
from trytond.transaction import Transaction
from trytond.report import Report
from decimal import Decimal
from sql.functions import CurrentDate
from sql.aggregate import Sum
@ -125,6 +126,18 @@ class Book(SymbolMixin, metaclass=PoolMeta):
),
]
def get_rec_name(self, name):
""" add quantities - if its a asset-cashbook
"""
recname = super(Book, self).get_rec_name(name)
if self.feature == 'asset':
recname += ' | %(quantity)s %(uom_symbol)s' % {
'quantity': Report.format_number(self.quantity or 0.0, None,
digits=self.quantity_digits),
'uom_symbol': getattr(self.quantity_uom, 'symbol', '-'),
}
return recname
@fields.depends('asset', 'quantity_uom')
def on_change_asset(self):
""" get uom from asset