asset: einheit als währung/menge
This commit is contained in:
parent
c8c2afb190
commit
de99f0e473
5 changed files with 30 additions and 2 deletions
20
asset.py
20
asset.py
|
@ -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
|
||||
|
|
|
@ -138,6 +138,10 @@ msgctxt "field:investment.asset,uom:"
|
|||
msgid "UOM"
|
||||
msgstr "Einheit"
|
||||
|
||||
msgctxt "field:investment.asset,uom_symbol:"
|
||||
msgid "UOM"
|
||||
msgstr "Einheit"
|
||||
|
||||
msgctxt "field:investment.asset,wkn:"
|
||||
msgid "NSIN"
|
||||
msgstr "WKN"
|
||||
|
|
|
@ -110,6 +110,10 @@ msgctxt "field:investment.asset,uom:"
|
|||
msgid "UOM"
|
||||
msgstr "UOM"
|
||||
|
||||
msgctxt "field:investment.asset,uom_symbol:"
|
||||
msgid "UOM"
|
||||
msgstr "UOM"
|
||||
|
||||
msgctxt "field:investment.asset,wkn:"
|
||||
msgid "NSIN"
|
||||
msgstr "NSIN"
|
||||
|
|
|
@ -83,6 +83,7 @@ class AssetTestCase(ModuleTestCase):
|
|||
asset = self.prep_asset_item(
|
||||
company=company,
|
||||
product = product)
|
||||
self.assertEqual(asset.uom_symbol, 'usd/u')
|
||||
|
||||
@with_transaction()
|
||||
def test_asset_rec_name(self):
|
||||
|
|
|
@ -12,6 +12,5 @@ full copyright notices and license terms. -->
|
|||
<field name="change_month6" />
|
||||
<field name="date" expand="1"/>
|
||||
<field name="rate" expand="1"/>
|
||||
<field name="currency"/>
|
||||
<field name="uom" />
|
||||
<field name="uom_symbol"/>
|
||||
</tree>
|
||||
|
|
Loading…
Reference in a new issue