Is there anything like on_change event to set value, domain when pop up a new window?

Asked by Cuong

Hi,

I'd like to know whether there is something like on_change event to set domain, value for fields when opening a window from menu item?

Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
Serpent Consulting Services
Solved:
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) said :
#2

Hello Coung,

You can use default_fieldname to set some values on fields while opening a window from menuitem. Use them in context.

Thanks,
Serpent Consulting Services
http://www.serpentcs.com

Revision history for this message
Cuong (bhcuong2008) said :
#3

Hi,

I'd like dynamic feature. It means that when I open a windows, it will run something like on_change function so that I can calculate dynamic value and domain for fields on the form.

For example, a m2o field, partner_id, I want to take an id that satisfies some conditions to get final result such as partner_id = 3, and domain is limited to VIP customers,....

Setting in the context, domain in action definition is simple, and static values, domains.

Thanks,

Revision history for this message
Serpent Consulting Services (serpent-consulting-services) said :
#4

Cuong,

In that case,fields_view_get() and default_get() will be your answer.

Override them and based on calculations done by you, your window will have its values.

Thanks.

Revision history for this message
Cuong (bhcuong2008) said :
#5

Hi,

I dont know much about default_get. I wonder whether it can set domain for fields or not. Domain is the most important thing because it limits what users see, provides the right things to users.

Thank you very much,

Revision history for this message
Best Serpent Consulting Services (serpent-consulting-services) said :
#6

Cuong,

The fields_view_get() will set the domain and architecture(view) related changes.

The default_get() is called when you click on NEW and the record is unsaved, thus it brings the default values from _defaults dict.

Hope this helps.

Revision history for this message
Cuong (bhcuong2008) said :
#7

It's very helpful. Thank you very much.

Revision history for this message
Cuong (bhcuong2008) said :
#8

Thanks Serpent Consulting Services, that solved my question.