diff --git a/README.md b/README.md index 09fd39fef..46be93154 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ addon | version | maintainers | summary [dbfilter_from_header](dbfilter_from_header/) | 17.0.1.0.0 | | Filter databases with HTTP headers [jsonifier](jsonifier/) | 17.0.1.0.0 | | JSON-ify data for all models [module_change_auto_install](module_change_auto_install/) | 17.0.1.0.0 | [![legalsylvain](https://github.com/legalsylvain.png?size=30px)](https://github.com/legalsylvain) | Customize auto installables modules by configuration +[onchange_helper](onchange_helper/) | 17.0.1.0.0 | | Technical module that ease execution of onchange in Python code Unported addons diff --git a/onchange_helper/README.rst b/onchange_helper/README.rst index 60cf5ce78..90fbb60fc 100644 --- a/onchange_helper/README.rst +++ b/onchange_helper/README.rst @@ -7,7 +7,7 @@ Onchange Helper !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:556ec1d279174035dfcc8805dad664de965fafb926ddc617899c4a7f51756444 + !! source digest: sha256:ae0d21d8811c6bb216bc524de3946ae71446fb1c9a6c23c9898e98d1a2ef4fee !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png diff --git a/onchange_helper/static/description/index.html b/onchange_helper/static/description/index.html index 77bd5d4e7..cb7cb3e1f 100644 --- a/onchange_helper/static/description/index.html +++ b/onchange_helper/static/description/index.html @@ -1,673 +1,482 @@ - + - - - - Onchange Helper - - - -
-

Onchange Helper

- - -

- - Beta - - - License: AGPL-3 - - - OCA/server-tools - - - Translate me on Weblate - - - Try me on Runboat - -

-

This is a technical module. Its goal is to ease the play of onchange - method directly called from Python code. -

-

- Table of contents -

-
- -
-
-

- Usage -

-

To use this module, you need to:

- -

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:

- -
-
-

- Known issues / Roadmap -

-

Note that onchanges tend to disappear due to the introduction of - ‘computed stored readonly False fields’ in most cases. When migrating, - it is best to prefer changing it to that way instead of using this - module. -

-
-
-

- Bug Tracker -

-

Bugs are tracked on - GitHub Issues. - In case of trouble, please check there if your issue has already been reported. - If you spotted it first, help us to smash it by providing a detailed and welcomed - - feedback. -

-

Do not contact contributors directly about support or help with technical issues.

-
-
-

- Credits -

-
-

- Authors -

-
    -
  • Akretion
  • -
  • Camptocamp
  • -
-
-
-

- Contributors -

- -
-
-

- Maintainers -

-

This module is maintained by the OCA.

- - Odoo Community Association - -

OCA, or the Odoo Community Association, is a nonprofit organization whose - mission is to support the collaborative development of Odoo features and - promote its widespread use. -

-

This module is part of the - OCA/server-tools - - project on GitHub. -

-

You are welcome to contribute. To learn how please visit - https://odoo-community.org/page/Contribute. -

-
-
-
- + + + +Onchange Helper + + + +
+

Onchange Helper

+ + +

Beta License: AGPL-3 OCA/server-tools Translate me on Weblate Try me on Runboat

+

This is a technical module. Its goal is to ease the play of onchange +method directly called from Python code.

+

Table of contents

+
+ +
+
+

Usage

+

To use this module, you need to:

+ +

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:

+ +
+
+

Known issues / Roadmap

+

Note that onchanges tend to disappear due to the introduction of +‘computed stored readonly False fields’ in most cases. When migrating, +it is best to prefer changing it to that way instead of using this +module.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Akretion
  • +
  • Camptocamp
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/server-tools project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ diff --git a/setup/_metapackage/pyproject.toml b/setup/_metapackage/pyproject.toml index 0b59b3358..19a615d8d 100644 --- a/setup/_metapackage/pyproject.toml +++ b/setup/_metapackage/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "odoo-addons-oca-server-tools" -version = "17.0.20240202.1" +version = "17.0.20240202.2" dependencies = [ "odoo-addon-base_exception>=17.0dev,<17.1dev", "odoo-addon-base_technical_user>=17.0dev,<17.1dev", @@ -8,6 +8,7 @@ dependencies = [ "odoo-addon-dbfilter_from_header>=17.0dev,<17.1dev", "odoo-addon-jsonifier>=17.0dev,<17.1dev", "odoo-addon-module_change_auto_install>=17.0dev,<17.1dev", + "odoo-addon-onchange_helper>=17.0dev,<17.1dev", ] classifiers=[ "Programming Language :: Python",