Odoo Help


show existing products of a customer in a tab

on 2/22/16, 3:28 AM 798 views

I am new in python, I've added a drop-down field so I can select a customer and seen his/her existing products in a tab.
but I cant show the list of existing products of a customer, how can I do it, can anyone help me please.


Akhil P Sivan

--Akhil P Sivan--

| 5 4 7
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

Akhil P Sivan
On 2/22/16, 7:18 AM


One option is to create a One2many compute field on res.partner model and call that on a tab in customer form view. So when you open the customer form, under a "Products" tab, you may see the existing products of the customer. You may check the tutorial on how to create a One2many compute or functional field. Or else you may contact me on akhilpsivan01@gmail.com for further help.

For example, you may try by adding the following code:

in your .py file:

class project_task(models.Model):

_inherit = "project.task"

customer = fields.Many2one('res.partner', string="Search Customer Name")

products = fields.One2many('product.template', compute='_get_products', string="Products")




def _get_products(self):

if self.customer:

product_list = self.env['product.supplierinfo'].search([('name.id','=',self.customer.id)])

if product_list:

p_list = []

for supp in product_list:


prod = self.env['product.template'].browse(p_list)

self.products = prod

in your xml file:

<record id="view_task_form2_inherited" model="ir.ui.view">

<field name="name">project.task.form.inherited</field>

<field name="model">project.task</field>

<field name="inherit_id" ref="project.view_task_form2"/>

<field name="arch" type="xml">

<field name="reviewer_id" position="after">

<field name="customer" />


<notebook position="inside">

<page string="Products">

<field name="products" />





thank you Akhil for the code, but by this, I get product list of supplier but I need customers products, i.e when I select customer 'A' then his bought products will show in a tab.

on 3/3/16, 2:37 AM

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.


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

1 follower(s)


Asked: 2/22/16, 3:28 AM
Seen: 798 times
Last updated: 3/5/16, 1:37 PM