-
-
Notifications
You must be signed in to change notification settings - Fork 612
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
[8.0][IMP][mail_tracking] Email stars and generic webhook #77
Conversation
@@ -77,13 +84,81 @@ class MailTrackingEmail(models.Model): | |||
string="Tracking events", comodel_name='mail.tracking.event', | |||
inverse_name='tracking_email_id', readonly=True) | |||
|
|||
@api.model | |||
def email_score(self, trackings): | |||
"""Default email score algorimth""" |
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.
Why this method here? And why not @api.multi in case of belonging here?
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 is for reusing this in other models (like crm.lead) and inherit only in one place
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, make it @api.multi then
@antespi please review runbot and travis |
@api.depends('recipient') | ||
def _compute_recipient_address(self): | ||
for email in self: | ||
matches = re.search(r'<(.*@.*)>', email.recipient) |
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.
won't you be better off with https://github.com/OCA/OCB/blob/8.0/openerp/tools/mail.py#L606?
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 match is not for checking email address, but for extrating it if recipient is in the form Name <[email protected]>
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.
check your regex against This <hello@world>>
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 think #77 (comment) should still work for you.
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.
@hbrunn This only could happend if partner email is hello@world>
because this form if built by Odoo automatically concatenating partner name and partner email.
This match is not for checking, just for extracting and easy matching by partner email afterwords
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 know I'm late, just letting you know that still the suggested regexp should work for extracting the email as you want. 😉
it seems you didn't git add |
superseded by #78 it seems |
This PR only affects to They are separated in order to review them separately Please, open this PR again, in order to continues reviewing process |
okay thanks, got the point. I really miss lauchpad's depending branch feature |
@antespi please review coveralls. This PR is ready to be merged 👍 |
Any chance to add some tests? 😇 |
5013d12
to
2d5f855
Compare
All green 🐸 , rebase and squashed for merging. |
@@ -79,7 +79,7 @@ def send_email(self, message, mail_server_id=None, smtp_server=None, | |||
smtp_server=smtp_server, smtp_port=smtp_port, | |||
smtp_user=smtp_user, smtp_password=smtp_password, | |||
smtp_encryption=smtp_encryption, smtp_debug=smtp_debug) | |||
except Exception as e: | |||
except Exception as e: # pragma: no cover | |||
if tracking_email: | |||
tracking_email.smtp_error(self, smtp_server_used, e) | |||
raise |
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.
If you raise again the exception, isn't the previous DB operations rollbacked?
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 have to raise the exception because i'm inheriting the method, so I have to propagate the result, even an exception
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 don't known if the last operation is rollbacked. This is a cool test case.
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've added a new test case for testing SMTP error using mock. I think raising exception will not affect DB operations because is the standard behavior.
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 took a look at your mocks, and I do not see a test case for an SMTP Exception. In order to test this case, you need to use mock_object.side_effect = SMTPError
. I only see return_values being set in the mocks.
021eb44
to
5c646f5
Compare
5c646f5
to
4621c8d
Compare
@antespi, we decided to not squash intermediate commits when fixing comments in review to ease reviewers to see what you have done new instead of reviewing again the full diff, and only squash on merge time or when all is clear. Please don't do it next time. For me, this is 👍, but I'm going to wait to @lasley to give his approval before merging. |
I admittedly die a bit each time I look at that I digress- LGTM 👍 thanks for the submission! |
cc @Tecnativa