Community mailing list archives

Re: 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 Odoo 8

Mustafa Babiker El-Siddig Mustafa Hamad
- 12/28/2015 15:10:16


Well you can try debugging by printing values of fields (using python print statement) and then trying to relate those to behavior expected from domain filter.


Mustafa Babiker El-Siddid Mustafa Hamad

On Dec 28, 2015 10:48 PM, "Patricia Soria" <> wrote:

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),('', '=', '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…!

Post to: