asset: einheit als währung/menge

This commit is contained in:
Frederik Jaeckel 2022-12-01 16:30:50 +01:00
parent c8c2afb190
commit de99f0e473
5 changed files with 30 additions and 2 deletions

View file

@ -46,6 +46,8 @@ class Asset(ModelSQL, ModelView):
domain=[
('category', '=', Eval('product_uom')),
], depends=['product_uom', 'product'])
uom_symbol = fields.Function(fields.Char(string='UOM', readonly=True),
'on_change_with_uom_symbol', searcher='search_uom_symbol')
rates = fields.One2Many(string='Rates', field='asset',
model_name='investment.rate')
rate = fields.Function(fields.Numeric(string='Current Rate',
@ -259,6 +261,24 @@ class Asset(ModelSQL, ModelView):
if self.company.currency.id != self.currency.id:
return self.company.currency.id
@fields.depends('uom', 'currency')
def on_change_with_uom_symbol(self, name=None):
""" get symbl of uom
"""
return '%(currency)s/%(unit)s' % {
'currency': self.currency.symbol if self.currency is not None else '-',
'unit': self.uom.symbol if self.uom is not None else '-',
}
@classmethod
def search_uom_symbol(cls, names, clause):
""" search in uom
"""
return ['OR',
(('uom.rec_name',) + tuple(clause[1:])),
(('currency.rec_name',) + tuple(clause[1:])),
]
@classmethod
def get_rate_data_sql(cls):
""" get sql for rate/date