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

[8.0][IMP][mail_tracking] Email stars and generic webhook #77

Merged
merged 1 commit into from
Aug 7, 2016

Conversation

antespi
Copy link
Contributor

@antespi antespi commented Jul 13, 2016

  • Add a generic webhook for an easier inheritance
  • Add a smartbutton in res.partner form to see all tracking emails related to its email address
  • Add email score and email stars fields to res partner form and a default simple algorithm to calculate them

cc @Tecnativa

@rafaelbn rafaelbn added this to the 8.0 milestone Jul 13, 2016
@@ -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"""
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

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

@rafaelbn
Copy link
Member

@antespi please review runbot and travis

@api.depends('recipient')
def _compute_recipient_address(self):
for email in self:
matches = re.search(r'<(.*@.*)>', email.recipient)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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]>

Copy link
Member

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>>

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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. 😉

@hbrunn
Copy link
Member

hbrunn commented Jul 25, 2016

it seems you didn't git add hooks.py

@hbrunn
Copy link
Member

hbrunn commented Jul 25, 2016

superseded by #78 it seems

@hbrunn hbrunn closed this Jul 25, 2016
@antespi
Copy link
Contributor Author

antespi commented Jul 25, 2016

This PR only affects to mail_tracking addon
#78 PR includes these commits, because it depends on this.

They are separated in order to review them separately

Please, open this PR again, in order to continues reviewing process

@pedrobaeza
Copy link
Member

@hbrunn. They are different things. #78 includes also this one.

@hbrunn
Copy link
Member

hbrunn commented Jul 25, 2016

okay thanks, got the point. I really miss lauchpad's depending branch feature

@rafaelbn
Copy link
Member

@antespi please review coveralls. This PR is ready to be merged 👍

@yajo
Copy link
Member

yajo commented Aug 5, 2016

Any chance to add some tests? 😇

@antespi antespi force-pushed the 8.0-mail_tracking_email_stars branch from 5013d12 to 2d5f855 Compare August 5, 2016 19:03
@antespi
Copy link
Contributor Author

antespi commented Aug 5, 2016

All green 🐸 , rebase and squashed for merging.
Testing controllers using mock. @yajo, this trick is really awesome.

@@ -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
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

@antespi antespi Aug 7, 2016

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@antespi antespi force-pushed the 8.0-mail_tracking_email_stars branch from 021eb44 to 5c646f5 Compare August 7, 2016 18:16
@antespi antespi force-pushed the 8.0-mail_tracking_email_stars branch from 5c646f5 to 4621c8d Compare August 7, 2016 18:17
@pedrobaeza
Copy link
Member

@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.

@lasley
Copy link
Contributor

lasley commented Aug 7, 2016

I admittedly die a bit each time I look at that except Exception, but it's in the core too so it's only right to replicate here.

I digress- LGTM 👍 thanks for the submission!

@pedrobaeza pedrobaeza merged commit b8f2336 into OCA:8.0 Aug 7, 2016
@yajo yajo deleted the 8.0-mail_tracking_email_stars branch August 8, 2016 08:26
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.

6 participants