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.
dynamically add new fields to a osv model depending on the number of records of another osv model in openerp?
How to dynamically add new fields to a osv model depending on the number of records of another osv model in openerp? For example I have a model which is for planning purchases. I need to show total order qty that came in each shop.so i need to add new field each time a new record in sale.shop is created.
__init__ function of your class to dynamically add the sales shop to
class planning(osv.osv): def __init__(self, pool, cr): shop_ids = pool.get('sale.shop').search(cr,SUPERUSER_ID,) for shop in pool.get('sale.shop').browse(cr, SUPERUSER_ID,shop_ids): self._columns['shop_qty_%s'%shop.id] = fields.float( '%s Order Qty'%shop.name) return super(planning,self).__init__(pool, cr)
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/29/13, 10:59 AM|
|Seen: 2031 times|
|Last updated: 3/16/15, 8:10 AM|