Skip to Content
Menu
This question has been flagged
2 Replies
2375 Views

Hi

I'm very new in python and odoo so I need a help.

In project>task module I've added a selection field which for select customer. now I need when I select a customer then his products will show in a tab.

can anyone help me please.

Avatar
Discard

I check it but I don't understand what you need, post some code of what you are doing

Author Best Answer

xml

<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" />

</field>

<notebook position="inside">

<page string="Products">

<field name="products" />

</page>

</notebook>

</field>

</record>


.py file

from openerp import api, fields, models

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:

order_line_list = self.env['sale.order.line'].search([('name.id','=',self.order_partner_id.id)])

if order_line_list:

ol_list = []

for partner in order_line_list:

ol_list.append(supp.product_tmpl_id.id)

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

                self.products = prod


I want: From selection field when a customer will be selected then his bought product will show in a tab below.

Avatar
Discard
Related Posts Replies Views Activity
0
Apr 24
401
4
Nov 23
4250
0
Oct 23
378
0
Dec 22
1334
2
Dec 23
17353