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

[MIG] base_vat_optional_vies: Migration to 10.0 #507

Merged
merged 6 commits into from Aug 8, 2017

Conversation

chienandalu
Copy link
Member

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

@chienandalu chienandalu force-pushed the 10.0-mig-base_vat_optional_vies branch 2 times, most recently from 2c962dc to 66d364d Compare June 30, 2017 07:17
@chienandalu chienandalu force-pushed the 10.0-mig-base_vat_optional_vies branch from 66d364d to 705f43d Compare June 30, 2017 17:56
vies_passed = fields.Boolean(
string="VIES validation passed", readonly=True)

def __init__(self, pool, cr):
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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'):
Copy link
Member

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...

@chienandalu
Copy link
Member Author

@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()
Copy link
Member

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.

@chienandalu
Copy link
Member Author

@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
It also avoids check on child contacts (wich I'm not sure if it's necessary/correct)

@pedrobaeza pedrobaeza force-pushed the 10.0-mig-base_vat_optional_vies branch from 180d9c0 to dddf0b1 Compare July 3, 2017 15:19
Copy link
Member

@luismontalba luismontalba left a comment

Choose a reason for hiding this comment

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

Tested on runbot

@pedrobaeza pedrobaeza merged commit fa28f5c into OCA:10.0 Aug 8, 2017
@pedrobaeza pedrobaeza deleted the 10.0-mig-base_vat_optional_vies branch August 8, 2017 13:52
@pedrobaeza pedrobaeza mentioned this pull request Aug 8, 2017
39 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants