Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
3419 Переглядів

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

Аватар
Відмінити
Автор Найкраща відповідь

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.

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
лип. 24
5587
1
лип. 23
2208
1
квіт. 23
7550
1
січ. 23
1744
0
вер. 21
2067