Odoo Help


How can I filter products in a sales orders line using a value linked to a variant attribute value of a product? I'm using odoo8

on 12/28/15, 2:52 PM 659 views

hi!!! I have added the “origen” attribute to the sale_order class, as I mentioned above this field is linked using a many2one relation to a product attribute value.

This is the class definition:

class sale_order(osv.osv):

_name = "sale.order"

_inherit = 'sale.order'

_columns = {

'fecha_entrega_cliente': fields.datetime('Entrega Solicitada'),

'turno_id': fields.many2one('calendar.event','Turno'),

'obra_id': fields.many2one('sale.obra','Obra', domain="[('name','=',partner_id)]"),

'ubicacion': fields.char('Ubicacion'),

'zona': fields.many2one('sale.zona' ,string='Zona'),

'origen': fields.many2one('product.attribute.value' ,string='Origen'),


I want to filter the products shown in a sales order line using the 'origen' attribute . I tried using .xml:

<xpath expr="//tree[@string='Sales Order Lines']/field[@name='product_id']" position="attributes">

<attribute name="domain">[('attribute_line_ids', '=', origen)]</attribute>


But it doesn’t work…

Also tried this in the .py:

class sale_order_line(osv.osv):






'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True),('product_variant_ids.attribute_value_ids.attribute_id.id', '=', 'origen')], change_default=True, readonly=True, states={'draft': [('readonly', False)]}, ondelete='restrict'),

But it doesn’t show any product.

I would be really grateful if somebody can help me…!

 I am not getting. will you elaborate more using one example?

Krupesh Laiya
on 12/29/15, 12:50 AM
Hi guys!!  many thanks for replying. The attribute_line_ids is defined in product.template and the view is in the Variants tab

2015-12-29 7:10 GMT-03:00 Axel Mendoza <portaltemplate12973@mail.odoo.com>:

A new answer for How can I filter products in a sales orders line using a value linked to a variant attribute value of a product? I'm using odoo8 has been posted. Click here to access the post.

Axel Mendoza

on 12/29/15, 2:02 PM

Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 12/29/15, 5:10 AM

The thing is that you defined the origen field as a related field.

Related fields only get a value when you save the sale.order.line that will be saved when the sale.order object is saved. So you need to provide a default value for the origen field and change it if necessary using onchange


You could use the sale.order origen field directly in the domain like

<attribute name="domain">[('attribute_line_ids', '=', parent.origen)]</attribute>

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: 12/28/15, 2:52 PM
Seen: 659 times
Last updated: 12/29/15, 2:02 PM