İçereği Atla
Menü
Bu soru işaretlendi
5165 Görünümler

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 ?

Avatar
Vazgeç

Have you define manufacturer_pref field in this object ?

Üretici

Yes, on the line just above:

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

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

Üretici

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 !

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

Üretici

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

Üretici

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

Then define many2one with res_partner

Üretici

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 ?

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

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

Üretici

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.

Üretici

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)

Üretici

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 ?

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

Üretici

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 ?

İlgili Gönderiler Cevaplar Görünümler Aktivite
2
May 24
1596
2
Mar 15
5869
0
Ağu 24
1762
1
Mar 23
2417
2
Mar 20
4803