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

Hi,

I'm using odoo 10, I have added the many2one field "task_id" to the model sale.order

python file :

class SaleOrder(models.Model):

_inherit = "sale.order"

task_id = fields.Many2one('project.task', 'Task name')

class ProjectTask (models.Model):

_inherit = "project.task"

order_lines = fields.One2many('task.order.line','task_id',string="Products")


class TaskOrderLine(models.Model):

_name = 'task.order.line'

task_id = fields.Many2one('project.task')

product_id = fields.Many2one('product.product', string='Products')

I want to apply domain to the many2one field " product_id" in the sale.order to display only products that belongs to the selected "task_id" 

in xml file i used : 

 <xpath expr="//form/sheet/notebook/page/field/tree/field[@name='product_id']" position="attributes">

<attribute name="domain">[('task_id', 'in', task_id)]</attribute>

  </xpath>

it shows me error , any suggestions on how to apply correctly the domain in order to filter the products shown in the sale.order depending on the selected "task_id" ?

Avatar
Discard

Is there any relation of Project / Task in the Product.

Author

yes like this :

class ProjectTask (models.Model):

_inherit = "project.task"

order_lines = fields.One2many('task.order.line','task_id',string="Products")

class TaskOrderLine(models.Model):

_name = 'task.order.line'

product_id = fields.Many2one('product.product', string='Products')

Best Answer

Try this : [('task_id', '=', task_id)]

Avatar
Discard
Best Answer

 <field name = "sale_refund_ids" attrs = "{'invisible': [('inv_typ', '=', 'out_invoice')]}" domain = "[('inv_typ', '=', 'out_invoice')] "/>

</ field>

Try similar to the above code, Hope it will work

Avatar
Discard