Skip to Content
Menu
This question has been flagged
2 Replies
2673 Views

Hi everyone,

I would like to know if someone can help me with the problem I have when trying to create clients using the odoo 14 api.

The problem I have is that I am importing the clients from my odoo 8 to my odoo 14 with a script, and everything is done fine, the only problem I have is in the VAT field, since it throws me an error that the number de vat seems to be invalid.
This validation is not from VIES (which I also have deactivated in the odoo settings), but it is a separate validation and I cannot deactivate it when creating clients.

I have tried many ways but none work for me. I have passed the "check_vat : False" variable in the context, but this does not work either and I no longer know how to solve this problem.


This is the code part 

models_target.execute_kw(            
​db_target,
​uid_target,
​password_target,
​'res.partner',
​'create',
​[{
​............ other fields ............
​'vat': client_old['vat'],
​}],
​{'context': {'check_vat': False},}       
)

Error:

The VAT number [........] for the partner [........] seems to be invalid. \nNote: the expected format is ESA12345674'


I hope someone can help me, thank you very much

Avatar
Discard
Author Best Answer

Thank you very much for the answer and the help, but I have tried to do what you indicate and it does not work either. It is about odoo 14, I don't know if you have been able to try it, it may not work. Could you try it and tell me if it works for you please?

I keep getting the same error.

This is the code part 

models_target.execute_kw(            
​db_target,
​uid_target,
​password_target,
​'res.partner',
​'create',
​[{
​............ other fields ............
​ ​'vat': client_old['vat'],​
​}],
​{'context': {'no_vat_validation': True},}       
)


Error:

The VAT number [........] for the partner [........] seems to be invalid. \nNote: the expected format is ESA12345674'

Greetings and I hope for some solution that can help me. Thank you.

Avatar
Discard
Best Answer

Hi,

In order to by pass the validation, you have to pass no_vat_validation as True in the context.

See this function in the code:

@api.constrains('vat', 'country_id')
def check_vat(self):
# The context key 'no_vat_validation' allows you to store/set a VAT number without doing validations.
# This is for API pushes from external platforms where you have no control over VAT numbers.
if self.env.context.get('no_vat_validation'):
return


Thanks

Avatar
Discard
Related Posts Replies Views Activity
2
Jul 24
5016
1
Jul 23
1550
1
Apr 23
6901
1
Jan 23
1179
0
Sep 21
1548