Monday, December 2, 2024
7 changes · 17.0
New functionality added to Odoo
This update adapts payroll calculations to reflect the recent shift from NHIF to SHIF, which only affects the amount calculation. A new report wizard is created to manage both NHIF and SHIF reporting requirements, ensuring accurate payroll reporting from October 1st onwards.
Original PR description
Problem ---------- Since 1st October, the SHIF replace the NHIF, the only difference is the computation of the amount. All payslip before and on the 9 October use the NHIF and all new payslip from the 9 October use the SHIF Objective ---------- Adapt the salary rules to compute the good rule. Adapt the NHIF Report to make NHIF or SHIF reports. Solution ---------- Create new SHIF rule parameter with a min amount and rate computation. Create a new report wizard to manage the 2 different rules NHIF and SHIF task-4294419
Resolved issues and error corrections
This update fixes a bug where the POS system would unexpectedly start clocking in users even if a cashier wasn't selected. The change ensures a cashier is selected before clocking in, preventing errors and ensuring the POS remains usable. This improves the overall reliability of the Point of Sale experience.
Original PR description
Behavior before commit: When opening the POS and selecting a cashier, if the user decides to go back without selecting any cashier, the clock-in function gets called anyways. This leads to pos_blacbox trying to clock in an undefined cashier, which in turn leads to more errors down the line (including an unusable pos). With the modification proposed in this commit, we check that a cashier has indeed been selected and only then proceed with the clocking in. opw-4293988 opw-4182434
This update corrects a problem where multiple cancellation requests for Mexican tax documents (CFDI) could lead to errors. When a customer rejects a cancellation, a new cancellation request is created. When the SAT approves the second request, the original cancellation request is automatically removed, preventing data inconsistencies. This ensures accurate tax reporting and avoids potential issues with the Mexican tax authority.
Original PR description
In a production setup: - Create an invoice and sign it - Ask for a cancellation rejected by the customer => an invoice_request_cancel document is created - Ask for another cancellation request => another invoice_request_cancel document is created - Trigger the SAT to approve the second cancellation request => The first invoice_request_cancel document is unlink.
This update resolves issues with Mexican CFDI invoice generation related to rounding calculations. Specifically, it corrects an error in how taxes are calculated during global invoice creation, ensuring compliance with Mexican tax regulations. The fix improves the accuracy of CFDI invoices for Mexican businesses.
Original PR description
## Steps to reproduce the issue 1. Activate Mexican Localization 2. In Mexican Company, create two Invoices with one product line: - Price Unit of 3.47, 16% Tax - Activate CFDI to Public 3. Select…
## Steps to reproduce the issue
1. Activate Mexican Localization
2. In Mexican Company, create two Invoices with one product line:
- Price Unit of 3.47, 16% Tax
- Activate CFDI to Public
3. Select both Invoices and create Global Invoice ("Actions" drop menu)
4. Check the CFDI tab in one of the Invoices
5. One of those errors pops up depending on your rounding method:
#### Round per line:
> Code : 301
> Message : Error de validaciones adicionales [Error #CFDI40108] El TipoDeComprobante es I,E o N, el importe registrado en el campo no es igual al redondeo de la suma de los importes de los conceptos registrados. Folio: 2. Serie: GINV/. El valor del atributo SubTotal (6.95) no coincide con la suma de los importes (3.47 + 3.47 = 6.94)
#### Round globally:
> Code : CFDI40205
> Message : El valor del campo TotalImpuestosTrasladados no es igual a la suma de los importes registrados en el elemento hijo Traslado.
## Explanation
#### Round per line:
With commit odoo/enterprise@933864a38af21a70b219d2824c64fff488acb15f, base and tax amounts were tweaked in order to satisfy some CFDI constraints. This change calculates amounts in an incorrect order: instead of calculating `tax_amount` with the formula `base_amount * tax_rate`, it calculates the base using `total / (1 + tax_rate)` then subtracts the base from the total to obtain the tax amount.
In our example, with a total of `6.94 + 1.12 = 8.06`, the base is calculated as such: `8.06 / 1.16 = 6.94827586207`, rounded to `6.95`, and the tax as such : `8.06 - 6.95 = 1.11`. The difference between the tweaked base `6.95` and the addition of the base of all invoice lines `3.47 + 3.47 = 6.94` is not accepted.
#### Round globally:
During a Global Invoice creation, we will first calculate the values of the Invoices separately. During this calculation, `total_impuestos_trasladados` is rounded with `precision_digits=2` while values in `traslados_list` are rounded with `precision_digits=6`. https://github.com/odoo/enterprise/blob/800378bfd3fe198647c9b418def3bd36066d9cd7/l10n_mx_edi/models/l10n_mx_edi_document.py#L583-L590 https://github.com/odoo/enterprise/blob/800378bfd3fe198647c9b418def3bd36066d9cd7/l10n_mx_edi/models/l10n_mx_edi_document.py#L950-L961 https://github.com/odoo/enterprise/blob/800378bfd3fe198647c9b418def3bd36066d9cd7/l10n_mx_edi/models/l10n_mx_edi_document.py#L963-L964 https://github.com/odoo/enterprise/blob/800378bfd3fe198647c9b418def3bd36066d9cd7/l10n_mx_edi/models/l10n_mx_edi_document.py#L1000-L1001
In the example, `3.47 * 0.16 = 0.552`, is rounded to `0.56`. The addition of every rounded value gives `1.12` or `1.110400`, which gives the difference between `total_traslados_impuestos` and `traslados_list`.
## Fix reasoning
#### Round per line:
We will add a hack in `_get_post_fix_tax_amount_map`: CFDI accepts a difference of `1e-<precision_digits>`, which means that `precision_digits=2` would allow a difference of `0.01`. If the difference is lower, we will not perform the operation and only round the values.
In our example, the obtained tax amount is `1.12` and the expected tax amount `6.94 * 0.16 = 1.1104`. The difference between the two is lower than `0.01` and is accepted by the CFDI.
#### Round globally:
We will use the calculated values in `_get_global_invoice_cfdi_values` to compute the total price and totals of taxes at the end of the method instead of using the rounded values received from `cfdi_values_list` at the start.
opw-4085403This update fixes an issue with Odoo's report engines, specifically the account_codes engine, that caused incorrect data display when using LIMIT and OFFSET. The fix ensures consistent behavior across report types by adding an explicit ORDER BY clause, addressing a PostgreSQL requirement for reliable LIMIT/OFFSET functionality. This resolves data discrepancies and ensures accurate report results.
Original PR description
[FIX] account_reports, l10n_*_reports: add explicit ORDER BY to report engines for consistent LIMIT and OFFSET behavior As stated here https://www.postgresql.org/docs/current/queries-limit.html ,…
[FIX] account_reports, l10n_*_reports: add explicit ORDER BY to report engines for consistent LIMIT and OFFSET behavior
As stated here https://www.postgresql.org/docs/current/queries-limit.html , postgresql requires an explicit ORDER by within the query for LIMIT and OFFSET to work properly and consistently between query executions. We hence add one to each engine not having one already.
=======================================
[FIX] account_reports: properly handle groupby in account_codes engine for grouping keys used with multiple accounts
// TO REPRODUCE
1) Create a report with a single line, whose computation uses the account_codes engine, with formula "1". Set "partner_id" as the groupby value for that line. Setup a "load more limit" of 2 on your report.
2) Create 3 accounts, with codes 11, 12, 13
3) Create 3 partners: A, B, and C
4) Create journal entries, with the following lines (all balancing lines must use other accounts as the ones defined in 2) ), in that order:
- on account 11, with partner A, debit=10
- on account 11, with partner A, debit=20
- on account 12, with partner A, debit=25
- on account 11, without partner, debit=30
- on account 11, without partner, debit=40
- on account 12, with partner B, debit=50
- on account 13, with partner C, debit=60
5) Open the report for a period covering all the created journal entries, and have a look at the sublines generated for the groupby.
=> With the limit being 2, you'd expect to see "A", "B", and a "Load more..." line allowing to visualize the rest (namely a line for "C", and "Unknown"). Instead of that, you see no "Load more ...", and line "A"'s amount is wrong.
// EXPLANATION
The SQL query of the account_codes engine is grouping not only by groupby key (here, partner_id), but also by account_id, to be able to process the "C" and "D" suffixes of the formula later on. Because of that, the LIMIT passed by the load_more_limit is applied on that grouping.
With a load_more_limit of 2, we try to load 3 lines. If we manage to load 3, we only display 2, but know we need to display the "Load more..." line. Else, we know there are no more results, so no need for that additional line.
So, with our example, the query runs with a LIMIT of 3, returning
- 30 for A on account 11
- 25 for A on account 12
- 70 for no partner on account 11
Then, another issue happens:
The results returned by the SQL query (hence, by the engine) contain two times the same partner_id. From an engine perspective, the grouping key is only partner_id, not account_id (which is only used for an inner computation, with the SQL query). So that means the same grouping key has two different values. This is not legit, and causes one of them to shadow the other.
The report computation then receives 1 result for A, and 1 for "Unknown", so it renders them, and since there is no third result, it does not display the "Load more ...".
Forward-Port-Of: odoo/enterprise#74784This update optimizes the performance of reports displaying large amounts of asset data. By passing currency and expression values directly, the system avoids redundant data retrieval, resulting in faster report generation. This change significantly reduces processing time, especially with a large number of assets.
Original PR description
### Description When opening a report with a lot of data to display, getting some values can be very costly. In this case, for the depreciation schedule, we are retrieving the column expression and currency symbol each time if not found in `_build_column_dict`. To avoid retrieving a value that was already fetched, we can pass the currency and the expression directly. This reduces unnecessary `__get__` calls. ### Benchmark (made in 17.0) | N° of assets | Before | After | |--------------|---------|--------| | 500 | 2 s | 1.55 s | | 7k | 20 s | 19 s | | 17k | 50 s | 41 s | ### Reference opw-4287192
This update fixes an issue where sales order line subtotals were incorrectly displaying tax-included prices when orders were synchronized from Amazon with Avatax. The change ensures that the subtotal accurately reflects the amount before tax by intentionally excluding the Amazon's tax information, which Avatax is best positioned to handle.
Original PR description
When synchronizing orders from Amazon with Avatax enabled, sales order lines currently show no taxes and incorrectly set the tax included price as being the subtotal. This occurs because the fiscal position used does not include any tax, which is the expected behavior for Avatax. The recomputation then uses the full amount of the line (which is tax included), and in the absence of tax, consider this is also the subtotal. We now intentionally do not consider the tax amount from Amazon on the order lines, because the distribution of the Amazon's given tax amount is unknown. The multiple real taxes across that line is not an information that Amazon gives us, and needs to be seen from Avatax. This setup ensures that the subtotal on sales order lines remain accurate. opw-4214775