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] website_crm: contact us form create leads in wrong company #28738

Closed
wants to merge 1 commit into from

Conversation

Julien00859
Copy link
Member

In a mutli-company account with multiple websites for the
differents companies, the 'contact us' form creates leads in the
first company instead of the one linked to the website.

This PR corrects that behavior by setting a 'company_id' field
to the company_id of the user in case that field is missing.

opw-1907375

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

In a mutli-company account with multiple websites for the
differents companies, the 'contact us' form creates leads in the
first company instead of the one linked to the website.

This PR corrects that behavior by setting a 'company_id' field
to the company_id of the user in case that field is missing.

opw-1907375
Copy link
Contributor

@JKE-be JKE-be left a comment

Choose a reason for hiding this comment

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

Si tu pars sur une idée générique alors le code de insert_record doit se trouver dans website_form
et website_form doit avoir la methode _get_model_with_company() qui return []

et cette methode _get_model_with_company surchargée dans website_crm pour ajouter crm.lead a super()

Maintenant on sait que par convention, on nomme le champ company_id dans odoo, d'ailleur ligne 24 tu as bien laissé 'company_id'. Donc cette fonction ne sert plus a grand chose si on veut savoir si le model a un champ company, il suffit du coup de regarder s'il y a un field company_id sur le ir_model.

       model_name = model.sudo().model
  ==>  if 'company_id' in model_name and 'company_id' not in values:

Du coup on revient à la même question qu'il y a 1h ;)

Veut-on que company_id soit setté sur tous les models (et faire cette logique/magie de company_Id dans tous les modèles, ou seulement fixer le bug pour le cas d'un crm_lead et donc laisser le code dans website_crm sans la fonction _get_models_with_company?

IMO, un probleme de rendre ca générique, est qu'il ne sera plus possible du coup de générer des record non company_dependent. Alors que c'est souvent utiliser !
Par exemple, tu ne force pas le company_id sur product afin que tu puisse le vendre sous 2 compagnies différentes, ... Idem pour saleteam, ...

Donc je partirai plutot sur ta premiere idée de juste le faire pour le cas de crm.lead.
Et peut etre il faudra appliquer cette logique sur un deuxieme modele plus tard, mais ca sera du cas par cas.

@robodoo robodoo added the CI 🤖 Robodoo has seen passing statuses label Nov 15, 2018
Copy link
Contributor

@nim-odoo nim-odoo left a comment

Choose a reason for hiding this comment

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

Effectivement, tel quel le diff est "faussement générique". Je serais aussi d'avis de faire un cas particulier pour crm.lead, car remplir automatiquement ce champ sur d'autres modèles n'est pas forcément quelque chose qu'on veut systématiquement.

Copy link
Contributor

@nim-odoo nim-odoo left a comment

Choose a reason for hiding this comment

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

Mauvais bouton

@JKE-be
Copy link
Contributor

JKE-be commented Nov 15, 2018

et pour etre complet sur le message de commit:

he 'contact us' form creates leads in the first company instead of the one linked to the website.

Ce n'est pas vraiment "la première compagnie", mais la compagnie de l'admin car le insert est fait avec un sudo()

@xmo-odoo
Copy link
Collaborator

@Julien00859 you pushed the backing branch for this PR to odoo/odoo, would you mind closing the PR and remove the branch, and re-push it to odoo-dev?

@Julien00859 Julien00859 deleted the 12.0-opw-1907375-lead_multiple_sites-juc branch November 16, 2018 09:55
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants