summaryrefslogtreecommitdiff
path: root/addons/base_vat/models
AgeCommit message (Collapse)Author
2021-04-09[FIX] base_vat: patch orm limitationoco-odoo
https://github.com/odoo/odoo/pull/68253 fixed a bug in check_vat that caused it not to run any check when called on a partner with no country. However, doing this caused another issue because of an ORM limitation: when writing vat and country_id with a single write() on the res.company, two distinct write are triggered on the related res.partner, one for each field. Both those write trigger the check_vat constraint. Depending on the order in which the keys of the dictionnary passed to res.company's write were ordered, country_id could or could not be written before vat. If vat was written first and did not start with a country code, the write() on res.partner failed the constraint, because country_id wasn't set yet. This was wrong, but used to pass as there was no country_id on the partner, before https://github.com/odoo/odoo/pull/68253 fixed that. To circumvent the issue, we now allow entering any vat number without performing any check if it does not start with a country code and no country_id is set on the partner. closes odoo/odoo#69034 X-original-commit: 3b73ea994a0eedc08ee0e7c43610ca5e78984b54 Signed-off-by: Laurent Smet <smetl@users.noreply.github.com> Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-04-02[FIX] base_vat: Don't always pass VAT check when validating the VAT of a ↵oco-odoo
partner without country_id Before this, when making a partner without any country_id, any VAT could be set to it, which was inconsistent with the module's purpose. closes odoo/odoo#68492 X-original-commit: 4c962437bd59a1e9302d8034e8870880994eb713 Related: odoo/enterprise#17358 Signed-off-by: Cedric Snauwaert (csn) <csn@openerp.com> Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
2021-03-08[FIX] base_vat: accept XI VAT formatAndrea Grazioso (agr-odoo)
Following Brexit on January 1st 2021, companies in Northern Ireland have a new VAT number starting with XI instead of GB. More info: https://www.gov.uk/government/publications/accounting-for-vat-on-goods-moving-between-great-britain-and-northern-ireland-from-1-january-2021/check-when-you-are-trading-under-the-northern-ireland-protocol-if-you-are-vat-registered-business stdnum support the new XI VAT from 1.16 https://github.com/arthurdejong/python-stdnum/commit/b93d69581f35aa18e7fdd52b3f7fdf06770215e3 This patch add temporary support in base_vat until the new version is available on the Debian package repository Community tracked issue https://github.com/odoo/odoo/issues/64891 opw-2461322 closes odoo/odoo#67402 X-original-commit: 049ea814283448e44e102969ffd08837f110e3ea Signed-off-by: William André (wan) <wan@odoo.com> Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2021-02-10[FIX] base_vat: not called at allwan
The function was wrongly imported and used, and it was hidden by a generic catching of all exceptions. The return value and some legit exceptions were also badly handled: * The return value was always thruthy as it returns an object containing information about the check. * Exceptions can be raised if the format is not correct. In that case, we don't want to go to the simple vat check. Fixes #64897 opw-2451951 closes odoo/odoo#65771 Signed-off-by: William André (wan) <wan@odoo.com>
2021-01-07[FIX] base_vat: fix ABN check for AustraliaAndrea Grazioso (agr-odoo)
The Australian equivalent of a VAT number is an ABN number. In Australia TFN are private and not meant to be entered into systems or publicly displayed. ABN numbers are the public facing number that legally must be displayed on all tax invoices and legal documents. This fix will override the 'tfn' check done via stdnum for AU companies with 'abn' check opw-2415142 closes odoo/odoo#64131 Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2020-10-12[FIX] base_vat: wrong example vatnumber for CHBaptiste Vergote
As described here: https://www.estv.admin.ch/estv/fr/home/mehrwertsteuer/fachinformationen/steuerpflicht/unternehmens-identifikationsnummer--uid-.html The "new" (since 2014) vat number has to be displayed as: CHE 9 numeric digits plus TVA/MWST/IVA e.g.: CHE-123.456.788 TVA This commit removes the previous 6 digits vat number check and regex, and provide accurate examples on the error message displayed if the vatnumber given is wrong. opw-2291581 closes odoo/odoo#59789 X-original-commit: 624e086f0c8ac854fd292d3c6dd14a71ed67b9fe Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-10-06[FIX] base_vat: check VAT numbers UAxxxNicolas Martinelli
- Go to the Contacts app - Click on the Azure Interior company, or any other company with multiple associated people - Set the country to Mexico - Edit the VAT field and enter the following string: UAC070620MB3 Traceback will happen after hitting save. It happens because `self` is a recordset in this case. Moreover, while the VAT number starts with `UA`, the country is Mexico so the check is incorrct. opw-2348045 closes odoo/odoo#59257 X-original-commit: 3dbdc62b3458e9af2e74d8552a17d629dc7e2393 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-08-17[IMP] base_vat: remove simple check vat for coNikunj Ladava
- removed simple check vat for columbia - removed document type field from partner - document type will be managed by latam type - updated city name for colombia - added data for for latam identification type - Added depdencies - base_address_city - account_debit_note - l10n_latam_base task- 2190843 closes odoo/odoo#53040 Related: odoo/upgrade#1589 Related: odoo/enterprise#9567 Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-08-06[FIX] base_vat: fixes format of Switzerland VATAnh Thao Pham (pta)
- Install Contacts and Belgium - Accounting (l10n_be) - Go to Contacts and create a new Contact: * Select Switzerland as Country * Enter "CHE-123.456.788 TVA" ad VAT The VAT is auto-updated to "CHE123456788TVA", removing all special characters. The entered VAT is converted to its minimal representation, stripping whitespaces and seperators. And it is this compacted value that is stored. As defined here (https://www.estv.admin.ch/estv/fr/home/mehrwertsteuer/fachinformationen/steuerpflicht/unternehmens-identifikationsnummer--uid-.html), the Swiss VAT format should be CHE-XXX.XXX.XXX TVA. Therefore, the VAT will be automatically formated to the official format. opw-2291581 closes odoo/odoo#55582 X-original-commit: d75614e22f5b0b72e6bebd9cafba36fe32b9eb51 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-06-18[IMP] *: use named placeholders in translated messageMartin Trigaux
When more than one parameter is present in a message, it helps the translation to use named placeholder. This way, the order can be changed. It also helps the comprehension of the message.
2020-06-15[IMP] base_vat: add example of Australian ABN for error msgwilliam
2020-06-15[FIX] base_vat: override vatnumber check for ua vatAndrea Grazioso (agr-odoo)
Create a contact: - Company - Country: Ukranian - VAT: UA1234567890 Error will raise because the VAT is detected as invalid. This occur because vatnumber package for Ukranian VAT check the length to be 8 while according to various sources [1][2] the number is - 12 for companies - 9 or 10 for individuals [1] https://vat.international/ukraine/ [2] https://interbuh.com.ua/ru/documents/oneanalytics/123926 opw-2266940 closes odoo/odoo#52956 X-original-commit: 0f4c3b6a9930614397c61cef8b138985f2e2b708 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-04-30[ADD] base_vat: add vat validation for indiaJigar Vaghela
closes odoo/odoo#48430 Related: odoo/upgrade#997 Related: odoo/enterprise#9500 Signed-off-by: Josse Colpaert <jco@openerp.com>
2020-04-27[IMP] *: create users and partners in batchVictor Feyens
The main classes of partners and users support batch creation, but the majority of their overrides doesn't support creation in batch. Adapting those overrides to support records creation in batch shows great performance gains: * On `res_partner` : 2 to 3 times faster * On `res_users`, with the inherited `res_partner` created in batch: up to 10 times faster. Tests done with 500 to 4k records: * `res_partner` with only a name provided * `res_users` with a name and login X-original-commit: 9c3c5f161580039c1fe50f68acac808c18817997
2020-04-14[FIX] base_vat: no vat check if multiple countriesalt-odoo
We should only check the consistency between the vat number and country code in case we have one country involved in the recordset. closes odoo/odoo#49530 X-original-commit: 23771ef7fcadfc0022d278c2e3436a7befc9e5b8 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-03-30[FIX] base_vat: skip compacting if not vat of the countryAndrea Grazioso (agr-odoo)
Create a new contact with: - Name [DEMO] - VAT RORO790707I47 - Country Mexico An error inform the user that the vat is not valid, this happens because the vat number is recognized as romanian and compacted before passing to actual vat checking. Skip the check if the country of the new partner does not match what is detected on the vat, assuming the user know what he/she is doing opw-2218491 closes odoo/odoo#48273 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-02-05[IMP] base_vat: replace vatnumver by stdnum library.Hardik Prajapati
Python module vatnumber doesn't seem maintained anymore. Therefore, we should: - call directly stdnum (which is maintained and mostly used everywhere in vatnumber) Also improve stdnum import, vat fix method and vat expected formats task-1915371 closes odoo/odoo#36978 Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2020-01-30[FIX] base_vat: cache VIES resultNicolas Martinelli
- Activate the VIES online check - Create a partner of type Company and add several contacts - Set the VAT number, save A call to VIES is done for each contact. The field VAT is propagated from the parent company to the children, triggering the check on all partners. This is not problematic for local checks since those are fast. However, online checks take time which can lead to a timeout of the request if there are many contacts. Since the check is triggered through a constraint (`check_vat`), only one record at a time is checked. Therefore, it is not possible to build a local list of the VAT numbers to avoid duplicated verifications inside a single transaction. The solution is to store the result in cache. Since the call to the external API may fail (e.g. timeout), we extract the check to store only the successful calls. Closes #43939 opw-2181744 closes odoo/odoo#44298 X-original-commit: 0c7a3e95df41d4e12c2c5913c2f39e46f96fe77c Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-01-09[FIX] base_vat: new dutch vat number verificationjerome hanke (jhk)
Steps to reproduce: - install contacts and vat number validation - setup your company country to "Netherlands" - go to contacts > add a company > try to add a dutch vat number (NL264077921B03) Previous behavior: Proper vat numbers are considered unvalid and raise a ValidationError Current behavior: Specific check added for dutch vat numbers Related: http://kleineondernemer.nl/index.php/nieuw-btw-identificatienummer-vanaf-1-januari-2020-voor-eenmanszaken https://business.gov.nl/regulation/using-checking-vat-numbers/ http://www.pruefziffernberechnung.de/U/USt-IdNr.shtml opw-2166380 closes odoo/odoo#43081 X-original-commit: b7a82684a311d736dfffd822c2fce8896104b96d Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Co-authored-by: Nicolas Martinelli <nim@odoo.com>
2019-10-16[FIX] l1n_pe: forward-port of fixes to l10n_pefw-bot
base_vat: Correct management of the check of peruvian VAT without prefix. l10n_pe: Correct income account the last one is not correct. l10n_pe: Forced Round globally for peruvian companies once l10n_pe is installed, and with the onchange. l10n_pe: For peruvian companies it does not make sense a sequence per year and the year in the prefix is incorrect, we must force XXX- as a sequence prefix. closes odoo/odoo#38854 Forward-port-of: #38764 Signed-off-by: Josse Colpaert <jco@openerp.com>
2019-08-21[MERGE] forward port branch saas-12.4 up to f26de445e55Christophe Simonis
2019-08-20[MERGE] forward port branch saas-12.3 up to 6f55fd65da8Christophe Simonis
2019-08-19[MERGE] forward port branch 12.0 up to 32039b2ab44Christophe Simonis
2019-07-26[ADD] base_vat: Add Argentinian vat validationKatherine Zaoral
closes odoo/odoo#35218 Signed-off-by: Josse Colpaert <jco@openerp.com>
2019-07-26[MERGE] forward port branch saas-12.3 up to 40e8b67179fChristophe Simonis
2019-07-16[FIX] base_vat: fix constrainsRomainLibert
The vat checking constrains uses both the country_id and the vat, but was defined as depending only on the vat field
2019-05-29[IMP] api.py: Rename company_id/company_ids into company/companiesYannick Tivisse
The goal is to be coherent with the user property. Actually, company_id and company_ids on the environment are no fields. Calling env.company_id returns a browse record, not an id.
2019-07-29[MERGE] forward port branch saas-12.4 up to cda4f3c308cChristophe Simonis
2019-07-17[REM] *: calls to @api.multiAdrian Torres
Multi is the default api for methods, it is not necessary to explicitly decorate methods with it, adds clutter and most people use it because they see that the rest of the code uses it. Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-05-13[IMP] base: Contextualize the multi companyYannick Tivisse
Purpose ======= Allow the user to select the allowed companies for which he wants to see records on top of selecting his current company. It is confusing for users to see the records from the company he is connected to and the records of the children companies. Instead of using the hierarchy of companies to access records across companies, the user can now select (from his set of allowed companies) the companies for which he wants to access records. /!\ This means that the user will interact with records from company A when in company B. Example: a SO has been created and confirmed in A. When in B, I create the invoice from it. Specifications ============== 1/ Deprecate the parent/children hierarchy on the res.company model. The fields are kept on the res.company model to ensure the retro-compatibility, but won't be used accross the standard code anymore. The only functional usage for this mechanism was to allow to see records from several companies by creating a virtual parent company, which will be possible with the new mechanism. 2/ By default, a user will only see the records of the company he is connected to (or records without a company). (It is still editable by the user if needed). For that, put this information in the user context, to allow having different configurations on different browser tabs. Instead of having domains like ['|', ('company_id', '=', False), ('company_id', 'child_of', user.company_id.id)] you'll have something like ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] Note that the 'company_ids' is a value that is passed in the evaluation context on the record rule, as we already have user, or time. company_ids is a list of the ids of all the enabled companies in the user's context. 3/ Out of the generic improvements brought by this task, this will illustrate issues that could exist since several versions. For example, it should not be possible to create a scrap order for the company A with a package of the company B, or it should not be possible to create an invoice on the company A with payment terms from the company B. Before the version 12.0, it was easy to encounter this kind of issues as the admin was the SUPERUSER_ID. A positive side effect of the fact that the SUPERUSER_ID has become an inactive user was to make it more difficult to introduce mismatch on the records, but haven't solved the issue, as it was still possible to do it with parent companies configuration. Some of these issues have been fixed in this commit, but all the business flows should be re-tested to check if an ir.rule should be introduced (eg: a multi company rule for stock.quand.package), if the company of a record is correctly transfered to another record created from the first record (eg: From a SO, create an invoice and a payment, the company of the sales order should be transfered on the invoice and the payment, even if the company of the sales order is A and I'm logged into the company B with the company A enabled. 4/ Currently, if I click on a button on a notification email (example 'View Task'), I face a traceback if I'm not logged into the company of the record. Now, if you click on a button and if you have access to the record, the correct company will be automatically set. 5/ If I display a kanban view with several records from several companies (and an image), all the images should be displayed. 6/ Currently if you copy paste an url, this will crash if you're not in the correct company. This won't be fixed because it's quite impossible to do it in a clean way. This task brings a workaround. Copy/Paste -> Traceback -> Log into the correct company, re-copy/paste -> Ok. 7/ 2 property methods have been added on the environment to retrieve the company on which the user is logged in and the companies the user enabled, on a specific tab. That way, when creating a record, instead of doing default=lambda self: self.env.user.company_id do default=lambda self: self.env.company_id On the other hand, to retrieve the enabled companies, do companies = self.env.company_ids 8/ Modify the Company Switcher widget to allow to log into another company WITHOUT writing on the res.users (and thus bringing cache invalidation issues and so on). Also allow to enable several companies and see records from several companies, and independantly of the other browser's tabs. 9/ When focusing on a tab, save the current company configuration on the local storage. That way, when doing 'CTRL+T' or a middle click, the context is propagated to the new tab. 10/ Improve the error message in case of multi company access errors. Now, when the user is in debug mode, display the related names of the records and the name of the user who brings the issue. 11/ Remove the context erasing when writing on a res.users This is probably coming from the migration to new API of the base module. The context was not propagated at this moment, which was a common mistake at that time. When migrating the module, probably by using the 'black box' method, as the context was not propagated, it was erased on the new version. This is now an issue because the context (i.e. the enabled companies) was erased when writing on a res.users, leading to tracebacks. See: https://github.com/odoo/odoo/commit/7eab8e26d3d46c53f4be924d6a34e80a66e74960#diff-4c2e738ee8f64f11806c889ea097b5e7R624 12/ Fix the crash manager on redirect warnings. The issue is the following - Create an invoice on a company without a configured CoA. - Set a partner - On the onchange_partner_id, a redirect warning is raised to propose you to configure a CoA - Click on 'Go to the configuration panel' - A generic warning says something like 'Do you want to discard your changes?' - Click on yes, the page refreshes, but not on the redirect action. Now, set correctly the action on the hash, and reload instead. The breadcrumb is lost for example, but you reach the correct action at least. 13/ Introduce a res.group to enable/disable the multi company per tab feature. 14/ To help the users to know which tab is in which company, add the possibility to have a favicon per company. When creating a company, the classical 'O' icon is colored by default in a random color. 15/ Remove the company switcher on the frontend. This was mainly there to allow a user to swicth to the company linked to the website. This behavior is now transparent to the user. If the website A is activated, then the company set on the context is the company of the website. 16/ Deprecated the _company_default_get method on the res.company model. Remove the method _get_company on the res.users model. 17/ Add 'allowed_company_ids' and 'current_company_id' on the pyeval context. You can now use those variables on domains in the views to access directly to the activated company.ies on the current tab. TaskID: 1960971 closes odoo/odoo#32341 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-02-07[FIX] base_vat: belgian vat number correct displayCedric Snauwaert
Odoo Accept the following mask for vat encoding : BE0477472701 BE.0.477.472.701 BE.477.472.701 BE477.472.701 BE477472701 But, in certain cases we have to add the zero to be compliance (i.e. belgian official reports...). -> http://www.tvaintracommunautaire.eu/belgique.html This commit make use of the compact method defined in stdnum.be.vat (which is used by vatnumber in order to validate the vat). The compact method return a 10 digits vat number starting with a 0 which is compliant with the official reports. closes odoo/odoo#28523
2019-08-07[FIX] base_vat: validation for Chile and ColombiaJigar Vaghela
Add validation using stdnum library since vatnumber is deprecated. closes odoo/odoo#35433 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2018-12-11[MERGE] forward port branch saas-11.3 up to 55dafc20f6bChristophe Simonis
2018-12-11[MERGE] forward port branch 11.0 up to 7e5d5045bfaChristophe Simonis
2018-12-11[MERGE] forward port branch saas-15 up to 1ace2ed88beChristophe Simonis
2018-12-11[MERGE] forward port branch 10.0 up to f69c004795eChristophe Simonis
2018-12-05[FIX] base_vat: AlbaniaNicolas Martinelli
The module `vatnumber` (which is not maintained anymore) uses an incorrect validation method for Albanian VAT numbers. Therefore, we use the library `stdnum`, on which `vatnumber` relies for most cases. opw-1912680 closes odoo/odoo#29280
2018-09-27[REF] *: adapt code to new related default behaviourAdrian Torres
This commit adapts the business code to changes introduced by the parent commit in order to keep the same behaviour as before. All readonly=False fields will have to be checked afterwards to confirm that the business case requires write access to the source field.
2018-01-07[IMP] Remove duplicate fields namesFabien Pinckaers
2017-10-20[MERGE] forward port branch saas-16 up to dc2a6c6cd2aChristophe Simonis
2017-10-20[MERGE] forward port branch saas-15 up to bee0c11ef7fChristophe Simonis
2017-10-19[MERGE] forward port branch 10.0 up to 9b4447e9aa5Christophe Simonis
2017-10-19[MERGE] forward port branch 9.0 up to 2deb95b8522Christophe Simonis
2017-09-15[MERGE] forward port branch saas-17 up to ed901bedcb7Christophe Simonis
2017-09-15[FIX] base_vat: Regex need 'br' insted only 'r' now on python3Nhomar Hernández [Vauxoo]
2017-09-13[MERGE] forward port branch saas-17 up to 1e17035f71fChristophe Simonis
2017-09-13[MERGE] forward port branch saas-16 up to 268cf9d04abChristophe Simonis
2017-09-13[MERGE] forward port branch saas-15 up to 127dea7f668Christophe Simonis
2017-09-13[MERGE] forward port branch 10.0 up to c8b5c013401Christophe Simonis
2017-09-12[FIX] account: mark as reconciledNicolas Martinelli
`last_time_entries_checked` is a commercial field, so bypassing the write won't sync it. Closes #19274 opw-770018