Odoo Help

Welcome!

This community 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.

0

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

By
Patricia
on 12/28/15, 2:52 PM 384 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>

</xpath>


But it doesn’t work…


Also tried this in the .py:


class sale_order_line(osv.osv):

_inherit="sale.order.line"

_name="sale.order.line"

_columns={

'origen':fields.related('order_id','origen','id',type="integer"

,string="Origen"),

'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


Patricia
on 12/29/15, 2:02 PM
0

Axel Mendoza

--Axel Mendoza--
10228
| 7 7 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 an 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

Or

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

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/28/15, 2:52 PM
Seen: 384 times
Last updated: 12/29/15, 2:02 PM