Odoo Help

Welcome!

This community 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.

0

Trying to get manufacturer,(partner name) getting TypeError: string indices must be integers

By
Christian Parent
on 4/23/14, 3:16 PM 844 views

I have managed to get the manufacturer product code into purchase order line, now, I would like to add the manufacturer name which is a many2one field. I have tried :

'manufacturer' : fields.related('manufacturer_pref','manufacturer',type="many2one", relation="res.partner", string="Manufacturer",store=True),

but I am getting TypeError: string indices must be integers.

anyone can point me out in the right direction ?

Have you define manufacturer_pref field in this object ?

Jagdish Panchal
on 4/24/14, 2:10 AM

Yes, on the line just above:

'manufacturer_pref': fields.related('product_id', 'manufacturer_pref', type="char", relation="product.product", string="Manufacturer", store=True),
Christian Parent
on 4/24/14, 2:14 AM

Hi tyr this 'manufacturer' : fields.related('manufacturer_pref','manufacturer',type="char", string="Manufacturer",store=True),

Jagdish Panchal
on 4/24/14, 2:20 AM

wait, I have deleted the column manufacturer from db, Created a new line, no errors but no data for manufacturer, will tell you more in a sec as I just have restarted !

Christian Parent
on 4/24/14, 2:32 AM

value of manufacturer_pref this field come in to manufacturer ? if there is value in manufacturer_pref then manufacturer field have value.

Jagdish Panchal
on 4/24/14, 2:45 AM

No finaly, still getting TypeError: string indices must be integers

Christian Parent
on 4/24/14, 2:50 AM

both manufacturer_pref and manufacturer are from product.product table, only thing is that manufacter is the id number from res_partner table.

Christian Parent
on 4/24/14, 3:02 AM

Then define many2one with res_partner

Jagdish Panchal
on 4/24/14, 3:04 AM

I have tried it, did not work, may be I defined it wrong, will give it another try. If I put it in words, it would be:

I have an order line which has 1 product. I get the manufacturer_pref of that object from product.product table I need the name of the manufacturer of the manufacturer_pref from the table res.partner.

So the product 1482010000 (id 25781 in product_product) has a manufacturer "id 1654". In res.partner, id 1654 "Name" field is Micro Commercial Component <---- This is what I want to get in my field manufacturer in purchase.order.line.

Is that making more sense ?

Christian Parent
on 4/24/14, 3:21 AM

'partner_id' : fields.many2one('res.partner', 'Partner',),

'manufacturer' : fields.related('partner_id','manufacturer' ,type="char", relation="res.partner", string="Manufacturer",store=True),

Jagdish Panchal
on 4/24/14, 3:25 AM

Already had an object partner_id in that object that was causing a conflict, I have modified your lines to avoid conflicts.

        'manufacturer_id': fields.many2one('res.partner', 'ManufacturerID',),
    'manufacturer' : fields.related('manufacturer_id','manufacturer' ,type="char", relation="res.partner", string="Manufacturer",store=True),

I dont get errors anymore but, the manufacturer name still not showing up. when looking in the table with pgadmin3, the line gets value for every fields except manufacturer_id and manufacturer.

Christian Parent
on 4/24/14, 3:43 AM

Thing I dont get in your code, since I am only typing the default_code (from product_product table), and it has to gather the rest, where do you make the link between my product on that line, it's manufacturer(id) in product.product and the name in res.partner.

to be clear in my question, to get the manufacturer_pref, I had to tell him to use the product_id and get it's manufacturer_pref in product.product.

'manufacturer_pref': fields.related('product_id', 'manufacturer_pref', type="char",  relation="product.product", string="Manufacturer", store=True),

(follow)

Christian Parent
on 4/24/14, 3:53 AM

So, to get my manufacturer, I would need to use the product_id, get the manufacturer field in product.product (which has the id of the partner) and link id the the field name in res_partner table ?

Christian Parent
on 4/24/14, 3:55 AM

'manufacturer' : fields.related('manufacturer_id','manufacturer' ,type="char", string="Manufacturer",store=True),

Jagdish Panchal
on 4/24/14, 3:56 AM

Same behavior, but, should the manufacturer_id be the one from product_product table something in the line of

'manufacturer_id': fields.related('product_id', 'manufacturer', type="char",  relation="product.product", string="Manufacturer", store=True),

which would give the manufacturer id for that product then, we could link it to res.partner name field ?

Christian Parent
on 4/24/14, 4:21 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 4/23/14, 3:16 PM
Seen: 844 times
Last updated: 3/16/15, 8:10 AM