Odoo Help


How to delete the supplier info from a tree list of products?V8

michel Guénard
on 2/22/16, 10:27 AM 821 views

I need to create a server action in order to delete every supplier info that are linked to my products.

I tried the following code; which does not work(I am not a developper)

I understand that the link between product and supplier info is a one2many

I would appreciate any help because I have hundreds of products with obsolete or inaccurate supplier info due to mergers of various suppliers.

context = context or {}

for record in self.browse(cr, uid, context.get('active_ids', []), context=context):

value = ""

    for val in [product.supplierinfo]:

        if val:

            value += ""
pool.get('product.template').delete(cr, uid, record.id, {product.supplierinfo: value[:-1]}, context=context)

Jusab Sida (jsi)

--Jusab Sida (jsi)--
| 2 2 5
Gandhinagar, India
--Jusab Sida (jsi)--

Jusab Sida (jsi)
On 2/22/16, 12:37 PM

You can use this code in your action....

if context and context['active_ids']:

    pid = self.pool('product.supplierinfo').search(cr, uid, [('product_tmpl_id','in',context['active_ids'])])

    self.pool('product.supplierinfo').unlink(cr, uid, pid)

Thks Jusab; however the result is ValueError: "name 'active_ids' is not defined" while evaluating Any idea to solve this error?

AD LIBITOM, michel Guénard
on 2/22/16, 1:04 PM

can you try again??? i have updated my answer

Jusab Sida (jsi)
on 2/23/16, 12:10 AM

Have you pass active_ids in context?

Jusab Sida (jsi)
on 2/23/16, 12:14 AM

Hello Jusab Just works as expected; This server action removes the links to suppliers from the product form. (tested with 2 suppliers info) Many thanks

AD LIBITOM, michel Guénard
on 2/23/16, 3:38 AM

Enjoy!!!!!!!!! :)

Jusab Sida (jsi)
on 2/23/16, 4:02 AM



| 4 4 6
Hyderabad, India

On 2/23/16, 1:10 AM


for record in self.browse(cr, uid, context.get('active_ids', []), context=context):
 #self is product.template object & active_ids are the records selected from tree view...    
    supp_to_remove = []    
    for supp in record.supplierinfo:        
        supp_to_remove.append((3, supp.id))    

Hope this helps!

Thanks Pavan for the code; Igot the error: ValueError: "'product.template' object has no attribute 'supplierinfo'" while evaluating The server action I created is using the product template model.

AD LIBITOM, michel Guénard
on 2/23/16, 3:32 AM

you can use "record.seller_ids" inspite of 'record.supplierinfo',
and at end

on 2/23/16, 8:24 AM

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

Question tools

1 follower(s)


Asked: 2/22/16, 10:27 AM
Seen: 821 times
Last updated: 2/23/16, 3:41 AM