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

feat: First step to the CRM integration #10340

Merged

Conversation

4nt0ineB
Copy link
Member

@4nt0ineB 4nt0ineB commented May 22, 2024

What

First step in integrating the CRM with the producer platform.

  • Added Odoo CRM credentials as environment variables.

  • An organization is 'unreviewed' by default and can be 'validated' or 'rejected'. The “scripts/migration/2024_06_org_validation_move_field.pl” script must be run to change the old value in the .sto of orgs.

  • When an org is validated, it is added to the CRM. Its creator is also added and linked to an opportunity. A strategy is put in place to avoid duplicates and associate them with entities already in the CRM.

  • A main contact has been added to the organization, being the person who will receive the emails and be the center of the workflow in the CRM. It can be modified in the pro platform.

  • Adding a contact to a validated organization in the pro platform adds it to CRM.

  • Updates the products last import and export date of the corresponding org in the CRM when performed from the producer platform.

Related issue(s) and discussion

@github-actions github-actions bot added 🧪 tests dependencies Pull requests that update a dependency file 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. config Minion file import multilingual products 🏭 Orgs 🌐 Translations labels May 22, 2024
@4nt0ineB 4nt0ineB changed the title First step to the CRM integration feat: First step to the CRM integration May 22, 2024
@codecov-commenter
Copy link

codecov-commenter commented May 22, 2024

Codecov Report

Attention: Patch coverage is 15.78947% with 192 lines in your changes missing coverage. Please review.

Project coverage is 49.48%. Comparing base (dc04d18) to head (4f879f6).
Report is 394 commits behind head on main.

Files Patch % Lines
lib/ProductOpener/CRM.pm 11.73% 156 Missing and 2 partials ⚠️
lib/ProductOpener/Orgs.pm 21.42% 32 Missing and 1 partial ⚠️
lib/ProductOpener/Producers.pm 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10340      +/-   ##
==========================================
- Coverage   49.54%   49.48%   -0.07%     
==========================================
  Files          67       75       +8     
  Lines       20650    21538     +888     
  Branches     4980     5159     +179     
==========================================
+ Hits        10231    10658     +427     
- Misses       9131     9578     +447     
- Partials     1288     1302      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label May 23, 2024
@github-actions github-actions bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label May 23, 2024
@@ -125,6 +126,8 @@

my $started_t = time();
my $import_id = $started_t;
# sync CRM
update_last_import_date($Org_id, $started_t);
Copy link
Contributor

Choose a reason for hiding this comment

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

We also have nightly imports through Equadis and Agena3000, they usually call import_csv_file.pl
See for instance https://github.com/openfoodfacts/openfoodfacts-server/blob/main/scripts/imports/agena3000/run_agena3000_import.sh
The issue is that they contain multiple organizations, so it would need to be done based on the organizations actually present in the updated products.

@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Jun 3, 2024
@4nt0ineB 4nt0ineB marked this pull request as ready for review June 5, 2024 10:13
@4nt0ineB 4nt0ineB requested a review from a team as a code owner June 5, 2024 10:13
@github-actions github-actions bot added 💥 Merge Conflicts 💥 Merge Conflicts and removed 💥 Merge Conflicts 💥 Merge Conflicts labels Jun 5, 2024
"members" : {
"tests" : 1
},
"name" : "Acme Inc.",
"org_id" : "acme-inc",
"protect_data" : "",
"valid_org" : "1",
"validated" : 0
"valid_org" : "1"
Copy link
Contributor

Choose a reason for hiding this comment

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

create_pro_user.t should be changed so that it does not send "1"

Copy link
Contributor

@stephanegigandet stephanegigandet left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you!

@github-actions github-actions bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Jun 6, 2024
Copy link

sonarcloud bot commented Jun 6, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@stephanegigandet stephanegigandet merged commit 4f5a945 into openfoodfacts:main Jun 12, 2024
13 checks passed
@4nt0ineB 4nt0ineB deleted the crm-integration-first-step branch July 12, 2024 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Data import dependencies Pull requests that update a dependency file file import Minion multilingual products 🏭 Orgs 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers Template::Toolkit The templating toolkit used by product opener. The starting point for HTML/JS/CSS fixes. 🧪 tests 🌐 Translations
Projects
Status: Done
3 participants