-
-
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
[MIG][11.0] mail_digest #225
Conversation
Depending on the request might fail nevertheless the website should be there to be found. Fallback to search and use it if possible for digest' site name
When creating digest records within the context of mail composer (and possibly other contexts) you'll have a `default_template_id` key in the context which is going to override our safe default. This is going to break email generation because the template will be completely wrong and unpredictable. Lesson learned :)
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.
It seems, there's something wrong with message and mail_id params, as a few are unused, Otherwise, looks good !
mail_digest/data/ir_cron.xml
Outdated
@@ -3,25 +3,23 @@ | |||
<data noupdate="1"> |
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.
to remove.
mail_digest/models/mail_digest.py
Outdated
@@ -77,37 +75,37 @@ def create_or_update(self, partners, message, subtype_id=None): | |||
""" | |||
subtype_id = subtype_id or message.subtype_id |
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.
Looks like this can be removed, as it isn't used in the function.
mail_digest/models/mail_digest.py
Outdated
digest.message_ids |= message | ||
return True | ||
|
||
@api.model | ||
def _get_by_partner(self, partner, mail_id=False): | ||
"""Retrieve digest record for given partner. | ||
def _get_by_user(self, user, mail_id=False): |
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.
mail_id
should be renamed mail
mail_digest/models/mail_digest.py
Outdated
:param mail_id: `mail.mail` record for further filtering. | ||
|
||
By default we lookup for pending digest without notification yet. | ||
""" | ||
domain = [ | ||
('partner_id', '=', partner.id), | ||
('user_id', '=', user.id), | ||
('mail_id', '=', mail_id), |
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.
mail_id
is then mail.id
mail_digest/models/mail_digest.py
Outdated
('mail_id', '=', mail_id), | ||
] | ||
return self.search(domain, limit=1) | ||
|
||
@api.model | ||
def _get_or_create_by_partner(self, partner, message=None, mail_id=False): | ||
"""Retrieve digest record or create it by partner. | ||
def _get_or_create_by_user(self, user, message=None, mail_id=False): |
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.
Again mail_id
> mail
, message=None
to remove, as it's not used
mail_digest/models/mail_digest.py
Outdated
:param message: `mail.message` to include in digest | ||
:param mail_id: `mail.mail` record to set on digest | ||
""" | ||
existing = self._get_by_partner(partner, mail_id=mail_id) | ||
existing = self._get_by_user(user, mail_id=mail_id) |
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.
mail_id=mail_id
> mail=mail
mail_digest/models/res_users.py
Outdated
('user_id', '=', self.id) | ||
], limit=1) | ||
if self.env.context.get('foo'): | ||
import pdb; pdb.set_trace() |
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.
Seems this should be removed.
674ad2a
to
305fce8
Compare
@grindtildeath obsolete params removed. tnx :) |
305fce8
to
59974e6
Compare
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.
Two <data>
XML tags to remove and it's fine for me 👍
mail_digest/data/ir_cron.xml
Outdated
@@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<odoo> | |||
<data noupdate="1"> |
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.
Still this tag to remove.
mail_digest/data/config_param.xml
Outdated
@@ -0,0 +1,9 @@ | |||
<odoo> | |||
<data noupdate="1"> |
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.
Still this tag to remove.
59974e6
to
2e1e331
Compare
@grindtildeath done |
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.
LGTM
mail_digest/models/mail_digest.py
Outdated
|
||
@api.model | ||
def create_or_update(self, partners, message, subtype_id=None): | ||
def create_or_update(self, partners, message): |
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.
is there any reason to still use the partner here? specially since you then get the user_id from the 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.
some reasons:
- this method is called by res.partner
_notify
method as notification are sent to users but attached to partners. I like to keep the 2 things tied; - message/email recipients are partners (as in std notifications). Again like to keep this in line.
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, that makes sense.
it's quite hard for me to separate the old commits from the new ones, @simahawk, can you check this? |
@hbrunn the last 3 commits. The former are improvements coming from v10 that were not ported yet. |
thanks, I was doing something stupid before. I miss a migration script, but given we don't have rules about that to my knowledge, I won't block on this. Any reason not to provide one? Should be just a couple of SQL statements and make the upgrade experience much better. |
@hbrunn main reason, honestly: not needed for my project and not sure I can spend time on it. |
@simahawk fair enough. But you inspired me to make this PR: OCA/maintainer-tools#324 |
NOTE: I've tried to squash the 2 OCA transbot commits but I get tons of conflicts...