-
-
Notifications
You must be signed in to change notification settings - Fork 587
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] mass_mailing_partner: Migration to v12.0 #323
[12.0][MIG] mass_mailing_partner: Migration to v12.0 #323
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are failing on external ids of partner which were completely changed in v12
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK when bots get ✔️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ernestotejeda ! A final comment. As I stated before: wouldn't it make more sense to add mailing lists to the partner main (and unique?) contact instead of creating a new one everytime we run the wizard?
As I said in PR #324 , I think it is feasible to add a contact _sql_constraints in mailing contact (mail.mass_mailing.contact) to add a unique (email). |
You both should take into account that we sometimes want to have same the same partner in several mass mailing contacts. For example, with |
To have the PR @pedrobaeza comments in consideration: #284 (abandoned?) Indeed in v11 there's a problem in the way the unsubscription was managed due to an incomplete frontend support. I'd say that's now solved in v12 (it supports it both ways): I'd go for allowing both ways of having contacts. Although I still think the logic way for the partner is to have a unique relation to a single contact. |
As i said in PR #324 , i think is better to leave that migration as it is now, so i think we should leave this PR as it is now too. |
Rebuilding runbot for testing About #323 (comment) from @ernestotejeda
VERY IMPORTANT ISSUE WE HAD and @chienandalu SOLVED is when the user (customer) MERGE res.partner . I will test this case to see what happends. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
* When creating or saving a mass-mailing contact, partners are matched through | ||
email, linking matched partner, or creating a new one if no match and the | ||
maling list partner mandatory field is checked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ernestotejeda I have found a BUG. Module creates a NEW res.partner always and it shouldn't.
- Modules should check always if there is a res.partner with the same email to match but
- Only if the mail.mass_mailing.contact belongs to a mail.mass_mailing.list which has set to TRUE the field "Mandatory Partner" must create a NEW res.partner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rafaelbn Yay!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rafaelbn I tested on the runbot and I could not reproduce that error
* When creating or saving a mass-mailing contact, partners are matched through | ||
email, linking matched partner, or creating a new one if no match and the | ||
maling list partner mandatory field is checked. | ||
* Mailing contacts smart button in partner form. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I've find a new smart-button "Mailing contact" in res.partner. Why are we allowing this? In my side doesn't have any sense as I said and we should FIX this. In the migration from v10 or v11 to v12 then OpenUpgrade should merge all mass_mailing.contact related to a single res.partner to a single mass_mailing.contact
Well, I don't want to extend the debate any longer, but I think the summary that @rafaelbn has made is very good, and I take the opportunity to respond to these aspects because I think that before making any change to the code, we must have everything clearly @rafaelbn, I agree with almost everything he has put in, but I do not understand what would be the problem with allowing a partner to be associated with more than one contact.
1- the wizard that exists to associate several partners to a list:
2- In res.partner:
3- In the mass_mailing_list_dynamic module (in case you were to migrate to v12)
4- As I said in the PR #324 . The module website_mass_mailing adds the snippet that gives the user the possibility to register in a mass mailing list from the website and each time a user uses this to subscribe to this list, this module creates a new contact mailing although there is another contact with that e-mail. So, if there is an AA contact with an email aa@example.com, each time that email subscribes to a list through the website, a contact will be created with that email and therefore associated with the AA partner. Anyway, I think that if the fact that a partner can be related to more than one contact is not wrong as a concept, it would be better to leave it as is, so as not to have to intervene in the aforementioned aspects. |
the domain domain = [('opt_out', '=', False)] in the field mass_mailing_contact_ids was removed because the mail.mass_mailing.contact doesn't have that field now in v12, mail.mass_mailing class. list_contact_rel is the class that has this field now. |
Good analysis @ernestotejeda I'm on keeping both ways of behaviour so we avoid those issues. So:
list_ids = partner.contact_ids.mapped('list_ids')
partner.contact_ids[1:].unlink()
partner.contact_ids[:1].list_ids |= list_ids # Or maybe on the relation model to keep the subscription dates and states
|
I agree with you @chienandalu, thanks |
@rafaelbn when a contact is associated with a partner the following contact fields: |
@ernestotejeda @chienandalu Whats happend with this? 😄 |
Well, @sergio-teruel , I think all the suggestions have been resolved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This migration is critical I need to analyze deeper. It could be a disaster when migrating a customer from v10 to v12 for example. I cannot approve with out testing it deeper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would try finish this PR as I have next module depends on
Thanks, @victormmtorres I'd say this was almost ready but I lost track of it. I you'd review if all the comments were honored and this is ready to review again let me know and I do my final one :) |
[IMP] mass_mailing_partner: Link mail statistics to partner
* Exclude opt_out. Now opted-out records will not be counted in the "Mailing lists" smart button in the partner form. * Avoid duplicate error. By indicating the exact `partner_id` and ensuring no contacts associated to it are found, you avoid possible duplication errors when several partners share the same name or email.
Without this patch, users without access to reading and editing mass mailing contact records are now unable to change a partner's name or email. They'd recieve an exception such as: AccessError: Sorry, you are not allowed to access this document. Only users with the following access level are currently allowed to do that: - Mass Mailing/User (Document model: mail.mass_mailing.contact) Restrictive ACLs shouldn't restrict normal user operation nor DB consistency, so using sudo mode now and testing behavior.
* [FIX+IMP] mass_mailing_list_dynamic: tests, icons, filters... * Brand new icon * Added feature of loading an existing filter as criteria * Tests as SavepointCase for optimizing times * Tests in post-install for avoiding errors on res.partner not null constraints when several modules added them. * Updated documentation. * Fix mock in test for not commiting test data. * [FIX] mass_mailing_list_dynamic: Wasn't able to create contacts in fully synced lists Syncing context was being set in the wrong object. Added to test too. * [FIX] mass_mailing_list_dynamic: Allow to write back vals from res.partner Module mass_mailing_partner writes back certain values from partner to mass_mailing_contact. Module should allow that write operation.
- In DB which use large amounts of records and intesive use of mass_mailings, not optimized compute records lead to a drastical decrease of performance
156e441
to
ca74186
Compare
@chienandalu I kind of lost on that amount of comments on many people on this PR, I fix one I found is clear. But other maybe already done by @ernestotejeda on his last commit ca74186 |
For each partner, if already has a contact it's added to the selected list, otherwise a new one is created
Or infinite recursions will happen on other `write` overwrites, like the one that happens on `mass_mailing_partner`.
d6fb85e
to
007d8ad
Compare
/ocabot merge |
This PR looks fantastic, let's merge it! |
Congratulations, your PR was merged at 7081297. Thanks a lot for contributing to OCA. ❤️ PS: Don't worry if GitHub says there are unmerged commits: it is due to a rebase before merge. All commits of this PR have been merged into |
cc @Tecnativa