Community mailing list archives

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

- 12/28/2015 14:44:04

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…!