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

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

Open Saran440 opened this issue 2 years ago • 4 comments

Move function _track_template() on base_substate_mixin to mail_thread Currently, Email Template on Base Substate is not working.

Step to error:

  1. Create base substate and add Email Template
  2. Change substate to substate there is email template, it will not send email template.

Saran440 avatar Oct 24 '23 05:10 Saran440

I can confirm the issue. Now everybode seems to be patching it in their *_substate module.

Test on this one are failling. Unit tests on 15.0 branch are currently broken. Fix in: https://github.com/OCA/server-ux/pull/733 Can you review the fix?

bosd avatar Oct 24 '23 06:10 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 May 26 '24 12:05 github-actions[bot]

Just tested this locally. The error still exsists.

Traceback (most recent call last):
  File "/opt/odoo/custom/src/odoo/odoo/service/server.py", line 1260, in preload_registries
    registry = Registry.new(dbname, update_module=update_module)
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 87, in new
    odoo.modules.load_modules(registry, force_demo, status, update_module)
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 470, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 363, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/opt/odoo/custom/src/odoo/odoo/modules/loading.py", line 198, in load_module_graph
    registry.setup_models(cr)
  File "/opt/odoo/custom/src/odoo/odoo/modules/registry.py", line 279, in setup_models
    model._prepare_setup()
  File "/opt/odoo/custom/src/odoo/odoo/models.py", line 2975, 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, base.substate.mixin

bosd avatar Jun 28 '24 20:06 bosd

@bosd Thank you for checked. Error because this model base.substate.mixin use mail.thread inherit and other module such as hr_expense_substate inherit mail.thread already So, i deleted inherit and someone must inherit mail.thread itself if model not support

Saran440 avatar Jul 02 '24 08:07 Saran440

@Saran440 Can you please force push again. To see if tests pass this time?

bosd avatar Nov 14 '24 21:11 bosd

@oca/server-ux-maintainers Can we get a merge here?

bosd avatar Dec 12 '24 15:12 bosd

Well, you could argue "my" solution is a bit more finicky because you need to make sure that inherits are in the right order, but this is something that is true in all the rest of Odoo's ORM (and arguably all of OOP).

But I think the reason this solution is worse is that this bypass the mail being sent in the post commit hook. This feature has been done to avoid a flow that would crash after it has sent an email (you can imagine the spam as the backend user will never see the message in DB). It's better to let mail.thread handle everything.

len-foss avatar Dec 13 '24 07:12 len-foss

Well, you could argue "my" solution is a bit more finicky

So should we proceed with this one?

bosd avatar Dec 19 '24 11:12 bosd

I think the usage of the post commit hook is a strong argument. We can therefore go with @len-foss's solution or refactor the solution proposed here such that the outgoing mail is only triggered in the post commit hook. That is probably best of both worlds, but it requires additional development.

StefanRijnhart avatar Dec 19 '24 12:12 StefanRijnhart

What a great day to merge this nice PR. Let's do it! Prepared branch 15.0-ocabot-merge-pr-735-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 0eba1533340e144e14853a2d92fa46c38792d3a4. Thanks a lot for contributing to OCA. ❤️

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