Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: 15.0
Choose a base branch
from

Conversation

Saran440
Copy link
Member

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.

@bosd
Copy link
Contributor

bosd commented Oct 24, 2023

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: #733
Can you review the fix?

@Saran440 Saran440 force-pushed the 15.0-fix-base_substate-template_default branch 2 times, most recently from 35062f4 to e3863e4 Compare October 25, 2023 03:52
Copy link
Contributor

@bosd bosd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments in: #736 (review)

@Saran440 Saran440 force-pushed the 15.0-fix-base_substate-template_default branch from 6fe65b2 to 8fc2c69 Compare January 26, 2024 11:18
Copy link

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 github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label May 26, 2024
@bosd
Copy link
Contributor

bosd commented Jun 28, 2024

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

@github-actions github-actions bot removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jun 30, 2024
@Saran440 Saran440 force-pushed the 15.0-fix-base_substate-template_default branch from 899633b to 2205a6f Compare July 2, 2024 08:04
@Saran440
Copy link
Member Author

Saran440 commented Jul 2, 2024

@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 Saran440 force-pushed the 15.0-fix-base_substate-template_default branch 2 times, most recently from c774ecb to 4df11b6 Compare July 9, 2024 09:46
@Saran440 Saran440 force-pushed the 15.0-fix-base_substate-template_default branch from 4df11b6 to 29ba690 Compare July 10, 2024 03:25
@bosd
Copy link
Contributor

bosd commented Nov 14, 2024

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

@Saran440 Saran440 force-pushed the 15.0-fix-base_substate-template_default branch from 8b43ff5 to 12822c5 Compare November 15, 2024 02:57
Copy link

@Dranyel-Bosd Dranyel-Bosd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

@bosd
Copy link
Contributor

bosd commented Dec 12, 2024

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

Copy link
Member

@StefanRijnhart StefanRijnhart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue seems to be that _track_template of the mixin is bypassed in the ORM inheritance MRO. The solution put forward earlier today in https://github.com/OCA/sale-workflow/pull/3483/files is to change the inheritance order.
The solution in this PR is to refactor out the method.
I would like the solutions to converge, but I don't know which approach is better. Do you have any arguments for either? @Saran440 @bosd @len-foss

@len-foss
Copy link

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.

@bosd
Copy link
Contributor

bosd commented Dec 19, 2024

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

So should we proceed with this one?

@StefanRijnhart
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants