콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
3386 화면

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

아바타
취소
관련 게시물 답글 화면 활동
2
7월 24
5561
1
7월 23
2198
1
4월 23
7525
1
1월 23
1734
0
9월 21
2051