server-ux icon indicating copy to clipboard operation
server-ux copied to clipboard

[16.0][FIX] base_substate: track template on substate

Open Saran440 opened this issue 2 years ago • 9 comments
trafficstars

This PR cherry-pick from https://github.com/OCA/server-ux/pull/735

Saran440 avatar Oct 24 '23 06:10 Saran440

@pedrobaeza Can you please merge this? 🙏

bosd avatar Nov 02 '23 09:11 bosd

@etobella We are talking about this one. It is not likely to get merged soon in this current form. Should this block the other pr?

:innocent: Why is this change negativly impacting performant?

bosd avatar Nov 02 '23 13:11 bosd

It impacts because this is evaluated for each writing in every model in Odoo inheriting from mail thread, instead of only those inheriting from the substate mixin.

pedrobaeza avatar Nov 02 '23 13:11 pedrobaeza

Ok, I agree with @pedrobaeza it shouldn't inherit in mail.thread

@etobella Thank you for your suggest. If we use base.substate.mixin inherit mail.thread and move function _track_template() back to base.substate.mixin it will not create new abstract. what do you think?

_name = "base.substate.mixin"
_inherit = "mail.thread"

Saran440 avatar Nov 03 '23 02:11 Saran440

Oops, the discussion here seems to have halted. As well as the dev/merging of other substate modules.

@Saran440 Can we get things moving again? Can you rebase/force push to recreate runboat / tests?

bosd avatar Dec 12 '23 07:12 bosd

Ping @Saran440 It has been a while since we worked on several substate modules. Things got stale over time. What do we need to do to get things moving again?

bosd avatar Jan 18 '24 11:01 bosd

@bosd I fixed test script and some bug in function _track_template(). Can you check and test template in https://github.com/OCA/account-invoicing/pull/1568 please. Thank you.

Saran440 avatar Jan 26 '24 09:01 Saran440

Can you check and test template in OCA/account-invoicing#1568 please. Thank you.

Sorry to keep you waiting... With the version of base_substate in this PR I'm getting an error:

RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1584, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/opt/odoo/custom/src/odoo/odoo/service/model.py", line 133, in retrying
    result = func()
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1611, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 1809, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
    result = endpoint(**request.params)
  File "/opt/odoo/custom/src/odoo/odoo/http.py", line 697, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/opt/odoo/auto/addons/web/controllers/dataset.py", line 46, in call_button
    action = self._call_kw(model, method, args, kwargs)
  File "/opt/odoo/auto/addons/web/controllers/dataset.py", line 33, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 461, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/api.py", line 448, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "<decorator-gen-69>", line 2, in button_immediate_install
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_module.py", line 76, in check_and_log
    return method(self, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_module.py", line 491, in button_immediate_install
    return self._button_immediate_function(type(self).button_install)
  File "/opt/odoo/custom/src/odoo/odoo/addons/base/models/ir_module.py", line 615, in _button_immediate_function
    registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
  File "<decorator-gen-14>", line 2, in new
  File "/opt/odoo/custom/src/odoo/odoo/tools/func.py", line 87, in locked
    return func(inst, *args, **kwargs)
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 90, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 488, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 372, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 207, in load_module_graph
    registry.setup_models(cr)
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 285, in setup_models
    model._prepare_setup()
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 2703, in _prepare_setup
    cls.__bases__ = cls.__base_classes
TypeError: Cannot create a consistent method resolution
order (MRO) for bases BaseModel, base, mail.thread, mail.activity.mixin, sequence.mixin, base.substate.mixin

The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
    at makeErrorFromResponse (http://localhost:16069/web/assets/435-e992299/web.assets_backend.min.js:973:163)
    at XMLHttpRequest.<anonymous> (http://localhost:16069/web/assets/435-e992299/web.assets_backend.min.js:981:13)

bosd avatar Feb 23 '24 20:02 bosd

@Saran440 Can you attend to the error? It might be applicable to the backport in V15

bosd avatar May 30 '24 08:05 bosd

What is the status of this one?

bosd avatar Nov 15 '24 06:11 bosd

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

github-actions[bot] avatar Mar 16 '25 12:03 github-actions[bot]

@pedrobaeza Is this one ok for you now?

bosd avatar Mar 18 '25 06:03 bosd

Why previous approach didn't work?

pedrobaeza avatar Mar 18 '25 08:03 pedrobaeza

@pedrobaeza See https://github.com/OCA/sale-workflow/pull/3483 for why the previous approach did not always work, and how it can be solved without overriding write.

StefanRijnhart avatar Mar 18 '25 09:03 StefanRijnhart

On my way to merge this fine PR! Prepared branch 16.0-ocabot-merge-pr-736-by-pedrobaeza-bump-patch, awaiting test results.

OCA-git-bot avatar Mar 18 '25 09:03 OCA-git-bot

Congratulations, your PR was merged at 52d41cc9c3e9620d6f42dd4bcaac3bdf07ddae5a. Thanks a lot for contributing to OCA. ❤️

OCA-git-bot avatar Mar 18 '25 09:03 OCA-git-bot

@pedrobaeza I take it that you didn't like the solution that depends on the inheritance order?

StefanRijnhart avatar Mar 18 '25 11:03 StefanRijnhart

Well, I didn't see that alternative approach. I just saw that overwriting the write one was too much intrusive, and that they have proposed an alternative one having enough support.

pedrobaeza avatar Mar 18 '25 11:03 pedrobaeza

@pedrobaeza Well, as you can see in https://github.com/OCA/sale-workflow/pull/3483/files it does not have the intrusive write, and is more in line with the standard Odoo tracking mechanism using the cursor commit hooks. Should we go that way for 17.0?

StefanRijnhart avatar Mar 18 '25 11:03 StefanRijnhart

OK then, let's improve it in 17.0

pedrobaeza avatar Mar 18 '25 11:03 pedrobaeza