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 to return a domain on field on onchange action ?

By
Yug Faa
on 4/29/13, 10:08 AM 9,142 views

Hello everybody,

I try to get a domain (context maybe) on field when I change a value of an other field.

My case :

I have two fields :

  1. partner_id : m2o (res.partner) type
  2. type : selection(sale or purchase)

On a form view, I want when I set type=sale, the domain=[('customer','=',True)] applied to the field partner_id

My idea is to use onchange action on the field type, but I don't know how

A help please

13

Naresh Soni (nch)

--Naresh Soni (nch)--
Tiny ERP Pvt Ltd
http://www.odoo.com
1281
| 2 2 4
India
--Naresh Soni (nch)--

Team Lead, Odoo(Formerly OpenERP) Support & OPW

Naresh Soni (nch)
On 4/29/13, 10:24 AM

Hello Yug Faa,

on_change in OpenERP has 3 possible values returned finally in a dictionary or a {} .

1: The value dictionary i.e {field1:value1,field2:value2}

2: The domain dictionary i.e {field1:domain1}

3: The warning

Syntax:

res = {'value':{},'domain':{},'warning':'Warning Message'}

According to your case add this to the return dictionary.

{'domain':{'partner_id':[('customer','=',True)]}}

Thanks

Thanks !!!

Ankit H Gandhi(AHG)
on 11/26/15, 8:28 AM
1
TheBrush
On 8/1/13, 8:47 AM

'warning' key permits also a dict as value: {'title': 'Caption title of window:', 'message': 'Text of the message'}

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

2 follower(s)

Stats

Asked: 4/29/13, 10:08 AM
Seen: 9142 times
Last updated: 3/16/15, 8:10 AM