Odoo Help

0

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

By
Christian Parent
on 4/28/14, 12:22 PM 1,828 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--

3378
| 5 5 7
Bikaner, India
--Prakash--

OpenERP Developer 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 (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
11584
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
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 ?

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.

Register

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

0 follower(s)

Stats

Asked: 4/28/14, 12:22 PM
Seen: 1828 times
Last updated: 3/16/15, 8:10 AM