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

[FIX] mail: create partner from template in right company #30893

Closed
wants to merge 1 commit into from

Conversation

kebeclibre
Copy link
Contributor

Before this commit, when creating a partner automatically when creating
a message with a template, the company on the partner was wrongly set

After this commit, we try to retrieve the company from the model on the template

OPW 1934392

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

partner_id = self.env['res.partner'].find_or_create(mail)
Partner = self.env['res.partner']
if self.model and 'company_id' in self.env[self.model]._fields:
company_id = self.env[self.model].browse(res_id).company_id.id
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that by browsing then reading in a loop you will have a SELECT by res_id, it would be better to do that outside of the loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, put creation of Partner variable before the loop

@@ -26,6 +26,7 @@ class MailTestStandard(models.Model):
email_from = fields.Char()
user_id = fields.Many2one('res.users', 'Responsible', track_visibility='onchange')
umbrella_id = fields.Many2one('mail.test', track_visibility='onchange')
company_id = fields.Many2one('res.company')
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure there is no problem with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What could go wrong when adding a field in stable? ;)
It is tolerated in test-exclusive modules
I speak under the control of @KangOl

Copy link
Contributor

Choose a reason for hiding this comment

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

It's kinda tolerated for test_* modules if there is not other way...

Copy link
Contributor

Choose a reason for hiding this comment

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

Hacking a very nice test model in stable makes me very very sad.

I understand you don't really like me ...

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Feb 6, 2019
@robodoo robodoo added the CI 🤖 Robodoo has seen passing statuses label Feb 6, 2019
@tde-banana-odoo
Copy link
Contributor

Apart the loop thingy (as said by other smart people), LGTM ! Good work ! I won't say you are the best but you are probably not the worst.

@robodoo robodoo removed the CI 🤖 Robodoo has seen passing statuses label Feb 6, 2019
@kebeclibre
Copy link
Contributor Author

@tde-banana-odoo
@KangOl
@Xavier-Do
Et voilà ! changes made

@@ -385,12 +385,20 @@ def generate_recipients(self, results, res_ids):
results[res_id].pop('partner_to', None)
results[res_id].update(recipients)

records_company = None
if self.model and results and 'company_id' in self.env[self.model]._fields:
Copy link
Contributor

Choose a reason for hiding this comment

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

You could add a check on self._context.get('tpl_partners_only'):

Before this commit, when creating a partner automatically when creating
a message with a template, the company on the partner was wrongly set

After this commit, we try to retrieve the company from the model on the template

OPW 1934392
@robodoo robodoo added the CI 🤖 Robodoo has seen passing statuses label Feb 6, 2019
@kebeclibre
Copy link
Contributor Author

robodoo r+

@robodoo robodoo added the r+ 👌 label Feb 7, 2019
@robodoo
Copy link
Contributor

robodoo commented Feb 7, 2019

Linked pull request(s) odoo/enterprise#3575 not ready. Linked PRs are not staged until all of them are ready.

@robodoo
Copy link
Contributor

robodoo commented Feb 7, 2019

Merged, thanks!

@fw-bot fw-bot deleted the 12.0-helpdeskfromemail-lpe branch October 19, 2019 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI 🤖 Robodoo has seen passing statuses OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants