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

Still looking to connect the dots (Related field) need help !

By
Christian Parent
on 4/28/14, 12:22 PM 1,366 views

I am trying to get the purchase form to show my product manufacturer. I did managed to get the manufacturer code to show with :

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

I am also trying to get the manufacturer related to this manufacturer_pref.

both fields are in the product.product table, (manufacturer and manufacturer_pref). Only thing that looks to be tricky, is that manufacturer is a mny2one field taken from res.partner :

'manufacturer' : fields.many2one('res.partner', 'Manufacturer'),

I have tried many ways but still, I cannot get the "Name" of the partner to show up. I do have the integer(id) related to the partner table in the product.product table under manufacturer field. But, I cannot get it to show and or being added in the purchase.order.line tableor form/report.

Can anyone help me dig it?

1

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 5/6/14, 7:20 PM

just modify your comment typed code type='char' into type='many2one' Example, 'manufacturer':fields.related('product_id', 'manufacturer', type='many2one', relation='product.product', string='manufacturer', store=True); same as sudhir arya but change relation res.partner into product.product.

hi, the problem u had is caused by "relation", the field u created on product_product is many2one and the object is res.partner. So on field related in purchase.order.line, u need to link it to res.partner instead of product.product

please try this code : 'manufacturer_pref': fields.related('product_id', 'manufacturer', type="many2one", relation="res.partner", string="Manufacturer Code", store=True),

Stone
on 5/6/14, 11:09 PM

Yes. finaly, Maybe we had tried this earlier but I had a typos in, fields.related('product_id', 'manufacturer', type="many2one", relation="res.partner", string="Manufacturier", store=True),

Christian Parent
on 5/7/14, 11:27 AM
1

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 4/28/14, 1:25 PM

Hello Christian Parent,

You just have to add another related field to get manufacturer.

Here it is:

fields.related('product_id', 'manufacturer', relation='res.partner', type='many2one', string='Manufacturer')

You can get more information about related and other fields: OpenERP Fields

Hope this will help you.

I am receiving File "/opt/openerp/server/openerp/osv/fields.py", line 1285, in _fnct_read value = value[field] or False File "/opt/openerp/server/openerp/osv/orm.py", line 387, in __getitem__ raise KeyError(error_msg) KeyError: "Field 'manufacturer' does not exist in object 'browse_record(purchase.order, 8)'"

When creating a new record. I will try to use existing records and add manufacturer to my view see if it at least links.

Christian Parent
on 4/30/14, 1:29 PM

I have modified the line a couple time... I am at 'manufacturer': fields.related('product_id', 'manufacturer', type="char", relation="product.product", string="Manufacturier", store=True), this at least gives me something in the DB : browse_record(res.partner, 1654) 1654 is the right manufacturer, so getting close but just not there yet !!!

Christian Parent
on 5/6/14, 4:48 PM
0
Christian Parent
On 5/6/14, 2:04 PM

I dont know if it is the way we are doing it but, it does not seem to work. The manufacturer of the product already exist in the product.product table, it is his id number from res.partner. The things tried so far does not work, see my comment above.

Remember, I want to add the field manufacturer to purchase.order.line table. The line in this table consist of each individual product ordered in an invoice.

I have managed to add the manufacturer reference code thru :

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

So, I use the product_id from purchase_order_line which is the primary key (ID) in the table product.product. with that, I can get the manufacturer_pref which is already in the product.product table.

When I try to do similar to this for manufacturer name (manufacturer) It gives me errors.

I have all the logic :

Product_id in purchase_order_line is related to id in product.product. Each product in product.product has a field manufacturer which contains the id (Primary Key) of the res.partner table.

What I need to get in purchase_order_line is the field "name" from res.partner .... Is this more clear ?

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/28/14, 12:22 PM
Seen: 1366 times
Last updated: 3/16/15, 8:10 AM