Community mailing list archives

community@mail.odoo.com

Re: Set custom domain when displaying existing record (when onchange is not triggered)

by
Willow IT, Jon Wilson
- 09/16/2015 19:25:06
Thanks guys for great suggestions.

As the code was not entirely in our control (it is on uom on sale.order.line), and standard product_id_change from base Odoo already returns domains, we ended up having to override product_id_change to strip the returned domain out, not set our own domain, and used the functional field as suggested by Pedro.

Jonathan Wilson
ph: +61 3 8506 0393
mob: +61 4 000 17 444
2013 & 2015 Odoo Best Partner Asia/Pacific
Creators of  Odoo-Pentaho integration project





On 16 September 2015 at 18:33, Pedro Manuel Baeza Romero <pedro.baeza@gmail.com> wrote:
A better solution is to have a domain depending on other computed field, and put the logic on the compute method of that field. See an example here:

Domain definition: https://github.com/odoomrp/odoomrp-wip/blob/8.0/sale_product_variants/models/sale_order.py#L51
Compute method: https://github.com/odoomrp/odoomrp-wip/blob/8.0/sale_product_variants/models/sale_order.py#L38

Regards.

2015-09-16 10:11 GMT+02:00 Graeme Gellatly <gdgellatly@gmail.com>:

If it is just a domain for search / constraints all I do is set a fake xml domain like (field, =, sol_o2m) .

Then use an override of search to test for it and transform it to the actual domain I want. 

It isn't exactly your use case but the concept will work. 

Sent from TypeMail

On 16 Sep 2015, at 6:07 PM, Jonathan Wilson <jon@willowit.com.au> wrote:
Hi Community

We have a need for a fairly complex domain on a many2one on sales order lines on the form view that pops up from sales order header.

While it can be easily calculated in one browse and lookup, it cannot be expressed in the xml. (The domain, in some cases, simply ends up being [('id', 'in', (x, y))]

This is triggered by onchanges and works well for new data, or when data changes.

However, when opening an existing line, the onchanges are not triggered.

Since the domain should be set for an existing record and there is no way to code it in to the default domain, is there a way we could cause the display of an existing record to trigger an onchange?  Even if I define a new invisible column on the view, I can not think of any way to get a new record to put a value in there to cause an onchange!

Thanks in advance.

Jonathan Wilson
mob: +61 4 000 17 444
2013 & 2015 Odoo Best Partner Asia/Pacific
Creators of  Odoo-Pentaho integration project




_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe


_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe