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?
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 10/1/13, 1:46 PM|
|Seen: 574 times|
|Last updated: 3/16/15, 8:10 AM|