-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by simahawk
- Loading branch information
Showing
25 changed files
with
1,088 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
=============== | ||
Onchange Helper | ||
=============== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:f99de3ee6c925e95e76870bbc84e80cfeb2842ff3e1e71af1f2bd17deeb935b6 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github | ||
:target: https://github.com/OCA/server-tools/tree/18.0/onchange_helper | ||
:alt: OCA/server-tools | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/server-tools-18-0/server-tools-18-0-onchange_helper | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-tools&target_branch=18.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This is a technical module. Its goal is to ease the play of onchange | ||
method directly called from Python code. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
To 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. | ||
|
||
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 <https://github.com/OCA/server-tools/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 <https://github.com/OCA/server-tools/issues/new?body=module:%20onchange_helper%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* Akretion | ||
* Camptocamp | ||
|
||
Contributors | ||
------------ | ||
|
||
- Guewen Baconnier <[email protected]> | ||
- Florian da Costa <[email protected]> | ||
- Andrea Stirpe <[email protected]> | ||
- Souheil Bejaoui <[email protected]> | ||
- Kevin Khao <[email protected]> | ||
- Thien Vo <[email protected]> | ||
|
||
Other credits | ||
------------- | ||
|
||
The migration of this module from 17.0 to 18.0 was financially supported | ||
by Camptocamp. | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
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 <https://github.com/OCA/server-tools/tree/18.0/onchange_helper>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# License LGPL-3 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright 2016-2017 Akretion (http://www.akretion.com) | ||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Onchange Helper", | ||
"version": "18.0.1.0.0", | ||
"summary": "Technical module that ease execution" " of onchange in Python code", | ||
"author": "Akretion,Camptocamp,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/server-tools", | ||
"license": "LGPL-3", | ||
"category": "Generic Modules", | ||
"depends": ["web"], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * onchange_helper | ||
# | ||
# Translators: | ||
# Lukáš Spurný <[email protected]>, 2018 | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2018-03-03 10:08+0000\n" | ||
"PO-Revision-Date: 2018-03-03 10:08+0000\n" | ||
"Last-Translator: Lukáš Spurný <[email protected]>, 2018\n" | ||
"Language-Team: Czech (Czech Republic) (https://www.transifex.com/oca/" | ||
"teams/23907/cs_CZ/)\n" | ||
"Language: cs_CZ\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" | ||
|
||
#. module: onchange_helper | ||
#: model:ir.model,name:onchange_helper.model_base | ||
msgid "Base" | ||
msgstr "" | ||
|
||
#~ msgid "base" | ||
#~ msgstr "základny" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * onchange_helper | ||
# | ||
# Translators: | ||
# Niki Waibel <[email protected]>, 2017 | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 10.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2017-06-01 14:59+0000\n" | ||
"PO-Revision-Date: 2017-06-01 14:59+0000\n" | ||
"Last-Translator: Niki Waibel <[email protected]>, 2017\n" | ||
"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" | ||
"Language: de\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
||
#. module: onchange_helper | ||
#: model:ir.model,name:onchange_helper.model_base | ||
msgid "Base" | ||
msgstr "" | ||
|
||
#~ msgid "ir.rule" | ||
#~ msgstr "ir.rule" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * onchange_helper | ||
# | ||
# Translators: | ||
# enjolras <[email protected]>, 2018 | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2018-03-03 10:08+0000\n" | ||
"PO-Revision-Date: 2023-09-03 00:15+0000\n" | ||
"Last-Translator: Ivorra78 <[email protected]>\n" | ||
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" | ||
"Language: es\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
"X-Generator: Weblate 4.17\n" | ||
|
||
#. module: onchange_helper | ||
#: model:ir.model,name:onchange_helper.model_base | ||
msgid "Base" | ||
msgstr "Base" | ||
|
||
#~ msgid "base" | ||
#~ msgstr "base" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * onchange_helper | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 15.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2022-09-04 06:07+0000\n" | ||
"Last-Translator: Ignacio Buioli <[email protected]>\n" | ||
"Language-Team: none\n" | ||
"Language: es_AR\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
"X-Generator: Weblate 4.3.2\n" | ||
|
||
#. module: onchange_helper | ||
#: model:ir.model,name:onchange_helper.model_base | ||
msgid "Base" | ||
msgstr "Base" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * onchange_helper | ||
# | ||
# Translators: | ||
# Quentin THEURET <[email protected]>, 2018 | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2018-03-03 10:08+0000\n" | ||
"PO-Revision-Date: 2018-03-03 10:08+0000\n" | ||
"Last-Translator: Quentin THEURET <[email protected]>, 2018\n" | ||
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" | ||
"Language: fr\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
|
||
#. module: onchange_helper | ||
#: model:ir.model,name:onchange_helper.model_base | ||
msgid "Base" | ||
msgstr "" | ||
|
||
#~ msgid "base" | ||
#~ msgstr "base" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * onchange_helper | ||
# | ||
# Translators: | ||
# OCA Transbot <[email protected]>, 2017 | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 10.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2017-06-01 14:59+0000\n" | ||
"PO-Revision-Date: 2017-06-01 14:59+0000\n" | ||
"Last-Translator: OCA Transbot <[email protected]>, 2017\n" | ||
"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" | ||
"Language: hr\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" | ||
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" | ||
|
||
#. module: onchange_helper | ||
#: model:ir.model,name:onchange_helper.model_base | ||
msgid "Base" | ||
msgstr "" | ||
|
||
#~ msgid "ir.rule" | ||
#~ msgstr "ir.rule" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * onchange_helper | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 16.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2024-01-02 16:34+0000\n" | ||
"Last-Translator: mymage <[email protected]>\n" | ||
"Language-Team: none\n" | ||
"Language: it\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=2; plural=n != 1;\n" | ||
"X-Generator: Weblate 4.17\n" | ||
|
||
#. module: onchange_helper | ||
#: model:ir.model,name:onchange_helper.model_base | ||
msgid "Base" | ||
msgstr "Base" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * onchange_helper | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: onchange_helper | ||
#: model:ir.model,name:onchange_helper.model_base | ||
msgid "Base" | ||
msgstr "" |
Oops, something went wrong.