Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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?
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 10/1/13, 1:46 PM|
|Seen: 861 times|
|Last updated: 3/16/15, 8:10 AM|