35 Commits
Author SHA1 Message Date
Antoine Dupuis (andu) 23064451d1 [FIX] web: Fix download.js handling of large content.
When handling a non-200 reponse with a large payload (>65536 bytes),
download.js fails to decode the payload properly on WebKit.

This is because the content is parsed using WebKit's
`DOMParser.parseFromString`, which creates several Text nodes if the
text would exceed 65536 bytes. Then, only the textContent of the second
Text node is passed to `JSON.parse()`, which fails because it is not
valid JSON.

See https://stackoverflow.com/questions/67738121/in-what-cases-do-browsers-create-multiple-adjacent-text-nodes/67774415#67774415
and https://github.com/WebKit/WebKit/blob/68ae0fde5f959e056fbd6700f1ca7fa652cd1ffa/Source/WebCore/html/parser/HTMLConstructionSite.cpp#L584-L592

closes odoo/odoo#160753

Taskid: 3790302
X-original-commit: a68348fd2b5141a410608016469ffabadc08d68d
Signed-off-by: Luca Vitali (luvi) <luvi@odoo.com>
2024-04-05 20:07:47 +00:00
Antoine Dupuis (andu) 294e0d7e2e [FIX] l10n_es: Fix equity account types
Accounts 10x -> 13x should be of 'equity' type.
(In the Balance Sheet, they are referenced under the Equity section.)

opw-3743637

closes odoo/odoo#160324

X-original-commit: cfb474a7081f5b123bf27a5234d2d11819f19011
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2024-04-03 20:38:20 +00:00
Antoine Dupuis (andu) 9d290e2b8c [FIX] l10n_pt: Minor fixes to CoA
In #87572, the CoA was refactored to follow the regulation for companies
under the general regime, which can be found at
https://www.occ.pt/fotos/editor2/taxonomiasplanocontas_fev2019.pdf

This commit fixes minor discrepancies between our version and the
published regulation.

taskid:3060790

closes odoo/odoo#157780

X-original-commit: 5625baa2dc2b078c6c534a9aa98f122e7f8f20dc
Related: odoo/enterprise#58709
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2024-03-15 17:30:00 +00:00
Antoine Dupuis (andu) 8cc4303347 [FIX] l10n_xx: Fix 16.2+ fw-port of #123816
Commit 14abe7acb11 (PR #123816) introduced default tax closing accounts
for localizations that were so far missing them. However, the mechanism
for specifying the default tax closing accounts changed in 16.2: they
must now be specified on the tax groups. This was not correctly done
in the fw-port, so we fix this in this commit.

closes odoo/odoo#155911

Taskid: 3524378
X-original-commit: f522550e083af22e63d219124273b47e0fcb7bbd
Signed-off-by: John Laterre (jol) <jol@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2024-02-29 20:40:36 +00:00
Antoine Dupuis (andu) 69d292fa2e [FIX] l10n_ch_hr_payroll_account: Fix employee cost account codes
In https://github.com/odoo/odoo/pull/105119, new accounts were added
to represent employee-related expenses. Based on the non-official
document https://swissdec.ch/document/share/295/4cc46aca-8b47-49e9-882a-03c37eb8dea3
we used account codes 2990 and 2999 for accounts 'Indemnities' and
'Company Car Correction'.

However, these accounts have no place with the equity accounts in 29xx,
since they are not equity but rather expense accounts. Examples of CoAs
that include employee indemnity accounts place them under account group
5 with the other employee-related expenses.

(e.g. https://plancompta.com/plan-comptable-suisse-pcg-2021/)

As such, we move accounts 2990 Indemnities -> 5840
and 2999 Company Car Correction -> 5031.

Fixing this in stable will not cause any in-database corruption, since
the updated code is only executed when the CoA is loaded/reloaded.
However, users will need to reload the CoA in order to take advantage
of the fix.

This also ensures that the Swiss Balance Sheet is balanced.

taskid:3060790

closes odoo/odoo#150692

Related: odoo/enterprise#54941
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2024-01-24 10:44:42 +00:00
Antoine Dupuis (andu) c0450feaa3 [REF] l10n_ec: Refactor _l10n_ec_get_identification_type
_l10n_ec_get_identification_type will get called quite often in a loop
in the ATS report, so it's important that it gets orm-cached. This
reimplementation removes calls to ref() and replaces them with calls
to _xmlid_to_res_model_res_id() which is entirely orm-cached.

closes odoo/odoo#147723

X-original-commit: f95540bb8b92e795b1331910049d0d6de7da120c
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-12-29 09:49:54 +00:00
Antoine Dupuis (andu) 79cf19dc3e [FIX] l10n_ro: Fix some account types.
4424 VAT to be recovered should be liability_current.
4426 VAT deductible should be asset_current.
4427 VAT collected should be liability_current.

closes odoo/odoo#146572

Taskid: 3634044
X-original-commit: 2581dda5217a6434cee529ed2ef144eb71fca467
Related: odoo/enterprise#52907
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-12-18 18:46:39 +00:00
Antoine Dupuis (andu) 4938d48d68 [FIX] l10n_it: VAT report: corrections to tax repartition lines
- refund tax repartition lines lack tax grids -> added
- Outgoing credit notes lack base line grids -> should decrease total
  active transactions -> added.
- Purchase taxes 0% G and 0% S should increase total passive
  transactions, not increase total active transactions -> fixed

closes odoo/odoo#145636

Taskid: 3175384
X-original-commit: 114a3e3c1587a057da96d4148d61416cfd434dac
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-12-11 14:46:52 +00:00
Antoine Dupuis (andu) 68a6db4f96 [MOV] l10n_de: Move code for setting default tags on accounts to l10n_de
Previously, the code that sets default tags on bank accounts was in
l10n_de_reports, so was not yet loaded when the demo company is created
at module init of l10n_de.

As a result, the demo company was created without the necessary tags
on the 1001 Cash and 1201 Bank accounts, which meant that the Balance
Sheet would not be impacted by these accounts on the demo company.

This commit fixes this.

taskid:none

closes odoo/odoo#145357

X-original-commit: 70c3cf2fa31fca3fea93d8623dc38cad0d048450
Related: odoo/enterprise#52302
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-12-07 18:35:51 +00:00
Antoine Dupuis (andu) 64e45fe1f1 [IMP] l10n_mn: Convert VAT report to use tax_tags engine
- Moved VAT report to Community repo
- Re-numbered XMLids of the report lines so that they correspond to the
  tag names
- Changed the tax repartition line templates to use the new tax tags
  defined in the VAT report
- Removed the obsolete tax tags and account tags

closes odoo/odoo#134590

Related: odoo/enterprise#47033
Related: odoo/upgrade#5122
Signed-off-by: Olivier Colson (oco) <oco@odoo.com>
2023-10-12 09:49:42 +00:00
Antoine Dupuis (andu) dc3a0994b4 [FIX] l10n_br: Make sure credit notes use same sequence as invoices
Bugfix.
Steps to reproduce:
1. Create a fresh DB with the Brazilian localization.
2. Create a new Credit Note (directly from the menu, not from an
   invoice). Confirm.
3. Observe that you get a ValidationError: "Another entry with the same
   name already exists." because the name of the Credit Note is
   NFe 00000001, and an invoice called NFe 00000001 already exists.

Analysis:
The credit note should be called NFe 00000002, because in Brazil the
same sequences should be used both for invoices and for credit notes of
a given document type.
However, because the `refund_sequence` field is set to True on the
'Customer Invoices' journal, the sequence mixin doesn't consider
invoices and credit notes as using the same sequence, and therefore
doesn't consider the existing invoice when finding a new name for the
credit note.

Solution:
Set the field `refund_sequence` to False on the journal created by the
l10n_br template.
We also take the opportunity to move the code that provides a default
name to the demo invoices to a separate file demo/account_demo.py, for
consistency with other localizations.

closes odoo/odoo#137700

Signed-off-by: Josse Colpaert <jco@odoo.com>
2023-10-06 06:14:09 +00:00
Antoine Dupuis (andu) b206a848db [FIX] l10n_tr: Account 103 should have asset_current type
Source: official Turkish CoA
https://www.gib.gov.tr/fileadmin/mevzuatek/eski/muhsisteb1ekmuh5b.htm

taskid:3493555

closes odoo/odoo#136847

X-original-commit: 1c1b464f216d44c96c01d54de99e0e5c0b3e7ccc
Related: odoo/enterprise#48025
Signed-off-by: Laurent Smet (las) <las@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-09-28 04:17:25 +00:00
Antoine Dupuis (andu) bfaccfcdae [IMP] l10n_ro: Minor changes for l10n_ro_saft
For the l10n_ro_saft module that generates the D.406 declaration, we
needed to:
- create a new export tax specifically for services (which should be
  reported separately from goods); and
- make sure the Bank, Outstanding Receipts and Outstanding Payments
  accounts are created with codes 5121xx, and the Cash account with code
  5311xx, because codes 5120 and 5130 are not available in the official
  CoA and were therefore causing validation errors in the SAF-T export.
- because the CUI number (found in the company_registry field) for
  partners is required for the SAF-T export, and it is substantially
  the same as the VAT number, re-use logic from l10n_be to automatically
  fill in the company_registry if the VAT exists.

closes odoo/odoo#132269

Task-id: 3172198
X-original-commit: 74be0779164f8cd65c399977d5f3e058c213318d
Related: odoo/enterprise#45939
Related: odoo/documentation#5532
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-08-21 19:57:11 +02:00
Antoine Dupuis (andu) daacd9adc0 [FIX] l10n_eu_oss: Create OSS account with correct tags
Bugfix. When installing l10n_eu_oss with l10n_de_skr03, an OSS account
'17010 Unsatzsteuer 19% OSS' is created. However, this account has
no account tags set on it, so it gets left out from the Balance Sheet
report. (Note that in Germany, due to there being two CoAs, the Balance
Sheet report still works using account tags.)

The solution: when creating the OSS account, re-use the account tags
of the account we are copying.

closes odoo/odoo#130287

X-original-commit: f541ef903085ed95b0aa0bc6d3e82bf9efa2a23d
Signed-off-by: John Laterre (jol) <jol@odoo.com>
2023-08-02 01:15:53 +02:00
Antoine Dupuis (andu) 73fab18182 [IMP] l10n_it_edi: Add a test for credit note XML export.
At the moment, there is no test that checks that normal credit notes
(i.e. of type TD04, not reverse-charge refunds) are correctly exported
in FatturaPA.

So we're adding one. We're making it a complicated credit note (it
contains some negative amounts) in order to improve the test coverage.

closes odoo/odoo#125690

X-original-commit: f7f2c4275531751253e0fe57a6a192fe98d6da5c
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-06-20 15:58:26 +02:00
Antoine Dupuis (andu) c31beb459d [FIX] tools: Improve docstring of load_xsd_files_from_url()
This is to clarify that the file_name param is not used if a ZIP is
downloaded: in that case, the filenames in the ZIP are used to save
the attachment.

See discussion in https://github.com/odoo/odoo/pull/115720#pullrequestreview-1392562860

closes odoo/odoo#124946

X-original-commit: ae94f14a844352f66490ec326fe2d1a716023891
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-06-14 10:54:47 +02:00
Antoine Dupuis (andu) 9f9a0ee7dd [FIX] l10n_it: Remove accounts 71 and 72 from the CoA.
Since the coming into force on 01/01/2016 of Legislative Decree 139/2015
implementing EU Directive 2013/34/EU, extraordinary gains and losses
should no longer be accounted separately on the P&L statement.

See this article https://www.fisco7.it/2017/02/come-ricollocare-nel-conto-economico-gli-abrogati-oneri-e-proventi-straordinari/

There is therefore no point in having special accounts for
extraordinary gains and losses.

So we are removing accounts 71 and 72, both from the CoA and from the
Profit and Loss accounts.

Since they should no longer be used since 2016, this should not have any
impact for existing users.

closes odoo/odoo#122990

X-original-commit: 19cd212f762afdc906aa9f41793cc5c1fa9ea828
Related: odoo/enterprise#41687
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-05-31 13:08:16 +02:00
Antoine Dupuis (andu) 6179727d5c [FIX] account: automatic entry wizard: avoid clashes with lock dates
Currently, if you use the automatic entry wizard to change the period of
a journal item dated prior to the lock date, you'll just get blocked
with a UserError, with no workaround.

This commit changes the date of the adjustment entry to be the first end
of month after the lock date. As a result, the adjustment entry can be
created.

Based on PR #92439

closes odoo/odoo#122997

Taskid: 2823170
X-original-commit: fdeaff0a879bdf1242ed0a8d85e3e0363dd3276b
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2023-05-31 10:32:14 +02:00
Antoine Dupuis (andu) 3469537d51 [REF] account: Vendor Bills: Refactor the lock date message
At the moment, the lock date message is generated in
_compute_tax_lock_date_message. We delegate it to a separate function
in order to use this message elsewhere as well.

Note: this refactor introduces minor changes in behaviour:
- we remove the second part of the lock date message (that mentions
  other lock dates than the most blocking one), because it is too much
  information.

- we calculate the new accounting date from the existing accounting date
  rather than from the existing invoice date. This should not change
  anything in practice, since the new accounting date will be the last
  day of the period after the lock date.

task-2823170

X-original-commit: aeb6707dfc0f4aa093d7687bbb0e488558d2a99f
Part-of: odoo/odoo#122997
2023-05-31 10:32:13 +02:00
Antoine Dupuis (andu) 25cfb97f7e [FIX] l10n_it_edi: Generate correct XML for negative invoice lines
When creating an invoice with a positive line and a negative line, with
different taxes, the DatiRiepilogo node for the tax of the negative
line contained positive amounts when they should be negative.

This is because we were applying `abs()` too naively in the XML template
and in the code of _l10n_it_edi_prepare_fatturapa_tax_details.

This bugfix commit changes the logic to no longer use abs().

opw-3316300

closes odoo/odoo#122982

X-original-commit: 0241e96fe12401f0891efc00f840e03d0c0219fd
Signed-off-by: Quentin De Paoli <qdp@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-05-30 23:51:41 +02:00
Antoine Dupuis (andu) 055269cc4e [ADD] l10n_lv: Latvian localization
Based on Allegro-IT's PR https://github.com/odoo/odoo/pull/112159
with several adjustments and fixes (renamed XMLIDs, taxes, fiscal
positions, VAT report).

closes odoo/odoo#121073

X-original-commit: 815a817ff53760d57f978fd88b529a8b38bda62d
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-05-10 21:18:26 +02:00
Antoine Dupuis (andu) 6e30206fdb [FIX] account: Correctly translate terms when loading CoA
Bugfix: at the moment, if the environment's language is not en_US,
loading a CoA doesn't correctly load the translations: the translations
for all languages are created with the en_US terms.

Steps to reproduce:
1. Create a DB and install l10n_be.
2. Switch to French.
2. Create a new company based in Belgium.
3. Install the Belgian CoA on the company.

Expected behaviour: The accounts should be in French.
Actual behaviour: The French translation of the accounts contains
the terms in English.

Analysis:
When the records are created by _load_records(), the language of the
environment is French. As a result, all translatable terms are created
with translations in en_US and in fr_FR.
See https://github.com/odoo/odoo/blob/39292a02ab34ea86abd5601055901eb968006944/odoo/fields.py#L1762-L1771

Later on, when the translations are loaded by _load_translations,
there already exists a name->'fr_FR', so our call to
translation_importer.save(overwrite=False) doesn't want to overwrite it.
See https://github.com/odoo/odoo/blob/2780c37cfdb8560ac7c725fd27f4fe272f1d3072/addons/account/models/chart_template.py#L787

As a result, we end up with the English terms in both the en_US and
fr_FR translations.

The fix:
Set the language to en_US when calling _load_records().

closes odoo/odoo#120863

X-original-commit: 52ef69aa8423a0fd5d78af1ab018a98dba87361c
Signed-off-by: William André (wan) <wan@odoo.com>
2023-05-09 11:57:39 +02:00
Antoine Dupuis (andu) 33a9db123a [FIX] tools: XSD: handle ZIP files with URL not ending in .zip
In the case of the Basque country EDI, the ZIP archive containing the
XSD files is located at
https://www.gipuzkoa.eus/documents/2456431/13761107/Esquemas+de+archivos+XSD+de+env%C3%ADo+y+anulaci%C3%B3n+de+factura_1_2.zip/2d116f8e-4d3a-bff0-7b03-df1cbb07ec52
which does not end in .zip due to the hash at the end.

The current mechanism for detecting whether the file is an XSD or a ZIP
does not handle this, so the ZIP can't be downloaded.

Instead of trying to guess the file type from the URL, we therefore try
to open the file as a ZIP, and if that fails, we assume it's an XSD.

closes odoo/odoo#118933

X-original-commit: 0f1b128a8bcb01ecd5ca8a8db1dfa41230ecadda
Signed-off-by: Josse Colpaert <jco@odoo.com>
2023-04-18 19:29:08 +02:00
Antoine Dupuis (andu) d1834758ea [IMP] tools, account: remove XSD crons; download XSD button
At the moment, XSD files are automatically downloaded at database
initialization, which is quite unnecessary.

The idea is to change Odoo's use of XSDs from being systematically
downloaded and used for validation to simply being available if desired
(e.g. for development or for customers who want them).

To achieve this, this commit does the following:

- remove the XSD download crons;
- provide a 'download XSDs' button in the Settings (next to the debug
  mode button) which is available in debug mode;
- skip XSD validation if any required XSD file is not present; and
- deprecate the 'force_reload' option.

Entreprise PR: odoo/enterprise#38350
Task id: 3010716

closes odoo/odoo#118790

X-original-commit: c8174c7914e567489de74b574b076467440bdb2d
Related: odoo/enterprise#39879
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-04-17 18:01:18 +02:00
Antoine Dupuis (andu) cfb84de489 [FIX] account: Avoid ir_module.account_templates compute error
Issue / How to reproduce:

At the moment, if a localization's python module is not present,
the computation of the `ir.module.module.account_templates` field fails
with a ModuleNotFoundError

How to reproduce:
- Create a fresh DB with a localization e.g. l10n_be
- Remove the localization directory
- Start the DB again and navigate e.g. to Inventory > Configuration >
  Settings. You will see a traceback, whose root cause is that the
  computation of the `account_templates` field failed.

We noticed this in a runbot upgrade between 16.1 and 16.2, for a new
localization that was introduced in 16.0.

Solution:

Make the computation return False if the Python module cannot be found.
Also, filter out the modules where account_templates is False when
constructing the list of available chart templates.

closes odoo/odoo#113875

Signed-off-by: William André (wan) <wan@odoo.com>
2023-02-28 23:49:47 +01:00
Antoine Dupuis (andu) bc1c00b84b [FIX] l10n_bo: include account groups in __manifest__
Unfortunately, when I wrote the loc, I forgot to include
`account.group.template.csv` in `__manifest__.py`.

As such, the account groups were not loaded, and I didn't notice an
error in the chart template name.

Thanks to WAN for finding this.

closes odoo/odoo#110890

X-original-commit: 7610f1ef5f329a52ee16fe88909be30ddf395b8d
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-01-24 23:21:52 +01:00
Antoine Dupuis (andu) 1e3c1726e8 [IMP] l10n_bo: Bolivian loc (bring up-to-date)
closes odoo/odoo#110696

X-original-commit: c6984459dc50e08037d9ef514f7fc5d9aea30640
Related: odoo/enterprise#36152
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2023-01-23 20:27:05 +01:00
Antoine Dupuis (andu) d76e3bb82e [IMP] account: Change 'Miscellaneous' menu to 'Journals'
In Odoo 16, we redesigned the `Accounting > Miscellaneous` menu to
provide a convenient interface for inspecting any journal entry or
journal item.

As such, it no longer makes sense to call it 'Miscellaneous'.

This commit aligns the name with the new functionality.

We also remove the default filter of the 'Journal Entries' view, which
restricted it to miscellaneous entries, and replace it with a filter
on posted entries, consistent with the purpose of conveniently
inspecting the accounting journals.

closes odoo/odoo#106749

Task: 3083921
X-original-commit: ee551d74557b889a463bd7dff234ff5f12539e4a
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
2022-11-28 20:50:25 +01:00
Antoine Dupuis (andu) 67a383a13d [FIX] account: Deferred income wiz - don't reconcile draft entries
When creating draft deferred entries in a reconcilable account,
we should not attempt to reconcile them, because only posted entries
can be reconciled.

closes odoo/odoo#106603

X-original-commit: edaf019eac9124cb64c0a1dce55291d40b542256
Signed-off-by: William André (wan) <wan@odoo.com>
2022-11-25 23:15:18 +01:00
Antoine Dupuis 5a09449ddc [FIX] tools: fix filename resolution in XSD imports
With PRs odoo/89145 and enterprise/26393 came new methods for
retrieving XSD files and using them for XML validation.

The new retrieval method expects modules to provide a 'prefix' that
is prepended to the XSD's filename. For example, l10n_cl_edi will
name its XSD files 'l10n_cl_edi.<filename>.xsd'.

However, this messes things up when one XSD file needs to import
another. For example, l10n_cl_edi.DTE_v10.xsd has the statement
'<xs:include schemaLocation="SiiTypes_v10.xsd"/>'

Currently, the filename resolver has no way of knowing that this
should resolve to 'l10n_cl_edi.SiiTypes_v10.xsd', not
'SiiTypes_v10.xsd'.

In addition, the new retrieval method saves the ZIP archives
received over the network under the '<filename.xsd>'. Thus
'SiiTypes_v10.xsd' might actually be a ZIP-encoded file.

So, we need to do something to fix the imports.
Here are two possible solutions:
1. We scrap this 'prefix' stuff and either save the ZIP files under
   a different name, or we just don't save them.
2. Or, we provide a mechanism for indicating a prefix to the filename
   resolver.

Personally, I don't see the point in saving the ZIP files, and this
'prefix' stuff seems pointless. So I prefer solution 1.

But, because I assume there must be a reason to all of that 'prefix'
stuff, here is an implementation of solution 2.

I'd be keen to know the reason, btw.

EDIT:
In addition to the first issue described above, we have the second
issue that some XSD files returned by the Chilean SII are encoded
using ISO-8859-1 encoding (e.g. SiiTypes_v10.xsd). If we leave them
in this encoding, then LXML isn't able to parse them when performing
imports.

closes odoo/odoo#102601

Solution: convert the files to UTF-8 before storing them.
X-original-commit: 75555df56475b457331938453657c1f73d231e33
Related: odoo/enterprise#32482
Signed-off-by: Josse Colpaert <jco@odoo.com>
2022-10-07 14:37:14 +02:00
Antoine Dupuis (andu) 0c50be8130 [FIX] website: fix conditional visibility based on file upload
At the moment, if we try to make a website field conditionally visible
based on whether a file has been uploaded, the field never appears even
after uploading the file.

Steps to reproduce issue
- Create a new fresh DB with the website app.
- Go to the Contact Us page, click on 'Edit'.
- Add a File Upload field
- Add another field, and set it to be conditionally visible on the
  File Upload field.

Fix:
- Create visibility comparators for files (fileSet / !fileSet), which
check whether the `value.name` property is set / not set.

opw-2856054

closes odoo/odoo#93756

X-original-commit: fec02f6cfc4abd68f0d6bd49285580510fe59465
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2022-06-16 17:26:59 +02:00
Antoine Dupuis (andu) 7cb109e7b0 [FIX] account: fix write-after-post in PR 91638
PR 91638 introduced a write() on the partner_id  after the AML state
was set to 'posted'.

This causes a problem for users who have the journal hash activated.

Fix => move the write() before posting the AMLs.

closes odoo/odoo#91997

X-original-commit: cd3bbeb15983b263ba2ffb419d59575b64a41ca2
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2022-05-23 09:57:42 +02:00
Antoine Dupuis (andu) fc1f3476d4 [FIX] account_edi - revert to using AccountTax._compute_all to
compute tax amounts corresponding to each invoice line in the edi
document for the invoice.

The issue
In Mexico, companies are required to send every invoice in electronic
format to the government. This document (called the CFDI) specifies,
for each invoice line, the taxes applicable, the amount before tax
and the tax amount. The document also specifies the total amounts
withheld for each tax which was applicable to the invoice.

The PAC (the external service which signs this electronic document
and sends it to the government) does checks on those amounts. In
particular, the tax amounts must satisfy two constraints to pass
validation:

(1) The total tax amount for a tax must be equal to the sum of the
tax amounts reported for each invoice line.
(2) The tax amount reported for each line must be equal to
(tax rate * base amount), rounded either up or down. For example, for
a line with base = MXN 398.28 and an applicable VAT of 16%, the
exact tax amount would be 0.16 * 398.28 = 63.7248, so the acceptable
values for the tax amount on that line are 63.72 and 63.73.

In v14, we used the AccountTax.compute_all method to compute the tax
amounts reported for each invoice line. This gave the exact tax
amount, rounded (either up or down depending on which side of 0.5 it
is). This always fulfils condition (2) but fulfils condition (1)
only if the tax rounding method is 'Round Locally'. Because of this,
in v14 MX users couldn't use 'Round Globally'.

In v15, we use a new SQL-based method to compute the tax amount
reported for each invoice line: we take the total tax amount, and
allocate it among the invoice lines proportionately to the base
amount of the invoice line. This always fulfils condition (1) but
sometimes doesn't fulfil condition (2). This has caused many issues
in customer DBs (see list of tickets at the end).

This was introduced in commit 433656415a and seems to be an issue
for all MX customers who have upgraded to v15.

The solution
@smetl and I have looked into what can be done about this.

Modifying the tax amount computation method in a way which satisfies
both conditions is possible, but requires more work and testing.

The existing v14 code generates tax amounts which satisfy both
conditions, at least when the tax computation method is
'Round Locally'.

A good temporary solution, while we try to modify the tax amount
computation to satisfy both conditions, would therefore be to use
the v14 tax amount computation when the tax rounding method is
'Round Locally'. While not ideal, this will at least enable
customers with the 'Round Locally' rounding method to correctly
submit their invoices to the government. Customers with the
'Round Globally' method will need to wait for the full fix.

This commit does exactly that.

Tickets linked to this problem (non-exhaustive list):
opw-2695243
opw-2733280
opw-2723571
opw-2724805
opw-2722370
opw-2722388

closes odoo/odoo#85407

X-original-commit: cddb5bc3af4806c7d1b9b09d07a5b9361d2815c0
Related: odoo/enterprise#24767
Signed-off-by: Laurent Smet <las@odoo.com>
2022-02-28 10:14:55 +00:00
Antoine Dupuis (andu) 7b21821d60 [FIX] l10n_pe: demo: set l10n_latam_identification_type_id to 'RUC'
The issue:
When creating a fresh DB with demo data, the demo company and
customer are created with l10n_latam_identification_type_id set to
the default, which is 'VAT', rather than 'RUC'.

This creates a problem when we create an invoice with the demo
company and the demo customer and validate it: when the l10n_pe_edi
module sends the invoice to the OSE, the OSE responds with the
following error code:

'1007|El dato ingresado no cumple con el estandar - [...]
error: Error Factura (codigo: 1007): 1007
(nodo: "cbc:ID/schemeID" valor: "0")'

Some observations on how the issue occurs:
Interestingly, when you create a new company or partner using the UI,
the `l10n_latam_identification_type_id` is automatically set to 'RUC'.
This is ensured by the `ResCompany.create()` and
`ResPartner._onchange_country()` methods, see
https://github.com/odoo/odoo/blob/f84dbf63b9354a3c577589178a09c3ffb151cba3/addons/l10n_latam_base/models/res_company.py#L10 and
https://github.com/odoo/odoo/blob/f84dbf63b9354a3c577589178a09c3ffb151cba3/addons/l10n_latam_base/models/res_partner.py#L24

However, when the demo company is created, the `create()` method is
called at the first <field> element, which is `name`, and so,
`create()` does not set `l10n_latam_identification_type_id`.

And because the demo partner is created without the UI, the onchange
is not called when the partner's country is set.

The solution:
Therefore it is necessary to manually set the
`l10n_latam_identification_type_id` in the demo data.

closes odoo/odoo#82920

X-original-commit: 33e174d58e7ad2a5a965f31a23c4b8281fedef79
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2022-01-17 17:50:29 +00:00
Antoine Dupuis (andu) ad1b55b760 [FIX] base: catch PDFs that fail on PdfFileWriter.write
Issue:
Our functionality for merging PDFs from multiple vendor bills relies on PyPDF2. It is well-known that PyPDF2 is sometimes unable to manipulate even perfectly normal PDFs. To provide a helpful error message to the user when this happens (i.e. give them the names of the vendor bills corresponding to the offending pdfs), the `_get_unreadeable_pdfs()` function is called right before we try to merge the PDFs in `_merge_pdfs`. This function is meant to identify the offending PDFs and provide them to the user.
However, _get_unreadable_pdfs did not notice the problem with 3 of my customer's pdfs, because the error was only triggered once the PdfFileWriter.write function was called in _merge_pdfs. This function, however, is not called in _get_unreadable_pdfs, therefore, it did not notice that anything was wrong.

Fix:
- Change _get_unreadable_pdfs so that it also makes a call to PdfFileWriter.write
- As soon as PdfFileWriter.write fails once, it will continue failing when we append more PDF streams to the PdfFileWriter. I therefore suggest initialising a different PdfFileWriter at each iteration of the for loop in order for an offending PDF to not cause a false positive on subsequent PDFs.

closes odoo/odoo#78966

X-original-commit: 0b4efd37376223806e7ff7273f520b2d17337bc8
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Antoine Dupuis (andu) <andu@odoo.com>
2021-10-26 13:22:56 +00:00