8000 [FIX] base_vat: correct the check and the reference of Israeli VAT numbers by mathcoutant · Pull Request #172760 · odoo/odoo · GitHub
[go: up one dir, main page]

Skip to content

[FIX] base_vat: correct the check and the reference of Israeli VAT numbers #172760

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

Conversation

mathcoutant
Copy link
Contributor
@mathcoutant mathcoutant commented Jul 11, 2024

Issue:

The reference displayed when entering a non valid VAT number for Israel is incorrect. And the check used is not the right one.

Steps to reproduce:

  • In app Contact, create a new one
  • Select Israel as country and enter a non-valid VAT number
  • The default ref is displayed: 'CC##' (CC=Country Code, ##=VAT Number)
  • And the number 039225313 should be accepted

Cause:

he check used by the library stdnum is not up-to-date.
There is a PR to modify the library stdnum: https://github.com/arthurdejong/python-stdnum/ PR436 as the law has changed. Before only corporations could have a VAT number, now individuals can also have one.

Solution:

Use the right check (tdnum.il.idnr), which is available in the library stdnum.

opw-3954674

@robodoo
Copy link
Contributor
robodoo commented Jul 11, 2024

Pull request status dashboard

@mathcoutant mathcoutant force-pushed the 16.0-opw-3954674-add_vat_ref_for_israel-mcou branch from 2dc52b1 to 769f241 Compare July 11, 2024 11:41
@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jul 11, 2024
@mathcoutant mathcoutant force-pushed the 16.0-opw-3954674-add_vat_ref_for_israel-mcou branch from 769f241 to ea36b21 Compare July 11, 2024 15:30
Copy link
Contributor
@nle-odoo nle-odoo left a comment

Choose a reason for hiding this comment

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

looks good to me

side note: you should remove the direct link to https://github.com/arthurdejong/python-stdnum/pull/436 of the commit message (and PR message) so the PR outside of odoo repo doesn't get spammed by all the forward-port/PR/rebase and so on

you could do put it like arthurdejong/python-stdnum #436 or https://github.com/arthurdejong/python-stdnum/ PR436 I think

@mathcoutant mathcoutant force-pushed the 16.0-opw-3954674-add_vat_ref_for_israel-mcou branch from ea36b21 to 8ffb406 Compare July 12, 2024 07:09
@mathcoutant mathcoutant marked this pull request as ready for review July 12, 2024 08:36
@C3POdoo C3POdoo requested review from a team and alialfie and removed request for a team July 12, 2024 08:37
@mathcoutant mathcoutant changed the title [FIX] base_vat: display the reference of Israeli VAT numbers [FIX] base_vat: correct the check and the reference of Israeli VAT numbers Jul 12, 2024
Copy link
Contributor
@alialfie alialfie left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! I have one question though :)

Issue:
The reference displayed when entering a non valid VAT number for Israel is incorrect. And the check used is not the right one.

Steps to reproduce:
- In app Contact, create a new one
- Select Israel as country and enter a non valid VAT number
- The default ref is displayed: 'CC##' (CC=Country Code, ##=VAT Number)
- And the number 039225313 should be accepted

Cause:
The check used by the library stdnum is not up to date.
There is a PR to modify the library stdnum: https://github.com/arthurdejong/python-stdnum/ PR436 as the law has changed. Before only corporations could have a VAT number, now individuals can also have one.
The new regulations give different formats for comanies and individuals.

Solution:
Use the right check (tdnum.il.idnr) for individuals, which is available in the library stdnum.

opw-395467
@mathcoutant mathcoutant force-pushed the 16.0-opw-3954674-add_vat_ref_for_israel-mcou branch from 8ffb406 to 844b4f0 Compare July 16, 2024 15:24
Copy link
Contributor
@alialfie alialfie left a comment

Choose a reason for hiding this comment

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

Thanks for the modification!
LGTM @FlorianGilbert

@mathcoutant
Copy link
Contributor Author

@FlorianGilbert can you review please? A client is pushing to solve this as fast as possible.

@@ -820,6 +821,10 @@ def check_vat_de(self, vat):
is_valid_stnr = stdnum.util.get_cc_module("de", "stnr").is_valid
return is_valid_vat(vat) or is_valid_stnr(vat)

def check_vat_il(self, vat):
check_func = stdnum.util.get_cc_module('il', 'hp').is_valid if self.is_company else stdnum.util.get_cc_module('il', 'idnr').is_valid
Copy link
Contributor

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 we're doing that kind of stuff depending of if it's a company or not?
Couldn't we do the same than the fix in the module and always use idnr? 🤔

Is it for the check on the first digit?

Copy link
Contributor Author
@mathcoutant mathcoutant Jul 18, 2024

Choose a reason for hiding this comment

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

@FlorianGilbert The format is different if the contact is a company or not. The difference is only on the first digit, it must be a 5 for companies.
We could use only idnr but it would be more accurate to select the right one depending on if it is a company or not.

I agree it can be confusing for the users if the format is changing.
Tell me if you think I need to change and only use idnr.

Copy link
Contributor

Choose a reason for hiding this comment

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

@FlorianGilbert @mathcoutant I don't believe it is correct to access self.is_company here, as the function is called on potentially multiple partners in https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170

So either you'll need to override _run_vat_test or change the line above to work on partner and not self

Copy link
Contributor

Choose a reason for hiding this comment

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

@FlorianGilbert @mathcoutant I don't believe it is correct to access self.is_company here, as the function is called on potentially multiple partners in https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170

So either you'll need to override _run_vat_test or change the line above to work on partner and not self

Indeed, you're right, @mathcoutant may I ask you to fix it?
Thank you :)

Copy link
Contributor Author
@mathcoutant mathcoutant Jul 29, 2024

Choose a reason for hiding this comment

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

@FlorianGilbert I have looked into the proposed changes and changing partner to self seem to work.

But I also noticed that I forgot to add 'is_company' as constraint of check_vat with this PR, to check when only is_company is changed. But this change causes problem when changing both vat and is_company so I changed the write method to ensure that the check for the change of is_company is called after the one of vat. There may be a better way to do this...
There is the new PR: #174817

Can I have your opinion on this? Maybe the best solution is to only use idnr and remove the specific check for the company...

Copy link
Contributor

Choose a reason for hiding this comment

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

Hello @mathcoutant
As my first opinion on this PR was to only use idnr, let's change the code for that. I would prefer avoid adding a new constraint, etc etc.
Thank you, feel free to assign me as reviewer 😉

Copy link
Contributor
@FlorianGilbert FlorianGilbert left a comment

Choose a reason for hiding this comment

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

robodoo pushed a commit that referenced this pull request Jul 19, 2024
Issue:
The reference displayed when entering a non valid VAT number for Israel is incorrect. And the check used is not the right one.

Steps to reproduce:
- In app Contact, create a new one
- Select Israel as country and enter a non valid VAT number
- The default ref is displayed: 'CC##' (CC=Country Code, ##=VAT Number)
- And the number 039225313 should be accepted

Cause:
The check used by the library stdnum is not up to date.
There is a PR to modify the library stdnum: https://github.com/arthurdejong/python-stdnum/ PR436 as the law has changed. Before only corporations could have a VAT number, now individuals can also have one.
The new regulations give different formats for comanies and individuals.

Solution:
Use the right check (tdnum.il.idnr) for individuals, which is available in the library stdnum.

opw-395467

closes #172760

Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
@robodoo robodoo closed this Jul 19, 2024
mathcoutant added a commit to odoo-dev/odoo that referenced this pull request Jul 29, 2024
In this PR: odoo#172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674
robodoo pushed a commit that referenced this pull request Jul 30, 2024
In this PR: #172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

closes #174817

Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Jul 30, 2024
In this PR: odoo#172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

X-original-commit: dacabd6
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Jul 30, 2024
In this PR: odoo#172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

X-original-commit: dacabd6
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Jul 30, 2024
In this PR: odoo#172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

X-original-commit: dacabd6
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Jul 30, 2024
In this PR: odoo#172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

X-original-commit: dacabd6
fw-bot pushed a commit to odoo-dev/odoo that referenced this pull request Jul 30, 2024
In this PR: odoo#172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

X-original-commit: dacabd6
robodoo pushed a commit that referenced this pull request Jul 31, 2024
In this PR: #172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

closes #174947

X-original-commit: dacabd6
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Mathieu Coutant (mcou) <mcou@odoo.com>
robodoo pushed a commit that referenced this pull request Jul 31, 2024
In this PR: #172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

closes #174990

X-original-commit: dacabd6
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Mathieu Coutant (mcou) <mcou@odoo.com>
robodoo pushed a commit that referenced this pull request Jul 31, 2024
In this PR: #172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

closes #175006

X-original-commit: dacabd6
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Mathieu Coutant (mcou) <mcou@odoo.com>
robodoo pushed a commit that referenced this pull request Jul 31, 2024
In this PR: #172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

closes #175027

X-original-commit: dacabd6
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Mathieu Coutant (mcou) <mcou@odoo.com>
robodoo pushed a commit that referenced this pull request Jul 31, 2024
In this PR: #172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

closes #174971

X-original-commit: dacabd6
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Mathieu Coutant (mcou) <mcou@odoo.com>
@fw-bot fw-bot deleted the 16.0-opw-3954674-add_vat_ref_for_israel-mcou branch August 2, 2024 06:46
Dasanchez1992 pushed a commit to Nosolotec/odoo that referenced this pull request Aug 22, 2024
In this PR: odoo#172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

closes odoo#174947

X-original-commit: dacabd6
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Mathieu Coutant (mcou) <mcou@odoo.com>
riccardoSANEHO pushed a commit to resultrum/odoo that referenced this pull request Sep 30, 2024
In this PR: odoo#172760 the check_vat_il function is calling self.company.

It appears it was not a good idea and several things were not done well:
- It could lead to errors as run_vat_test can be called on multiple partners: https://github.com/odoo/odoo/blob/16.0/addons/base_vat/models/res_partner.py#L170.
- The previous PR is also checking the VAT number depending on the field is_company but did not put it as a constraint. This can be fixed, but with more changes than needed.

It has been decided to use the `` check for all Israeli VAT numbers, regardless of the partner type. With this change the VAT check for companies is not complete: it is not tested that they begin by a 5. But it is good enough.

opw-3954674

closes odoo#174947

X-original-commit: dacabd6
Signed-off-by: Florian Gilbert (flg) <flg@odoo.com>
Signed-off-by: Mathieu Coutant (mcou) <mcou@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0