This is a technical module. Its goal is to ease the play of onchange method directly called from Python code.
auto_awesome What this module does
AI-generated from the code · Odoo 19.0This technical module lets developers run Odoo's onchange logic directly from Python code, without needing the web client. It is used by other modules, not by end users.
This is a technical module aimed at developers. It adds two helper methods on the base model that any Odoo model inherits, so other modules can simulate what happens in the user interface when a field is changed.
play_onchangestakes a dictionary of values and a list of field names, then runs the onchange methods for those fields in the given order. It returns the resulting values, including values computed by the onchange logic._get_new_valuesis an internal helper that extracts the new values returned by an onchange call, converting many2one values to their database id.
The module does not add menus, screens, buttons, reports, or scheduled jobs. It does not change any business rules by itself. Its purpose is to make it easier for other modules to reuse onchange behaviour when creating or updating records from code, for example in imports or automated processes. It depends on the web module and extends the base model, so the helpers are available on every model. Because it is a developer tool, end users will not see any direct change in Odoo.
Depends on
Required by other modules
Models and fields (1)
- base · extends an existing model
Text generated by AI (DeepSeek) from reading the Odoo 19.0 code on GitHub; it may contain mistakes, so check the code before deciding. View the code on GitHub
Availability by version
Reviewed: 2026-11-03Confirmation status: 8 confirmed, 1 with no information of 9 versions.
Sources · Odoo 19.0
Confirmed on 2026-11-03 in branch 19.0 of OCA/server-tools.
terminal Installation and usage
OCA documentation · Odoo 19.0Usage
Source · Odoo 19.0To use this module, you need to:
- depend on this module
- call yourmodel.play_onchanges(values, ['field'])
Example if you want to create a sale order and you want to get the values relative to partner_id field (as if you fill the field from UI)
> vals = {'partner_id': 1} > > vals = self.env['sale.order'].play_onchanges(vals, ['partner_id'])
Then, vals will be updated with partner_invoice_id, partner_shipping_id, pricelist_id, etc...
Default values will be used to process onchange methods, if respective fields are not set in vals. You can get them if you pass fields name in the list of fields.
> vals = {'partner_id': 1} > > vals = self.env['sale.order'].play_onchanges(vals, ['partner_id', > 'date_order'])
vals will contain, in addition to the changed values, the default value for date_order
You can also use it on existing record for example:
> vals = {'partner_shipping_id': 1} > > vals = sale.play_onchanges(vals, ['partner_shipping_id'])
Then the onchange will be played with the vals passed and the existing vals of the sale. vals will be updated with partner_invoice_id, pricelist_id, etc..
Behind the scene, play_onchanges will execute all the methods registered for the list of changed fields, so you do not have to call manually each onchange. To avoid performance issue when the method is called on a record, the record will be transformed into a memory record before calling the registered methods to avoid to trigger SQL updates command when values are assigned to the record by the onchange
Notes:
- Order in onchange_fields is very important as onchanges methods will be played in that order.
- If you use memory object in vals, be award that onchange method in base model call self.invalidate_cache() that reset it.
No verified information in OCA: Installation, Configuration.
Installation instructions, the distribution package, dependencies and configuration steps are not shown because they have not yet been verified in the module documentation for any version.
Data imported from GitHub: this sheet reflects the latest catalog review, not a live lookup. Always check the module documentation and staging before installing in production.