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

12.0 mig mail debrand #321

Merged
merged 5 commits into from
Nov 8, 2018
Merged

12.0 mig mail debrand #321

merged 5 commits into from
Nov 8, 2018

Conversation

gdgellatly
Copy link
Contributor

Complete rewrite as mail.templates are now QWeb templates so simply overwrite using inheritance.

The main change is all default mail notifications are debranded, not just the main one.

@OCA-git-bot OCA-git-bot mentioned this pull request Nov 7, 2018
24 tasks
@pedrobaeza pedrobaeza added this to the 12.0 milestone Nov 7, 2018
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

The change of strategy is not going to work as noupdate="1" records are not updated on secondary modules, so you should stick to python hack. It would be also good that you generate the README directly in this PR for saving one extra commit on merge and the lack of verification of the full composition.

mail_debrand/readme/DESCRIPTION.rst Outdated Show resolved Hide resolved
mail_debrand/readme/HISTORY.rst Outdated Show resolved Hide resolved
mail_debrand/readme/ROADMAP.rst Outdated Show resolved Hide resolved
mail_debrand/readme/USAGE.rst Outdated Show resolved Hide resolved
mail_debrand/views/mail_notification_view.xml Show resolved Hide resolved
@pedrobaeza
Copy link
Member

About regenerating the README, you only need to install maintainer-tools in your laptop and run the command inside module folder:

oca-gen-addon-readme  --repo-name social --branch 12.0 --addon-dir . --no-commit

but if not, at least don't remove entire README and let the previous one for reducing the diffs (one removing the text and another adding it the other way).

@gdgellatly gdgellatly force-pushed the 12.0-mig-mail_debrand branch 4 times, most recently from 9f53dc0 to 8e8bc13 Compare November 7, 2018 09:23
Copy link
Contributor

@LoisRForgeFlow LoisRForgeFlow left a comment

Choose a reason for hiding this comment

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

LGTM

@pedrobaeza pedrobaeza merged commit 5e92bf8 into OCA:12.0 Nov 8, 2018
@levkar
Copy link

levkar commented Dec 11, 2018

Odoo changed templates inside modules and this module is not working for many templates.

Example:

https://github.com/odoo/odoo/blob/11.0/addons/auth_signup/data/auth_signup_data.xml#L131
becomes
https://github.com/odoo/odoo/blob/12.0/addons/auth_signup/data/auth_signup_data.xml#L279

Python hack will not work either unless better regex patterns are written.

@gdgellatly @pedrobaeza @lreficent

@gdgellatly
Copy link
Contributor Author

gdgellatly commented Dec 11, 2018 via email

@gdgellatly
Copy link
Contributor Author

gdgellatly commented Dec 11, 2018 via email

@pedrobaeza
Copy link
Member

Well, this module shouldn't depend on those modules, so better to improve regexp for them.

@gdgellatly
Copy link
Contributor Author

@pedrobaeza I took a quick look, its not too bad. The first xml replacement needs to stay. While the rest could all be covered by 3 or 4 fairly straightforward regex, I think a better solution is an etree xpath based element replacement in code. Just traverse to the node and remove and continue to each ancestor if it is empty. Some of these are in td's, some in tr's some in tables, some in div's. Just easier to xpath to the node containing the text, remove, check parent, if now empty recursively remove.

There must be some point in the rendering that the full document is available for parsing.

@pedrobaeza
Copy link
Member

Yes, but once rendered, not by XML.

@rvalyi
Copy link
Member

rvalyi commented Dec 26, 2018

Are you sure this module works? I'm getting mad trying with sending a quotation by email end the "Powered by Odoo" is not removed. the xpath view extension of the mail.mail_notification_paynow looks correct however it looks like the inherit is not applied. For instance if I change something in the mail.mail_notification_paynow template, I see it change in the email, but that last <tr> where the branding stands is never removed...

@gdgellatly
Copy link
Contributor Author

gdgellatly commented Dec 26, 2018 via email

@pedrobaeza
Copy link
Member

I told about the change on the strategy about Python code, and now my fears come true...

@gdgellatly
Copy link
Contributor Author

gdgellatly commented Dec 27, 2018

@pedrobaeza Well looking at it, actually its working absolutely identically to v11.0 (in fact better as it at least takes care of all mail cases) so it is nothing to do with strategy change or anything like that. It just so happens that the v11.0 module also didn't remove the powered by messages from templates either inside or outside of mail module.

So picking on this PR and "strategy change" without checking is just a red herring, so you can be less fearful now. The functionality never existed to be ported.

Now if we agree we do want to remove these Powered by messages, I have written the xml parsing to do so, the question is do we want the change?

EDIT: I should not, there is a significant performance tradeoff here. Every email will require parsing and at least 1 xpath, whereas in the past only 1 single template was ever checked.

@pedrobaeza
Copy link
Member

@gdgellatly when I migrated this module in v10, I took the approach of replacing text in the mail rendering because of these things, and that's why I talked about from the very first moment. I still don't understand why this can't be done the same way:

https://github.com/OCA/social/blob/10.0/mail_debrand/models/mail_template.py

@gdgellatly
Copy link
Contributor Author

gdgellatly commented Dec 27, 2018

@pedrobaeza But you didn't. Except for one template. And that was before they were changed to qweb. And definitely the powered by messages were never removed.

Now it is 8 templates all slightly differently formatted in 2 differing formats. Parsing xml is the right way for the html based templates, replacement is right for the qweb ones. I did a POC, works nicely.

POC is at #344

@gdgellatly
Copy link
Contributor Author

@pedrobaeza I just went back and tested based off your v11. It doesn't work that way anymore for anything qweb based. It seems it now renders the template without the overarching qweb, and then adds them in during later based on user preferences.

@pedrobaeza
Copy link
Member

But mine is not v11, but v10. v11 version was done by Eficent.

@gr22
Copy link

gr22 commented Dec 28, 2018

I am experiencing the same thing. I find no way to override those views.

Are you sure this module works? I'm getting mad trying with sending a quotation by email end the "Powered by Odoo" is not removed. the xpath view extension of the mail.mail_notification_paynow looks correct however it looks like the inherit is not applied. For instance if I change something in the mail.mail_notification_paynow template, I see it change in the email, but that last <tr> where the branding stands is never removed...

ernestotejeda pushed a commit to Tecnativa/social that referenced this pull request Mar 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants