Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3380 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 24
5554
1
thg 7 23
2190
1
thg 4 23
7517
1
thg 1 23
1732
0
thg 9 21
2044