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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
3
الردود
6938
أدوات العرض
Use __init__
function of your class to dynamically add the sales shop to _columns
.
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)
This is impossible with the current osv model. And it is bad software design.
Better, add a new model: purchase_shop_quantity and make a one2many relation from your current model to the new one
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
3
مايو 21
|
3269 | ||
|
0
مايو 24
|
1729 | ||
|
0
أكتوبر 24
|
1262 | ||
|
2
سبتمبر 21
|
22563 | ||
|
0
ديسمبر 15
|
6379 |