-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
[18.0][MIG] partner_vat_unique: Migration to 18.0 #1906
base: 18.0
Are you sure you want to change the base?
Conversation
Currently translated at 100.0% (2 of 2 strings) Translation: partner-contact-12.0/partner-contact-12.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-12-0/partner-contact-12-0-partner_vat_unique/es/
Currently translated at 100.0% (2 of 2 strings) Translation: partner-contact-12.0/partner-contact-12.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-12-0/partner-contact-12-0-partner_vat_unique/it/
Currently translated at 100.0% (2 of 2 strings) Translation: partner-contact-12.0/partner-contact-12.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-12-0/partner-contact-12-0-partner_vat_unique/pt/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: partner-contact-13.0/partner-contact-13.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-partner_vat_unique/
Currently translated at 100.0% (4 of 4 strings) Translation: partner-contact-14.0/partner-contact-14.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-14-0/partner-contact-14-0-partner_vat_unique/es/
Currently translated at 100.0% (4 of 4 strings) Translation: partner-contact-16.0/partner-contact-16.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_vat_unique/de/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: partner-contact-16.0/partner-contact-16.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_vat_unique/
Currently translated at 100.0% (4 of 4 strings) Translation: partner-contact-16.0/partner-contact-16.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_vat_unique/hr/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate. Translation: partner-contact-16.0/partner-contact-16.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_vat_unique/
Currently translated at 100.0% (4 of 4 strings) Translation: partner-contact-16.0/partner-contact-16.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_vat_unique/es/
Currently translated at 100.0% (4 of 4 strings) Translation: partner-contact-16.0/partner-contact-16.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_vat_unique/pt/
Currently translated at 100.0% (4 of 4 strings) Translation: partner-contact-16.0/partner-contact-16.0-partner_vat_unique Translate-URL: https://translation.odoo-community.org/projects/partner-contact-16-0/partner-contact-16-0-partner_vat_unique/it/
/ocabot migration partner_vat_unique |
@@ -24,5 +24,6 @@ def _check_vat_unique(self): | |||
continue | |||
if record.same_vat_partner_id: | |||
raise ValidationError( | |||
_("The VAT %s already exists in another partner.") % record.vat | |||
self.env._("The VAT %s already exists in another partner.") |
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.
@lef-adhoc Please use translation function arguments instead.
self.env._("The VAT %(vat)s already exists in another partner.", vat=record.vat)
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.
Done!
for record in self: | ||
if record.parent_id or not record.vat: | ||
continue | ||
test_condition = config["test_enable"] and not self.env.context.get( |
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 is not really good practice. Instead, a configuration parameter is better to enable the constraint.
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.
Thanks for the feedback! Do you have an example of how to properly implement this with a configuration parameter?
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.
In ResConfigSettings model:
partner_vat_unique = fields.Boolean(
config_parameter="partner_vat_unique.partner_vat_unique',
help="Check this if you want to constrain VAT number to be unique"
)
Then, here, before the loop:
if self.env["ir.config_parameter"]
.sudo()
.get_param("partner_vat_unique.partner_vat_unique', 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.
Then, remove all things about test_enable.
And adapt tests accordingly.
Then, put that in a separate commit.
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’ve added a commit implementing the configuration parameter for the unique VAT constraint as you suggested. Could you please take a look and let me know if this approach works for you?
19a7fff
to
422297f
Compare
1fce377
to
3dcfa24
Compare
"test_vat" | ||
) | ||
if test_condition: | ||
if ( |
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 it outside the loop. If deactivated, don't enter in it at all.
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.
Done!
…constraint - Defined `partner_vat_unique` as a boolean configuration parameter. - Updated `res.partner` to validate VAT uniqueness based on this parameter. - Added a new section in ResConfigSettings for enabling/disabling the constraint. - Updated tests to include scenarios with the configuration parameter.
3dcfa24
to
1a7c237
Compare
No description provided.