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
[MIG] base_vat_optional_vies: Migration to 10.0 #507
[MIG] base_vat_optional_vies: Migration to 10.0 #507
Conversation
2c962dc
to
66d364d
Compare
66d364d
to
705f43d
Compare
vies_passed = fields.Boolean( | ||
string="VIES validation passed", readonly=True) | ||
|
||
def __init__(self, pool, cr): |
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.
Don't do this hack
@api.constrains('vat') | ||
def check_vat(self): | ||
for partner in self: | ||
if (not self.env.context.get('avoid_check_vat') and |
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.
Call super always. In this case, you can call it when VIES bypass is not activated. Put also a mechanism for avoiding this special check when on test mode and not testing specifically this module. Use a similar technique than https://github.com/OCA/bank-payment/blob/c5b093fb5ef1df31a699e49c90db646db115b44a/account_payment_transfer_reconcile_batch/models/payment_order.py#L28
return res | ||
|
||
# Delete old api constraint defined in base_vat addon | ||
@api.multi |
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 hack shouldn't be needed
self.assertEqual(self.partner.vat.upper(), res_vat) | ||
self.assertEqual(self.partner.vies_passed, res_vies) | ||
|
||
# AEA: Can't use this test in Travis, VIES checking returns always 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 this if not used, but try again to see. Maybe you can mock the call to VIES checking
@@ -99,7 +95,10 @@ def vies_vat_optional_check(self, country_code, vat_number): | |||
# Validate against VAT Information Exchange System (VIES) | |||
# see also http://ec.europa.eu/taxation_customs/vies/ | |||
vat = country_code + vat_number | |||
res = vatnumber.check_vies(vat) | |||
if not self.env.context.get('test_vies'): |
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.
You are ignoring config['test_enable'] as specified and still not calling super...
@pedrobaeza Yes, calling the super there required to make use of the base check methods. Wich is better and more simple anyway. Take a look now. |
for partner in self: | ||
if (not self.env.context.get('avoid_check_vat') and | ||
not partner.parent_id): | ||
super(ResPartner, partner).check_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.
I don't get why do you need to still overwrite this if you have already touched the other methods.
@pedrobaeza It avoids checking again vat here: https://github.com/Tecnativa/account-financial-tools/blob/180d9c01a3e0c57dd8b1495c4af5e20d4bb08940/base_vat_optional_vies/models/res_partner.py#L83 |
…ction to find parent function check_vat_'xx' instead of check_vat_'XX'
180d9c0
to
dddf0b1
Compare
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.
Tested on runbot
Optional validation of VAT via VIES
This module extends base_vat module features allowing to know if VIES
validation was passed or not.
cc @Tecnativa
Migrated from: #427