How to write an on_change that modifies a field inside a o2m field?

Asked by Leonardo Pistone

Hi all.

I'd like to have an on_change of a field to change a field inside a o2m field. It's not clear to me how to write the result['value'] in that case.

Practical example:

take the invoice view as it is now in v6. Suppose I wanted to improve the fiscal_position field, adding an on_change to it that re-computes the taxes inside the invoice lines. It's not clear to me what the on_change function should return in that case

Any pointers?

Thanks!

Question information

Language:
English Edit question
Status:
Answered
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Graeme Gellatly (gdgellatly) said :
#1

Hi,

I wrote an onchange doing just that for account_account_extension_o4sb released last week. The function signature is this one

def onchange_chart_template_id(self, cr, uid, ids, chart_template_id=False, context=None):

and it starts on line 71 of http://bazaar.launchpad.net/~gdgellatly/openobject-addons/acct-extension/view/head:/account_account_extension_o4sb/account_extension.py

but basically all you do is return a list of dictionaries for that field value.

Can you help with this problem?

Provide an answer of your own, or ask Leonardo Pistone for more information if necessary.

To post a message you must log in.