Odoo Help


2 Risposte
Ramya Kalaiselvan India
16/02/18, 01:05

I have done the same requirement in my project. I restricted duplication of product addition at o2m in sales form. (v7)


 def onchange_one2many(self, cr, uid, ids, order_line):

mylist = []

if order_line != []:

    for line in order_line:

        for loop in line:

            if isinstance(loop, dict):


if len(mylist) != len(set(mylist)):

    raise osv.except_osv(_('Warning'),_('Product Should be Unique'))

return True


<field name="order_line" on_change="onchange_one2many(order_line)" />

Thanks Rifakat Haradwala

Note: Correct me if anyone has better answer



Well you need specific development for that. It's not something you could configure.

You need to override write() of the main model and in write() you can iterate on the IDs of o2m field and put a check on the Product if it repeats and raise warning. Write() will be called when you save main form, so you won't be notified while you actually inserting line items. I am not sure onchange of o2m field would help because ID of newly inserted line item is not yet created while you add it, but you can give it onchange(o2m) also try.


Fai una domanda
Keep Informed
2 follower(s)
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.

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now