Hi, I want to add a field to the account.asset.category form which calculates the sum of purchased amount of all assets related to every category. For Exemple: Category 1: Cars The first purchase order amount for Ford Mustung=50000$ The second purchase order amount for Mercedes Benz=70000$ I want to add a field called "Total purchase amount" in the asset category form which calculates the sum. for this exemple it should be "120000$" In order to do it i created this function called def _get_1st_ul (i did a test query for categ 1)
class account_asset_category(osv.osv): _name = 'account.asset.category' _description = 'Asset category' def _get_1st_ul(self, cr, uid, ids, id, args, context=None):
return cr.execute("""SELECT SUM (purchase_value) AS amount
FROM account_asset_asset l
WHERE l.category_id ='1'
GROUP BY l.category_id""")
and then i added the column:
'Sum_Purchase': fields.function(_get_1st_ul, method=True, type='integer', string='Total purchase amount', store=False ),
Unfortunally it returns error: AttributeError: 'NoneType' object has no attribute 'get'
Can someone please help?