Odoo Help


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.


How to dynamically update domain filter on selection widget?

Iain Duncan
on 1/16/14, 5:13 PM 1,578 views

Hi, I'm not sure if what I'm doing is possible. I have extended the product type to include a relationship to optional prices, we're calling them BundlePriceOptions. The price options each have an fkey to product, so each product has a range of possible price options. I'm trying to alter the sale form so that on the sale order line, if one chooses a product, there is a pulldown with the list of possible price options, and that list should only contain options pertinent to the product currently selected. I thought I could do something like this:

<record id="view_order_form" model="ir.ui.view">
      <field name="name">sale.order.form</field>
      <field name="model">sale.order</field>
      <field name="priority">1</field>
      <field name="inherit_id" ref="sale.view_order_form"/>
      <field name="arch" type="xml">
          <field name="user_id" position="after">
          <tree string="Sales Order Lines" position="inside">
               string="Pricing Options"  
               domain="[ ('product_id', '=', product_id) ]" 
               on_change="price_option_change(bundle_price_option, context)"

But when I do this, I can't out what should go in the right hand side of the domain filter tuple. I'd like it to evaluate dynamically to the id of the currently selected product on the sale order line. It works if I put a static value in there (like an int of a product id), but whatever I put in there seems to give me a traceback of being undefined. If anyone can tell me what I should try or if I'm event approaching this correctly that would be great.

Thanks Iain


Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
| 5 3 5
--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 10/26/15, 6:21 AM


Try to remove the widget="selection" in the field tag ...

Also another option you can override the function product_id_change in the sale_order_line

to add 'domain' to your custom field ...

I hope it'll help,


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

0 follower(s)


Asked: 1/16/14, 5:13 PM
Seen: 1578 times
Last updated: 10/26/15, 6:21 AM