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.
I am French, I hope you understand :)
I'm trying to develop a module that creates a relationship between products. A product can be linked to several other products: they are identical but are occasions.
So there is a one2many relation (child_ids, one product for several occasions) and another many2one relation (parent_id, many opportunities for one parent). This is equivalent to reproduce the same relation between a partner (res.partner) and contacts (res.partner too).
When a user creates a sale order line (sale.order.line) in an order (sale.order), he must select the a product. If the selected product has occasion product(s), so I want to warn and allow him to select one.
It is necessary to overload the product_id_change() method (onchange on the product_id field defined on parent class) and search for existing attached product(s) (occasions).
I must to display the list of attached product and allow user to replace the product in the sale order line.
- Should I force a new search (like "search more ..." link) from the product_id_change() function?
- Should I use a wizard (osv.memory) to open the popup and show him the available opportunities?
- If so, how can I update the parent form (sale.order.line) to change the value of product_id field?
- If not, are there any other way to achieve this?
Thank you for your help.
you can add another field
'product_child_id': fields.many2one('product.product', 'Product Child',),
add the field in view sale.order . if user selected a product it load the list product_child_id of the product.
must be redefined product_id_change() function to load product_child_ids for this product .something like that:
class my_class(osv.osv): _inherit = 'sale.order.line' def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None): res = super(my_class, self).product_id_change(cr, uid, ids, pricelist, product, qty=0,uom=False, qty_uos=0, uos=False, name='', partner_id=False,lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None) product_pool = self.pool.get('product.product') product_browse= product_pool.browse(cr, uid, product) res['value']['product_child_id'] = product_browse.product_child_ids return res my_class()
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: 5/5/13, 3:43 PM|
|Seen: 3559 times|
|Last updated: 3/16/15, 8:10 AM|