Wednesday, October 30, 2024
58 changes · 18.0
Enhancements to existing features
Kitchen tickets in Point of Sale now show clearer order updates, including notes, add-ons, staff member, table or takeaway details, and timing. This helps restaurant teams understand what changed in an order faster and reduces delays or mistakes in kitchen preparation.
Original PR description
In this commit:
-------------------
- We have changed the entire kitchen ticket structure added many important data
to make it more usefule such as
- Diferent title related to the order changes.
- Proper orderline formation with internal notes and addons.
- Who has taken the order.
- Floor, table name with order number and time of order changes.
- Also adapted sitting mode (Dine in, Take out) changes.
- Changed the getOrderChanges functionas below
- Identified and separated only note updates in line
- Added some required informations like comboline and attributes.
- Enabled Order button when sitting mode updated (Dinein <-> Takeout)
- For this we have saved the sittingMode data in last order changes.
Task: 4264433Combo products now behave more consistently in online sales: shoppers will not see unnecessary configuration steps, combo products are excluded from wishlists, and combo items follow the intended display order. Analytics reporting for combo prices is also corrected, improving sales tracking accuracy.
Original PR description
- Don't open the combo configurator in eCommerce if there's nothing to configure, - Don't allow combo products in the wishlist, - Order combo items by combo sequence instead of by selection order, - Fix the Google Analytics tracking price for combos. task-4264135 Closes https://github.com/odoo/odoo/issues/182464
PDF files encoded in base64 are now recognized and displayed with the standard PDF icon in the web interface. This makes file previews more consistent and helps users identify PDF attachments more easily.
Original PR description
In the o_image scss, add support for the 'application/pdf;base64' mimetype so that these files are also represented with the pdf background image. Task-4263142 --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Description of the issue/feature this PR addresses: Current behavior before PR: Desired behavior after PR is merged: --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Original PR description
Description of the issue/feature this PR addresses: Current behavior before PR: Desired behavior after PR is merged: --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Resolved issues and error corrections
Removed leftover records and assets for a module that no longer exists. This prevents obsolete module data from appearing or causing confusion during system maintenance and upgrades.
Original PR description
The module was removed in odoo/enterprise@53098e18 --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Miscellaneous changes
When model selection field is used in a form, its default value is always one of the available values. Because of this, if the field is required, it does not force the user to pick a value, but it provides a possibly incorrect default value. This commit makes an empty value available for selection if no default value is chosen. The behavior is also made available on custom fields, if such an empty value had been manually created, it will be replaced by this implementation. Steps to
Original PR description
When model selection field is used in a form, its default value is always one of the available values. Because of this, if the field is required, it does not force the user to pick a value, but it provides a possibly incorrect default value. This commit makes an empty value available for selection if no default value is chosen. The behavior is also made available on custom fields, if such an empty value had been manually created, it will be replaced by this implementation. Steps to reproduce: - Install website_form_project - Add a form in a page - Select the "Create a Task" action - Add the "Analytic Account" field to the form - Make the field required => There was no way to have no default value by default. opw-4268164 Forward-Port-Of: odoo/odoo#185532 Forward-Port-Of: odoo/odoo#184842
Fixes an intermittent issue where manufacturing work orders could keep the wrong expected duration after producing serial-tracked items in batches. This helps production planning stay accurate and consistent for manufacturing teams.
Original PR description
This is a non-deterministic bug. Setup: - install mrp, enable workorders and serial numbers - create a storable product A with serial tracking - create a BOM with 1 operation for product A Steps: -…
This is a non-deterministic bug. Setup: - install mrp, enable workorders and serial numbers - create a storable product A with serial tracking - create a BOM with 1 operation for product A Steps: - create a MO for 2 units of product A -> the duration expected on the WO should be 120 minutes. - confirm then plan the MO - produce all -> you'll see a wizard for batch production (2nd wizard) - generate serials then produce or prepare MO (doesn't matter which) Issue: Sometimes the duration of the initial workorder is correctly computed -> 60 minutes, sometimes it is not (left as is). This is a mix of 2 'bugs': First, we have the `self.env['mrp.production'].browse` via a set(). Because it's a set, the productions received are not always in order, so the loop just after may process the last MO first. This triggers the 2nd 'bug'. Second, the first MO (that was planned) won't trigger `_compute_duration_expected` at https://github.com/odoo/odoo/blob/014ed907a2fab280e9fa6dd93b23a6a852700796/addons/mrp/wizard/mrp_batch_produce.py#L116 when changing `qty_producing` because of `is_planned`: https://github.com/odoo/odoo/blob/014ed907a2fab280e9fa6dd93b23a6a852700796/addons/mrp/models/mrp_production.py#L730-L731 instead, it will go through the compute later because the second MO (created in the split, but not planned) will trigger the compute for both ids via `recompute` because the original MO id was still in the pending transactions: https://github.com/odoo/odoo/blob/014ed907a2fab280e9fa6dd93b23a6a852700796/odoo/fields.py#L1413 However, the first workorder will already have its qty_producing set to 1 so won't pass in `_get_duration_expected`. Fix: Use `OrderedSet` instead of set along with `reversed()` so that the loop will process the last MO first. This way the pending compute for the original MO will correctly compute the duration because it's WO's qty_producing will still be zero. --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Fixes an issue where previewing a canceled invoice with no invoice lines could show an error instead of opening the preview. The system now handles missing invoice line data safely, improving reliability for users reviewing incomplete or canceled invoices.
Original PR description
Currently, an error occurs when the user attempts to preview an invoice, and invoice has no invoice lines. Step to produce: - Install the ```account``` module. - Create a new invoice, add a customer name, and 'Cancel' this invoice. - Click on 'Preview' button(ensure that no invoice lines have been added). ```ValueError: Expected singleton: account.move()``` An error occurs when the system tries to get installment data from the move line at [1], and the move lines are not available in the invoice. Link [1]: https://github.com/odoo/odoo/blob/430656132044f8d675712d5b6cbfef807880d024/addons/account/models/account_move.py#L5411-L5412 To handle this issue, pass empty data for installments if the move line is not available in the invoice. Sentry-5978934688 --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Fixed an issue where adding a down payment from purchase matching could reset a purchase order line back to the vendor’s default price. This preserves the price negotiated on the purchase order and helps avoid billing and reconciliation discrepancies.
Original PR description
### Steps to reproduce the issue: 1. Create a Product and add a Vendor Price under the Purchase tab 2. Create a Request for Quotation from the Vendor with the Product, change the Unit Price 3.…
### Steps to reproduce the issue: 1. Create a Product and add a Vendor Price under the Purchase tab 2. Create a Request for Quotation from the Vendor with the Product, change the Unit Price 3. Confirm Order 4. Create a Vendor Bill from the Vendor with one Invoice Line, click on "Purchase Matching" 5. Select the Invoice Line and click on "Add to PO" 6. Select the PO previously created and Add Down Payment 7. On the PO, the Unit Price on the Product Line has reverted to the Vendor Price ### Explanation: During `_create_downpayments`, `purchase.order.line` created from `account.move.line` are added to `purchase.order.order_line` through a concatenation operator (here a `+`, but `|` would have the same effect). With this operation, `purchase.order.order_line` is flagged as a modified value and needs to be totally recomputed. In the triggered recomputation methods is `_compute_price_unit_and_date_planned_and_name`, which affects multiple values including `unit_price` and uses `product_product.seller_ids`. https://github.com/odoo/odoo/blob/d0e7be7832672d476f1b289af52d3a425990d719/addons/purchase/models/purchase_order_line.py#L313-L318 https://github.com/odoo/odoo/blob/d0e7be7832672d476f1b289af52d3a425990d719/addons/purchase/models/purchase_order_line.py#L351-L358 ### Fix reasoning: With `Command.link`, only the added lines are flagged as new values and `purchase.order.order_line` is not recomputed. opw-4275163
This fixes a payroll/time off issue where changing an accrual allocation start date could leave old carryover expiration values in place, causing the displayed accrued days to become incorrect. Employees and HR teams will now see consistent, accurate time off balances when allocation dates are adjusted.
Original PR description
Steps to Reproduce: Create an accrual allocation: - Carryover date on allocation start date. - Has 1 level: * Start 0 days after allocation start date. * Accrues 1 day monthly on 1st day of the…
Steps to Reproduce:
Create an accrual allocation:
- Carryover date on allocation start date.
- Has 1 level:
* Start 0 days after allocation start date.
* Accrues 1 day monthly on 1st day of the month.
* Carryover policy all accrued time carried over.
* Carryover validity 1 month.
* Leave other options as is.
- Leave other options as is.
Create an allocation:
- Allocation type: accrual allocation.
- Accrual plan: use the one defined above.
- The following dates are in mm/dd/YYYY
- Set allocation start date 08/01/2023.
Number of days becomes 2 days (as expected).
- Set allocation start date 09/01/2023.
Number of day becomes 12 days (as expected).
- Set allocation start date 08/01/2023.
Number of days becomes 13 days (wrong).
The issue is that the expiration date of carried over days and the number of expiring days aren't reset when the start date of the allocation changes.
The fix is to reset these values when the start date of the allocation changes.
task-4208024This fix prevents an unexpected error screen when users save a customized view that contains an invalid context value. Instead of a technical traceback, the system can handle the invalid input more safely, improving reliability during view editing.
Original PR description
When the user edits the view and adds context with invalid syntax, a traceback will appear. Steps to reproduce the error: - Go to Settings > Technical > Views > Open any view - Add context = ``"[]"``…
When the user edits the view and adds context with invalid syntax,
a traceback will appear.
Steps to reproduce the error:
- Go to Settings > Technical > Views > Open any view
- Add context = ``"[]"`` or context = ``"{a}"`` like this in the view
- Save
Traceback:
```
UnboundLocalError: cannot access local variable 'err' where it is not associated with a value
File "odoo/http.py", line 2365, in __call__
response = request._serve_db()
File "odoo/http.py", line 1892, in _serve_db
return self._transactioning(
File "odoo/http.py", line 1955, in _transactioning
return service_model.retrying(func, env=self.env)
File "odoo/service/model.py", line 137, in retrying
result = func()
File "odoo/http.py", line 1922, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "odoo/http.py", line 2169, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "odoo/addons/base/models/ir_http.py", line 329, in _dispatch
result = endpoint(**request.params)
File "odoo/http.py", line 728, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "home/odoo/src/enterprise/18.0/industry_fsm_report/controllers/main.py", line 10, in edit_view
action = super().edit_view(view_id, studio_view_arch, operations, model, context)
File "odoo/http.py", line 728, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "home/odoo/src/enterprise/18.0/worksheet/controllers/main.py", line 10, in edit_view
action = super().edit_view(view_id, studio_view_arch, operations, model, context)
File "odoo/http.py", line 728, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "home/odoo/src/enterprise/18.0/web_studio/controllers/main.py", line 695, in edit_view
self._set_studio_view(view, new_arch)
File "home/odoo/src/enterprise/18.0/web_studio/controllers/main.py", line 456, in _set_studio_view
studio_view.arch_db = arch
File "odoo/fields.py", line 1402, in __set__
records.write({self.name: write_value})
File "home/odoo/src/enterprise/18.0/web_studio/models/studio_mixin.py", line 33, in write
res = super(StudioMixin, self).write(vals)
File "odoo/addons/base/models/ir_ui_view.py", line 535, in write
res = super(View, self).write(self._compute_defaults(vals))
File "odoo/models.py", line 4750, in write
real_recs._validate_fields(vals, inverse_fields)
File "odoo/models.py", line 1599, in _validate_fields
check(self)
File "odoo/addons/base/models/ir_ui_view.py", line 413, in _check_xml
elif err.__context__:
```
https://github.com/odoo/odoo/blob/69b404c7109ff689381f56520aad758424ec01aa/odoo/addons/base/models/ir_ui_view.py#L413-L418
Here, the ``err`` variable is referenced before the assignment,
So, it will lead to the above traceback.
sentry-5993638522
---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-prUnmerging multiple charts of accounts for the same company no longer fails with an unexpected error. This helps accounting users complete account structure changes reliably without manual workarounds.
Original PR description
Currently an error occurs when the user unmerges two or more charts of accounts with the same company. error: `ValueError: Expected singleton: account.account(1249, 1252, 163, 164, 165, 754)` This is because at [1] `self` used to display name here `self` contains multiple records. This commit will fix the above issue by looping records of self and using `display_name` of account, which is needed. [1]- https://github.com/odoo/odoo/blob/0bac60a7085c51ac8cb4f793b013dbea927d180c/addons/account/models/account_account.py#L1108 sentry-5985600163
Use normalized emails for comparison to avoid issues linked to formatting. Task-4281171: [mail] {email/smtp}_from normalized comparison Forward-Port-Of: odoo/odoo#185766 Forward-Port-Of: odoo/odoo#185749
Original PR description
Use normalized emails for comparison to avoid issues linked to formatting.
Task-4281171: [mail] {email/smtp}_from normalized comparison
Forward-Port-Of: odoo/odoo#185766
Forward-Port-Of: odoo/odoo#185749Before this commit, opening the paid orders and searching for an existing order would not fetch the orders from the database. opw-4276187 --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#185528
Original PR description
Before this commit, opening the paid orders and searching for an existing order would not fetch the orders from the database. opw-4276187 --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#185528
On a stock move, when using a lot from a sub-location, the created SML will still start from SM's source location instead of lot's location To reproduce the issue: 1. In Settings, enable "Storage Locations" 2. Create a tracked-by-sn product P 3. Update its qty: - SN01 at WH/Stock - SN02 at WH/Stock/Shelf 1 4. Confirm a delivery with 1 x P 5. Enable the column "Serial Number" - SN01 should be present 6. Remove SN01, set SN02 7. Validate the transfer 8. Open the detailed op
Original PR description
On a stock move, when using a lot from a sub-location, the created SML will still start from SM's source location instead of lot's location To reproduce the issue: 1. In Settings, enable "Storage…
On a stock move, when using a lot from a sub-location, the created SML will still start from SM's source location instead of lot's location To reproduce the issue: 1. In Settings, enable "Storage Locations" 2. Create a tracked-by-sn product P 3. Update its qty: - SN01 at WH/Stock - SN02 at WH/Stock/Shelf 1 4. Confirm a delivery with 1 x P 5. Enable the column "Serial Number" - SN01 should be present 6. Remove SN01, set SN02 7. Validate the transfer 8. Open the detailed operations Result: SN02 has been taken from WH/Stock, but the user probably wanted to use the existing one, in WH/Stock/Shelf 1. An onchange already exists to make sure that the user is not using a lot that already exists somewhere else. Before Odoo 17.2, we were considering the sub locations as not expected: https://github.com/odoo/odoo/blob/d5a7a3d02e3e2b4e47977abc8b9fc0d5d6135937/addons/stock/models/stock_move.py#L1167 But since Odoo 17.2 (via [1]), we now also accept the sub locations: https://github.com/odoo/odoo/blob/60b0bafc8abd1893c9cdd9913617c234692369cf/addons/stock/models/stock_move.py#L1242 This is a bit confusing because we don't display any warning anymore, but we don't select the correct source location neither. The commit should help the user and avoid that confusion [1] https://github.com/odoo/odoo/commit/99b39b72c7e65e85af6f06dcb6b02867623f3f69 OPW-4231749 Forward-Port-Of: odoo/odoo#185796
Steps to reproduce: - Install `website_event_sale` - Go to an event and for one ticket set maximum as 1 - Open event page and purchase a ticket, but don't complete the payment - Do the same in private navigation - Click on pay on the two page Issues: If you check with stripe payment is processed meaning that the two people are charged however one of them can't get a ticket as there isn't enough tickets available. Fix is to check before sending payment to provider and return error if the
Original PR description
Steps to reproduce: - Install `website_event_sale` - Go to an event and for one ticket set maximum as 1 - Open event page and purchase a ticket, but don't complete the payment - Do the same in private navigation - Click on pay on the two page Issues: If you check with stripe payment is processed meaning that the two people are charged however one of them can't get a ticket as there isn't enough tickets available. Fix is to check before sending payment to provider and return error if there's not enough seats. Concurrency issue is not fully solved but would require much more precise timing, and a proper solution wouldn't be stable. opw-3772093 Forward-Port-Of: odoo/odoo#185698 Forward-Port-Of: odoo/odoo#173809
Update branding logo and icon in windows installer. Old forgotten task Task-2862802 Forward-Port-Of: odoo/odoo#185650
Original PR description
Update branding logo and icon in windows installer. Old forgotten task Task-2862802 Forward-Port-Of: odoo/odoo#185650
**Current behavior before PR:** Public channels were not being fetched when users clicked channel mentions, causing chat window title to display "New message" instead of their actual names. Additionally, bus channels were not added every time when threads were opened, preventing real-time messaging in some cases. **Desired behavior after PR is merged:** Implemented channel fetching on mention clicks and added bus channel subscription when opening threads, enabling proper channel nam
Original PR description
**Current behavior before PR:** Public channels were not being fetched when users clicked channel mentions, causing chat window title to display "New message" instead of their actual names. Additionally, bus channels were not added every time when threads were opened, preventing real-time messaging in some cases. **Desired behavior after PR is merged:** Implemented channel fetching on mention clicks and added bus channel subscription when opening threads, enabling proper channel name display and real-time messaging functionality. Task:[3899453](https://www.odoo.com/odoo/project/1519/tasks/3899453) --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#185697 Forward-Port-Of: odoo/odoo#174473
Currently, a traceback occurs when the user deletes a module which is having a gamification goal record. To reproduce this issue: 1) Install `sale` and `gamification` 2) Create a new `gamification challenge` record 3) Create a new `goal` in the gamification challenge 4) Make sure the goal has the definition as `Automatic: sum on a field` 5) Select the model as `account` 6) Uninstall the invoicing module and start the `challenge` of that gamification. Error:- ``` KeyError: Fals
Original PR description
Currently, a traceback occurs when the user deletes a module which is having a gamification goal record. To reproduce this issue: 1) Install `sale` and `gamification` 2) Create a new `gamification…
Currently, a traceback occurs when the user deletes a module which is having a gamification goal record. To reproduce this issue: 1) Install `sale` and `gamification` 2) Create a new `gamification challenge` record 3) Create a new `goal` in the gamification challenge 4) Make sure the goal has the definition as `Automatic: sum on a field` 5) Select the model as `account` 6) Uninstall the invoicing module and start the `challenge` of that gamification. Error:- ``` KeyError: False ``` The value of the model_id became `False` when the user deletes a module used in goal. This leads to a traceback as model_id is used for the reference of obj https://github.com/odoo/odoo/blob/d9603e93d2ab5e0b9fd1948dfd3e3bee20ede599/addons/gamification/models/gamification_goal.py#L164-L165 We can resolve this issue by adding `ondelete='cascade'` in the field definition. Where the record will be deleted if the corresponding model is uninstalled. sentry-4089991441 Forward-Port-Of: odoo/odoo#180307
When archiving an operation in a bom, currently it will unlink if from bom lines that had it set as their `Consumed in Operation`. However, it's not the case for byproducts, meaning that the byproducts lines will still display the now archived operation. --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#185390 Forward-Port-Of: odoo/odoo#185093
Original PR description
When archiving an operation in a bom, currently it will unlink if from bom lines that had it set as their `Consumed in Operation`. However, it's not the case for byproducts, meaning that the byproducts lines will still display the now archived operation. --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#185390 Forward-Port-Of: odoo/odoo#185093
Adds default value to a few required selection fields as currently a value is apparently set in the form (as the select field will pick the first value) but without having the value really set in the field, meaning that on save, the field will appear as invalid. Also, to be able to select the "almost default" value, you'd need to select another value then pick the first value again to properly set it in the field and be able to save the form. To avoid those issue, we can add a default value t
Original PR description
Adds default value to a few required selection fields as currently a value is apparently set in the form (as the select field will pick the first value) but without having the value really set in the field, meaning that on save, the field will appear as invalid. Also, to be able to select the "almost default" value, you'd need to select another value then pick the first value again to properly set it in the field and be able to save the form. To avoid those issue, we can add a default value to those fields corresponding to the current "default" value in the form. --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#185477 Forward-Port-Of: odoo/odoo#184939
Issue: ====== clipboard data has ufeff characters in it. Steps to reproduce the issue: ============================= - Create a new note/todo - Add a link - Copy it - Visualise the data copied - It contains ufeff characters of the link Solution: ========= for web_editor: We remove the characters fron the text and html we put in the clipboard data. for html_editor: We dispatch a CLEAN command before selecting the content and we handle it by link_selection_plugin and we norm
Original PR description
Issue: ====== clipboard data has ufeff characters in it. Steps to reproduce the issue: ============================= - Create a new note/todo - Add a link - Copy it - Visualise the data copied - It contains ufeff characters of the link Solution: ========= for web_editor: We remove the characters fron the text and html we put in the clipboard data. for html_editor: We dispatch a CLEAN command before selecting the content and we handle it by link_selection_plugin and we normalize after after cloning the content opw-4029722 Forward-Port-Of: odoo/odoo#184372 Forward-Port-Of: odoo/odoo#182596
Currently the `report_stock_quantity` view third `UNION ALL` does a `generate_series` between the moves date and `now()` in case the move is not in done. This can lead to significant slowdowns when querying the view in case some databases have old moves not in done, cancel, draft. In that case, the report will generate a row for each day between the move.date and `now()`, leading to thousands of rows for 1 stock.move. To alleviate that, this commit uses the `report_period` as a lower bound
Original PR description
Currently the `report_stock_quantity` view third `UNION ALL` does a `generate_series` between the moves date and `now()` in case the move is not in done. This can lead to significant slowdowns when querying the view in case some databases have old moves not in done, cancel, draft. In that case, the report will generate a row for each day between the move.date and `now()`, leading to thousands of rows for 1 stock.move. To alleviate that, this commit uses the `report_period` as a lower bound. This greatly reduces the number of rows generated by the third `UNION ALL` without losing forecasted accuracy since the moves are not in done. #### speedup In a v17 database where `all_sm` returns 600 000 rows, querying the `report_stock_quantity` view goes from 20s -> 7s. --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#184998 Forward-Port-Of: odoo/odoo#179359
Currently it can happen that slightly changing the amount in (document) currency (field `amount_currency`) i.e. on a tax line can lead to an unbalanced move. (See example and "Reproduce" below.) The issue is the syncing (function `_sync_invoice`) between - amount in currency (document currency; field `amount_currency`) and - balance (company currency; field `balance`). There we update the amount in currency in case the balance is changed and the amount in currency is not changed. But
Original PR description
Currently it can happen that slightly changing the amount in (document) currency (field `amount_currency`) i.e. on a tax line can lead to an unbalanced move. (See example and "Reproduce" below.) The…
Currently it can happen that slightly changing the amount in (document)
currency (field `amount_currency`) i.e. on a tax line can lead to an
unbalanced move. (See example and "Reproduce" below.)
The issue is the syncing (function `_sync_invoice`) between
- amount in currency (document currency; field `amount_currency`) and
- balance (company currency; field `balance`).
There we update the amount in currency in case the balance is changed
and the amount in currency is not changed.
But this is problematic in case we want (in the same write) set
a different amount in currency but explicitly set the same balance
(and not just not write anything to the `balance` field).
Since we write the same balance it is not detected as a
change and we update the balance based on the amount in currency.
But this should not happen; the balance should be "protected"
from being updated (since it is the value we explicitly want).
This can i.e. cause the balance of the receivable line to receive the wrong value
I.e. consider the following case; with currency rate = 2 (also see "Reproduce" below)
Journal Items:
- product 1: amount in currency = -1000.00 €, balance = -500.00
- product 2: amount in currency = -200.00 €, balance = -100.00
- tax line 1: amount in currency = -180.03 €, balance = -90.02
- tax line 2: amount in currency = -30.00 €, balance = -15.00
- Receivable: amount in currency = -1410.03 €, balance = 705.02
And we modify tax line 2: amount in currency = -29.99 €.
Then first we set the correct values because we basically compute the
receivable line by summing the other lines:
Journal Items:
- product 1: amount in currency = -1000.00 €, balance = -500.00
- product 2: amount in currency = -200.00 €, balance = -100.00
- tax line 1: amount in currency = -180.03 €, balance = -90.02
- tax line 2: amount in currency = -29.99 €, balance = -15.00
- Receivable: amount in currency = -1410.02 €, balance = 705.02
So we have set the balance to the same as before but changed the
amount in currency. So then we recompute the balance on the receivable
line from the amount in currency due to the syncing (`_sync_invoice`)
Journal Items:
- product 1: amount in currency = -1000.00 €, balance = -500.00
- product 2: amount in currency = -200.00 €, balance = -100.00
- tax line 1: amount in currency = -180.03 €, balance = -90.02
- tax line 2: amount in currency = -29.99 €, balance = -15.00
- Receivable: amount in currency = -1410.02 €, balance = 705.01
But now the move is not balanced (the sum of the balances should be 0)
-500.00 + -100.00 + -90.02 + -15.00 = -705.02 (and not -705.01)
After this commit we "protect" the balance and amount in currency from
being updated by `_sync_invoice` in case the surrounding `write`
sets the balance (`balance`) or amount in currency (`amount_currency`)
respectively.
Reproduce: (c.f. example above)
1. Select company "My Company (San Francisco)"
2. Ensure EUR currency is activated and has value 2 unit per USD
(at the time of the invoice that will be created further below)
3. Copy the 15% tax
4. Create a new invoice in EUR with 2 lines
(1) qty = 1, unit price = 1000, taxes = 15%
(2) qty = 1, unit price = 200, taxes = 15%, 15% (Copy)
5. There should be 2 tax lines in the "Journal Items" tab
(1) amount in currency = -180.00 €, credit = 90.00 USD
(2) amount in currency = -30.00 €, credit = 90.00 USD
6. Modify tax line (1); set amount in currency to -180.03 €
and save.
The credit will be updated to 90.02 USD.
7. Modify tax line (2); set amount in currency to -29.99 €
and try to save
8. An "Invalid Operation" error is raised:
The move (Draft Invoice ) is not balanced.
The total of debits equals $ 705.01 and the total of credits equals $ 705.02.
Forward-Port-Of: odoo/odoo#185757
Forward-Port-Of: odoo/odoo#171705
**Note**
Compared to previous versions the `amount_currency` is not updated
anymore in `_sync_invoice` (only the `balance`).Before this commit, when a payable account was used on a customer invoice, or a receivable account on a vendor bill, an error message was raised saying "Any journal item on a receivable/payable account must have a due date and vice versa.". This was unclear, and caused for example confusion when importing the accounting history. Therefore, we now handle this case with a new error message. opw-4196597 Forward-Port-Of: odoo/odoo#185696 Forward-Port-Of: odoo/odoo#182979
Original PR description
Before this commit, when a payable account was used on a customer invoice, or a receivable account on a vendor bill, an error message was raised saying "Any journal item on a receivable/payable account must have a due date and vice versa.". This was unclear, and caused for example confusion when importing the accounting history. Therefore, we now handle this case with a new error message. opw-4196597 Forward-Port-Of: odoo/odoo#185696 Forward-Port-Of: odoo/odoo#182979