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

[16.0][MIG] l10n_eu_nace new ShowVoc integration #196

Merged
merged 45 commits into from
Apr 22, 2024

Conversation

edlopen
Copy link
Member

@edlopen edlopen commented Apr 15, 2024

Hello you all,

this is a migration and a refactor of the l10n_eu_nace module. Since the RAMON servers from we get te csv data are deprecated this PR contains the functionality to get the data directly from the new ShowVoc web catalogue in the format of a SPARQL endpoint. This get the industries and their translation by a API request and by running a simple wizard.

I would appreciate that this PR is merged rather quickly as it's my intention to migrate similar modules that relays on this new ShowVoc dataset.

Also I included this stale PR's commit.

@moduon MT-1816

@yajo @EmilioPascual @Shide @rafaelbn review this PR when you can.

Numerigraphe - Lionel Sausin and others added 30 commits October 28, 2023 12:01
Short category names are now displayed on partner views, since NACE names are so long
Data files were there, but translations were not.
[12.0][IMP] - Add unit tests

[IMP] - code improve

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/migrations/12.0.2.0.0/pre-migration.py

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/migrations/12.0.2.0.0/post-migration.py

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/models/res_partner_nace.py

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/models/res_partner_nace.py

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/models/res_partner_nace.py

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/models/res_partner_nace.py

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/models/res_partner.py

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/models/res_partner_nace.py

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/views/res_partner.xml

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/readme/CONTRIBUTORS.rst

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/models/res_partner_nace.py

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/models/res_partner_nace.py

Co-authored-by: Jairo Llopis <[email protected]>

[FIX] - fix code

Update l10n_eu_nace/models/res_partner_nace.py

Co-authored-by: Jairo Llopis <[email protected]>

[FIX] - Fix name_search
Fix post-migration

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/models/res_partner_nace.py

Co-authored-by: Jairo Llopis <[email protected]>

Update l10n_eu_nace/models/res_partner_nace.py

Co-authored-by: Jairo Llopis <[email protected]>
Some need to add secondary NACE codes to partners.

This is a very little addition, possibly quite standard, so it's done directly in the base addon.

@Tecnativa TT17678
FIX + IMP : more readable query for updating partners with new xml_id regarding old xml_id
@vincent-hatakeyama
Copy link

vincent-hatakeyama commented Apr 16, 2024

I’ve just tested the module.

The wizard need rework. There’s a save/discard button on the bottom and in the centre a big Import button. The import button need to replace the save button, and in the middle a text indicating what would happen would be best.

The import is fast. After import, the list of industries is not shown, so it feels like it did not work. I expected the list of industries to be shown again.

Importing again works as expected. If a language is added, the wizard needs to be run again. It should be indicated in the readme, or automatically done when a new language is activated.

I was also surprised that the module did not run the import during installation.

Odoo SA split the name and full name, only adding the code in the full name. I expected this module to do the same.

The list of industries is also strangely sorted, but I think that has nothing to do with this module.

Copy link

@EmilioPascual EmilioPascual left a comment

Choose a reason for hiding this comment

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

Thank you @edlopen for this pr. Some changes.

NACE Wizard. This will search for all active languages in Odoo and import the
data for each one.

1. Go to "Contacts" > "Configuration" > "Import NACE Wizard"

Choose a reason for hiding this comment

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

Suggested change
1. Go to "Contacts" > "Configuration" > "Import NACE Wizard"
1. Go to "Contacts" > "Configuration" > "Import NACE industries"

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

<form string="Import NACE industries">
<sheet>
<group>
<button

Choose a reason for hiding this comment

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

Maybe the button should be in the footer. Also, in the sheet it would be nice to put an informative text.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

bindings = nace_json.get("results", {}).get("bindings", {})
for binding in bindings:
nace_code = binding.get("code", {}).get("value", "")
nace_id = self.env["res.partner.industry"].search(

Choose a reason for hiding this comment

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

A search in a for can be a bottleneck. You could map them earlier.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! Thanks for your review @EmilioPascual

@aronabencherif
Copy link

@edlopen thanks already for this PR. I just reviewed all your code and I honestly admit that yours is much better. However, following the same logic as @vincent-hatakeyama, in Odoo's code base the full name is obtained by combining the code and the name. And what's more, once you have imported the data, you have the impression that nothing happens afterwards, no popup to explain that your code works perfectly 😀 and no list either to display the imported data. 👍

Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

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

Absolutely amazing!

Some comments though.

"depends": ["contacts"],
"maintainers": ["rafaelbn", "yajo", "edlopen"],
"depends": ["partner_industry_secondary"],
"external_dependencies": {"python": ["requests"]},
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: remove this implicit dependency, as Odoo 16 already requires it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

http://ec.europa.eu/eurostat/ramon/nomenclatures/index.cfm?TargetUrl=LST_CLS_DLD&StrNom=NACE_REV2&StrLanguageCode=FR&StrLayoutCode=#
If you want to import or update the data, you can do so by running the Import
NACE Wizard. This will search for all active languages in Odoo and import the
data for each one.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
data for each one.
data for each one. If you activate a new language, remember to run this wizard again.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

import_wizard = wizard.save()
return import_wizard

@users("test-manager")
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: You can remove this decorator, if you follow my suggestion above in setUpClass. The same applies for all other uses of @users

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.user = new_test_user(
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: change this to implicitly change the tests env from here onwards:

Suggested change
cls.user = new_test_user(
cls.uid = new_test_user(

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! Thanks for your review @yajo

@edlopen edlopen force-pushed the 16.0-mig-l10n_eu_nace branch from 9862788 to 83c94c1 Compare April 19, 2024 07:24
@edlopen edlopen force-pushed the 16.0-mig-l10n_eu_nace branch from 83c94c1 to 42e2788 Compare April 19, 2024 08:55
@edlopen
Copy link
Member Author

edlopen commented Apr 19, 2024

@vincent-hatakeyama @aronabencherif I've updated the wizard and now after installation the import wizard will appear. Also the names and full names are different, with the full names being the code and the nace name. Finally, after running the wizard, the industry tree view is displayed.

I hope this make the module more clear and easy to use. Thank you for your reviews!

Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

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

amazing

l10n_eu_nace/readme/USAGE.rst Outdated Show resolved Hide resolved
Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

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

Great job! Thank you!

@yajo yajo requested a review from EmilioPascual April 22, 2024 06:29
@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@yajo
Copy link
Member

yajo commented Apr 22, 2024

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-196-by-yajo-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit b961d29 into OCA:16.0 Apr 22, 2024
5 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 86a5f9a. Thanks a lot for contributing to OCA. ❤️

@yajo yajo deleted the 16.0-mig-l10n_eu_nace branch April 23, 2024 07:44
@edlopen
Copy link
Member Author

edlopen commented Apr 23, 2024

I forgot to add a migration script so that the data is not lost from the res.partner. Currently working to add it in a separate issue and PR.

Thank you all.

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.