-
-
Notifications
You must be signed in to change notification settings - Fork 845
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
[ADD] base_location_nuts addon #107
Conversation
'demo': [], | ||
'test': [], | ||
'installable': True, | ||
# 'auto_install':False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment code
overall cool stuff, not tested yet |
Good job thanks. Maybe res.partner.nuts could also be res.partner.nut |
@bealdav, NUTS is an acronym, not a plural: http://en.wikipedia.org/wiki/Nomenclature_of_Territorial_Units_for_Statistics, so it doesn't apply to remove the 's'. |
Oops, sorry for my lack of culture, never heard this term. It was not 🌰 then ... 😆 |
Runbot returns: |
@pedrobaeza I've already done in Antiun@1a3d11e |
|
Travis and runbot are ok, any other comments from reviewers? |
👍 |
any news? |
One hint and a conceptual question: |
class ResPartner(models.Model): | ||
_inherit = 'res.partner' | ||
|
||
region = fields.Many2one(comodel_name='res.partner.nuts', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we put domains for country_id on this fields?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This question is not asked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm testing to see if we can do what @hbrunn is asking. This configuration must be compatible with onchages defined in localizations addons (l10n_es_location_nuts, l10n_de_location_nuts, etc ...)
@hbrunn, thanks for your review:
The problem i couldn't fix is that Spanish translation sets labels according to Spanish nuts but what happens when user introduces a german address? Labels doesn't mean what data means. I don't know how to change labels/placeholder in on_change (v8 flavor) method, do you? |
you could have function fields that you use as labels (so you'll have to write the html code for the label yourself in the view). Then you wouldn't really need the localization modules, if you extend res.country with fields telling what level means what in the respective country, and if they apply at all. Based on that, you can hide the fields not relavant for the country selected |
@hbrunn sorry for my late answer and thanks for your review. I'm following your instructions to provide a correct label depending on partner country. In the other hand, we need localization modules for these reasons:
|
@hbrunn i've just finished the fix you commented. Now when country changes, labels changed dinamically, and localization addons can change labels properly. There are specific labels for each country, and each addon can translate them to each language. For testing, I recommend to install: |
9885d9e
to
fa33991
Compare
👍 |
Hi @OSguard @bealdav @pedrobaeza @hbrunn , please could you review this PR, changes are done from June and module it's working fine in production environment. Thanks |
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:alt: License: AGPL-3 | ||
|
||
NUTS Regions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put top line
I re-check for new conventions on README, and few remarks. Honor that remarks and answer the question from @hbrunn, and I'll merge it. |
lbl_substate = fields.Char(compute='_labels_get') | ||
|
||
@api.one | ||
@api.depends('country_id') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I don't understand the meaning of this api.depends
since your labels are computed by the translation tools.
Even if you change the country, your labels will stay the same since they depend of the language of the connected user. Maybe I miss something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lmignon each country define what 'region' and 'substate' fields mean. For example:
- Spain:
- substate = 'Autonomous Community'
- region = 'Region'
- Germany
- substate = 'Government region'
- region = 'District'
This depends on NUTS classification and which NUTS level is related with Odoo res.country.state. Each localization project (l10n-spain, l10n-germany, ...) creates their res.country.state objects
After this, you can translate labels, of course. For example, in spanish will be:
- España (Spain):
- substate = 'Comunidad autónoma'
- region = 'Región'
- Alemania (Germany)
- substate = 'Región de gobierno'
- region = 'Distrito'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what you will get is the same label for all customers, independently of their country. Ideally, you should get the correct label for the country language. This is similar to the address layout depending on the selected country.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, you have to see these other PRs to understand this:
- [ADD] l10n_es_location_nuts addon l10n-spain#150 :
l10n_es_location_nuts
addon setting labels for matching NUTS levels to spanish states defined byl10n_es_toponyms
addon - [ADD] l10n_de_location_nuts addon l10n-germany#11 :
l10n_de_location_nuts
addon setting labels for matching NUTS levels to german states defined byl10n_de_country_states
addon
This is not only country dependant, but also localization dependant, that's why this is not a country config parameter
@pedrobaeza, you'll will have diferent labels in different partners if country is different. In examples:
- Partner A: Germany country, labels 'Government region' and 'Region'
- Partner B: Spain country, labels 'Autonomous Community' and 'Region'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put a comment on the method then indicating that each localization module will inherit this method to add their specific labels.
2c0b1a0
to
573beb0
Compare
@pedrobaeza, remarks and version number fixed, squash and rebase. Thanks for your review |
This modules has been in customer's production environment for over 3 months. Tested! 👍 |
[ADD] base_location_nuts addon
NUTS Regions
This module allows to import NUTS locations.
Creates two new fields in Partner object:
calculated when state is selected
one from available for selected state
You need to install another addon (one for each country) in order to use
these NUTS, for example:
After installation, you must click at import wizard to populate NUTS items
in Odoo database in:
Sales > Configuration > Address Book > Import NUTS 2013
This wizard will download from Europe RAMON service the metadata to
build NUTS in Odoo. Each localization addon (l10n_es_location_nuts,
l10n_de_location_nuts, ...) will inherit this wizard and
relate each NUTS item with states. So if you install a new localization addon
you must re-build NUTS clicking this wizard again.
Only Administrator can manage NUTS list (it is not neccesary because
it is an European convention) but any registered user can read them,
in order to allow to assign them to partner object.