odoo/odoo#81777

Created by Bugfix, Yolann Sabaux (yosa)
Merged at cb9dfe107d073aeaf4a6b72818b4c28b11dab0c7

Statuses:

label
odoo-dev:15.0-OPW-2680841-trigger_onchange_js_afip-yosa
head
9a473d25908550dd254c9422bff37427f1801a9b
merged
3 years ago by Bugfix, Nicolas Lempereur (nle)
odoo/odoo
15.0 #81777
saas-15.1 #81880
16.0
17.0
18.0
saas-18.1
saas-18.2
saas-18.3
master #81881

[FIX] web: no trigger of an onchange

Steps to reproduce:

  • Install Argentinian Electronic Payment (l10n_ar_edi)
  • Change company (ar responsable)
  • Go in Accounting > Settings: in the AFIP section
  • delete key and certificate
  • click on generate request
    -> the key is not persisted unless a manual refresh/discard is done

Solution:
In V14 the onchange is triggered. Why?
Because this https://github.com/odoo/odoo/blob/1723c52d42389a8b5124ab4d15d55dad0d119a8f/addons/web/static/src/js/chrome/action_manager.js#L130-L139
works because of the call of the on_close function:
https://github.com/odoo/odoo/blob/1723c52d42389a8b5124ab4d15d55dad0d119a8f/addons/web/static/src/js/chrome/action_manager.js#L534-L543

Why not in V15?
In V15 the onchange can be triggered when the this.reload function is called via the on_closed function:
https://github.com/odoo/odoo/blob/7ce6d8d70be79c9c626865598b898dce9a18b045/addons/web/static/src/legacy/js/views/basic/basic_controller.js#L472-L482

But to be triggered, in the wrapSuccessOrFail (when the _trigger_up funciton is called), the onClose must be called:
https://github.com/odoo/odoo/blob/fb3878b581b831c13550d40e38a8e8890d82ea0d/addons/web/static/src/legacy/action_adapters.js#L362-L376

In order to do that, we would have to use the options (the params) sent with the doActionButton in the doAction function.
https://github.com/odoo/odoo/blob/fee371be291ba3d6f1adc71c08420b6510fdf386/addons/web/static/src/webclient/actions/action_service.js#L1198-L1199

BUT the options are not used anymore when _executeActURLAction* is called (only the actionparamater is required):
https://github.com/odoo/odoo/blob/fee371be291ba3d6f1adc71c08420b6510fdf386/addons/web/static/src/webclient/actions/action_service.js#L1098-L1104

Therefore, we find ourselves in a situation in which we cannot call the on_closed function in (the options are not even an 'option'**):
https://github.com/odoo/odoo/blob/fee371be291ba3d6f1adc71c08420b6510fdf386/addons/web/static/src/webclient/actions/action_service.js#L748-L764

Look again in V14 how the function is called:
https://github.com/odoo/odoo/blob/1723c52d42389a8b5124ab4d15d55dad0d119a8f/addons/web/static/src/js/chrome/action_manager.js#L527-L543

The solution is therefore easily understandable.

*we are in this specific switch_case because the action executed is:

https://github.com/odoo/enterprise/blob/6805d2f591237ad17d7db827dcf6fe36c2c2744f/l10n_ar_edi/models/res_config_settings.py#L30-L32

** no pun intended

opw-2680841