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

[15.0] mail_tracking blocking adding email on contact when record w/o message_id & partner_id #1209

Closed
sckevin98 opened this issue Aug 28, 2023 · 3 comments
Labels
enhancement stale PR/Issue without recent activity, it'll be soon closed automatically.

Comments

@sckevin98
Copy link

Is your feature request related to a problem?
When sending out newsletter from our e-mail marketing module the mail_tracking records created do not have a message - or a partner_id. I am not exactly sure why, when trying to test we got always message_id false and since I do not have a test mail server I was not able to largly test it on a new newsletter campaign.
image

Anyways, since we do not need tracking for these mails I did not invest much more time on record creation issue. Now employees noticed when trying to add a Mail which is connected to the record with a non-admin user it is throwing error.
image

Describe the solution you'd like
To avoid it we added custom condition in your oca code in _find_allowed_tracking_ids(self): method line 169:
Old Code part:
if (x[1] in msg_ids) # We can read the linked message

New Code part:
if x[1] if (x[1] in msg_ids) # We can read the linked message

Now it's not blocking adding emails on contact where records without message and partner_id exist.

Describe alternatives you've considered
Is this a condition of mail_tracking records that is just not considered (not having a message_id and partner_id)? or is it wanted that for records without these id fields filled it throws error because it's cruical for tracking to work correctly.

Additional context
Maybe you know why these records get created without ID's? Otherwise I think this would be a great feature for emails people do not want to track, but still want to be able to avoid conflicts in other module (like contact).

Thank you in advance!

@pedrobaeza
Copy link
Member

There's mail_tracking_mass_mailing as glue module for that.

@sckevin98
Copy link
Author

Hi Pedro Baeza,
thank you for your quick answer!
I've installed the mail_tracking_mass_mailing module and tested my case again.
Created a test Newsletter with Mailing List recipients and tried to save the mail in an existing contact, but still get thrown the same error...

Mail-Tracking record:
image

Error when trying to save this mail in a existing contact:
image

Error Message:
RPC_ERROR
Odoo Server Error
Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/addons/base/models/ir_http.py", line 237, in _dispatch
result = request.dispatch()
File "/home/odoo/src/odoo/odoo/http.py", line 698, in dispatch
result = self._call_function(**self.params)
File "/home/odoo/src/odoo/odoo/http.py", line 368, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/service/model.py", line 94, in wrapper
return f(dbname, *args, **kwargs)
File "/home/odoo/src/odoo/odoo/http.py", line 357, in checked_call
result = self.endpoint(*a, **kw)
File "/home/odoo/src/odoo/odoo/http.py", line 921, in call
return self.method(*args, **kw)
File "/home/odoo/src/odoo/odoo/http.py", line 546, in response_wrap
response = f(*args, **kw)
File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1324, in call_kw
return self._call_kw(model, method, args, kwargs)
File "/home/odoo/src/odoo/addons/web/controllers/main.py", line 1316, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "/home/odoo/src/odoo/odoo/api.py", line 464, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "/home/odoo/src/odoo/odoo/api.py", line 451, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "/home/odoo/src/enterprise/payment_sepa_direct_debit/models/res_partner.py", line 20, in write
res = super().write(vals)
File "/home/odoo/src/user/custom-addons/source_view_extended/models/partner.py", line 43, in write
res = super(ResPartner, self).write(vals)
File "/home/odoo/src/odoo/addons/base_vat/models/res_partner.py", line 706, in write
return super(ResPartner, self).write(values)
File "/home/odoo/src/enterprise/sign/models/res_partner.py", line 36, in write
res = super(ResPartner, self).write(vals)
File "/home/odoo/src/odoo/addons/snailmail/models/res_partner.py", line 26, in write
return super(ResPartner, self).write(vals)
File "/home/odoo/src/odoo/addons/partner_autocomplete/models/res_partner.py", line 179, in write
res = super(ResPartner, self).write(values)
File "/home/odoo/src/odoo/addons/mail_plugin/models/res_partner.py", line 46, in write
res = super(ResPartner, self).write(vals)
File "/home/odoo/src/user/custom-addons/contact_link_automation/models/res_partner.py", line 130, in write
return super(ResPartner, self.with_context(
File "/home/odoo/src/user/third-party-addons/asterisk_plus/asterisk_plus/models/res_partner.py", line 78, in write
res = super(Partner, self).write(values)
File "/home/odoo/src/user/oca-addons/base_partner_sequence/models/partner.py", line 39, in write
super(ResPartner, partner).write(partner_vals)
File "/home/odoo/src/odoo/odoo/addons/base/models/res_partner.py", line 610, in write
result = result and super(Partner, self).write(vals)
File "/home/odoo/src/odoo/addons/mail/models/mail_activity_mixin.py", line 243, in write
return super(MailActivityMixin, self).write(vals)
File "/home/odoo/src/odoo/addons/mail/models/mail_thread.py", line 323, in write
result = super(MailThread, self).write(values)
File "/home/odoo/src/user/oca-addons/mail_tracking/models/mail_bounced_mixin.py", line 35, in write
vals["email_bounced"] = mte_obj.email_is_bounced(email)
File "/home/odoo/src/user/oca-addons/mail_tracking/models/mail_tracking_email.py", line 225, in email_is_bounced
res = self.sudo()._email_last_tracking_state(email)
File "/home/odoo/src/user/oca-addons/mail_tracking/models/mail_tracking_email.py", line 235, in _email_last_tracking_state
return self.search_read(
File "/home/odoo/src/odoo/odoo/models.py", line 5062, in search_read
records = self.search(domain or [], offset=offset, limit=limit, order=order)
File "/home/odoo/src/odoo/odoo/models.py", line 1814, in search
res = self._search(args, offset=offset, limit=limit, order=order, count=count)
File "/home/odoo/src/user/oca-addons/mail_tracking/models/mail_tracking_email.py", line 191, in _search
ids = self.browse(ids)._find_allowed_tracking_ids()
File "/home/odoo/src/user/oca-addons/mail_tracking/models/mail_tracking_email.py", line 166, in _find_allowed_tracking_ids
return [
File "/home/odoo/src/user/oca-addons/mail_tracking/models/mail_tracking_email.py", line 171, in
not any({x[1], x[2]}) and x[3] in partner_ids
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/odoo/src/odoo/odoo/http.py", line 654, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/odoo/src/odoo/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
IndexError: tuple index out of range

Is this normal behaviour records of newsletter when send to mailing list does not have message_id & partner_id?

Copy link

github-actions bot commented Mar 3, 2024

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Mar 3, 2024
@github-actions github-actions bot closed this as completed Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

No branches or pull requests

2 participants