Skip to Content
Menú
This question has been flagged
2 Respostes
6766 Vistes

Hi ,

     I need to access the relational table created by many to many field, is it possible to access the table?

Thanks in advance......

Avatar
Descartar

What is your exact aim? Whenever you call that field you will get the appropriate values, like the other fields.

Autor

I want that relational id values, i cant able to get it through search method

Do you mean the id field of that relational table? Why do you need that? As soon as you will call that many2many field there will be browse record of the field against which you have created the relation.

Autor

I need it for my module customization, which link the customer and product category

Sorry, but I don't think that you need to know the "ID"(actual ID field) field of that relational table. You can have customer and product as many2many, what is the need? Lets say you got the ID, how and where do you use that ID field. If possible post your code here.

Autor

I am just customizing the sale module , i just link the customer with certain product category, so that in the sale order if i entered the name of the customer , i need only the certain category that i had linked with that pacticular customer, model_inherit.py from openerp import models, fields class res_partner(models.Model): _inherit='res.partner' products=fields.Many2many('product.category','cust_produ_rel','cust_id','prod_id','Products') inherit_view.xml cust_prod_inherit res.partner <xpath expr="//notebook[@colspan=4]" position="attributes"> 5 <xpath expr="//notebook/page[@name='sales_purchases']" position="after">

So yes, as soon as you will do "partner_id.products", (products is your field name) it will give you the browse records of only all those categories which are linked to that particular customer. Try this.

Autor

I cant get it , please

Autor

Using that sale.order, i am get the product category but i need match between the customer and the product category , so that i can use it

That is what I am saying once you will have the browse record of 'sale.order', you can get the product categories of customers as 'br_sale_order.partner_id.products'. Where do you want to match? With what you want to match it? You will only those product categories which are there in that particular customer not more than that.

Best Answer

When ever you will browse the sale.order model, you can use like this let's say your browse record is "br_sale_order", than you can use "br_sale_order.partner_id.products", which will give you the browse records of "product.category" model and you can iterate the loop on it.
 

Avatar
Descartar
Autor Best Answer

I need some clarification regarding this relational table. Y cant i able to access the table...........

Thanks in advance

Avatar
Descartar