Tuesday, July 6, 2021
20 changes · master
Enhancements to existing features
The recruitment screen now gives job source names more room in the kanban view. This helps prevent names from being cut off, making the information easier to read for users managing recruitment sources.
Original PR description
Gives a bit more space to the job source name to prevent text from cutting. Task ID: 2575483
The contract salary page sidebar now remains visible as users scroll up or down. This makes it easier for HR users to keep important salary information and navigation in view while reviewing longer contract salary pages.
Original PR description
scrolling down or up the page does not follow by the header. so this commit fixes the issue by changing the position property of the contract salary sidebar div so that scrolling down or up the page will be followed by the header TaskID-2578918
Resolved issues and error corrections
This fix restores a missing editor signal that parts of the website editor rely on when editing page content and styling options. It helps prevent regressions in editor interactions, particularly around snippets and color palette behavior, after an earlier incomplete forward-port.
Original PR description
Forward-port of a commit that was wrongly forward-ported with [1], half of the diff was lost because it landed in master before the merge of another commit which removes what was being reintroduced here... [1]: https://github.com/odoo/odoo/commit/e7f497b027d5931b1cf57febcab5deda573b45bb X-original-commit: 68d7d42cce012269342e18373a30970e2c582ba3
Miscellaneous changes
[FIX] web_editor: update Odoo Editor library to commit 0097423 Note: this is not a regular forward port as it builds the master Odoo-Editor branch. The commit message has been adapted to reflect commit hashes referering to that branch instead of saas-14.4. This builds the editor up to commit 0097423 of the Odoo Editor repository and therefore includes the following commits: commit 009742360ba8c39b76937b06b96952e1fb41b9ce Author: Younn Olivier <yol@odoo.com> Date: Thu Jun 24 14:0
Original PR description
[FIX] web_editor: update Odoo Editor library to commit 0097423 Note: this is not a regular forward port as it builds the master Odoo-Editor branch. The commit message has been adapted to reflect…
[FIX] web_editor: update Odoo Editor library to commit 0097423
Note: this is not a regular forward port as it builds the master
Odoo-Editor branch. The commit message has been adapted to reflect
commit hashes referering to that branch instead of saas-14.4.
This builds the editor up to commit 0097423 of the Odoo Editor
repository and therefore includes the following commits:
commit 009742360ba8c39b76937b06b96952e1fb41b9ce
Author: Younn Olivier <yol@odoo.com>
Date: Thu Jun 24 14:09:49 2021 +0200
[FIX] only send observerApply event when needed
REASON FOR THE FIX
To correctly display the overlay over a rotated element, we need to
reset the transform of the element, to be able to apply it on the
overlay.
Changing the style of the element in the SnippetEditor cover method
would trigger a DOM mutation, which will result in setting the
odooEditor observer unactive.
The issue was that flushing the observer (when setting it unactive)
would always send an event observerApply, even if no record was
processed.
It was an issue as the SnippetsMenu was triggering a content_changed
event at the reception of this event, which would rerender the
SnippetEditor overlay cover (and create an infinite loop of events).
SOLUTION
To avoid that, the observerApply event is sent only if records were
processed.
task-2554608
commit fe2730be1186385ee8ea83dfe803bcc5c7c84ebf
Author: Antoine Guenet <age@odoo.com>
Date: Tue Jun 29 17:29:58 2021 +0200
[FIX] prevent splitting the wrong parent on paste
When inserting blocks, we often need to split the node in which we're
inserting. The code that makes that happen had an issue in its while
statement that checked the wrong node, resulting in overreaching splits.
This fixes that while statement.
commit 8c40f48569f3d7fdde1e50761b4053c7fdc2e6a7
Author: Antoine Guenet <age@odoo.com>
Date: Mon Jun 28 12:20:50 2021 +0200
[IMP] paste text safely in editor without wrapping code in PRE tags
The system to detect if the text that was pasted contained javascript or
xml was weird, buggy and risky. This reverts it so we can make use of
insertText instead of insertHTML and be perfectly safe. We also preserve
linebreaks in HTML.
commit e2585b01690459770c064c27d8c4e8bae7a620cb
Author: Nicolas Bayet <nicolas.bayet@gmail.com>
Date: Mon Jun 28 15:52:48 2021 +0200
[FIX] deleteContentForward on google chrome
Sometimes Google Chrome wrongly triggers an input event with `data`
being `null` on `deleteContentForward` and `insertParagraph`. Luckily
Chrome provides the proper signal with the event `beforeinput`.
A fix had already been made for enter but not for `deleteContentForward`.
commit d2ca74e3add46a2e4bf3106b605d7ee93ef46228
Merge: 9508111 8bf167d
Author: Nicolas Bayet <nby@odoo.com>
Date: Mon Jun 28 14:13:33 2021 +0200
Merge pull request #248 from odoo-dev/master-fix-toolbar-pointer-nby
master-fix-toolbar-pointer-nby
commit 8bf167d4f9b9c17f07199d2b2dbf73ca635f68c1
Author: Nicolas Bayet <nicolas.bayet@gmail.com>
Date: Mon Jun 28 11:17:30 2021 +0200
[FIX] fix toolbar pointerEvents only when toolbar exists
Fix the toolbar pointerEvents only when the toolbar exists.
The editor without toolbar happen only in our test suite at the
time of this commit.
commit e61b0b50f7589dc05fdacd01d840ca6aba2a97cb
Author: Antoine Guenet <age@odoo.com>
Date: Fri Jun 25 16:11:36 2021 +0200
[FIX] do not merge similar option elements when sanitizing
The sanitizer merges similar elements together but <option> elements
should never be merged because they each represent a separate option,
no matter if several consecutive options are the same. Options are
blocks by default so failing to recognize that was the cause of the
issue.
commit 35acaf6e3e3046bac8e4175ead33072396d155f9
Author: Nicolas Bayet <nicolas.bayet@gmail.com>
Date: Thu Jun 24 16:50:36 2021 +0200
[FIX] correct selection only on mouseup
Before, the code was updating the selection while
the selection was changing. When changing selection
with the mouse, it created collapsed range in some case
where it should not. We now correct the selection
on mouseup and keyup to avoid conflicting with the browser manipulating
the selection on mousemove.
Also, the previous correction generated systematically a collapsed range
whereas now it correct only the range.startContainer or range.endContainer
individually.
commit e4832094a0e34f9c7ebf53c2fddc17783a6727dc
Author: Nicolas Bayet <nicolas.bayet@gmail.com>
Date: Thu Jun 24 12:16:29 2021 +0200
[FIX] prevent pointer event on toolbar when selecting
When the user was selecting inside the editable,
the floating toolbar can place itself on top of the
cursor, which change the selection. This change of
selection change the toolbar position, which re-change
the selection. This change happened indefinitelly.
commit d71e7d1ba9e04e4fd7c971dc22d16819ec0b9ac9
Author: Nicolas Bayet <nicolas.bayet@gmail.com>
Date: Thu Jun 24 11:46:24 2021 +0200
[IMP] eslint fixes
Some eslint autofix were commited.
This is the result of `eslint --fix .`
commit 16225c0a56fc406c72d070665eefb827d5fbcb6a
Author: Nicolas Bayet <nicolas.bayet@gmail.com>
Date: Thu Jun 24 11:56:04 2021 +0200
[FIX] prevent pointer event on toolbar triangle icon
The icon displaying the triangle was capturing the
pointer and changed the selection. The toolbar
should not capture the pointer events when the
user is selecting (ie. mousedown/mousemove)
some text with the mouse.
commit 5266ed06fbc045b4e54abe99adc8494de90291fb
Author: Antoine Guenet <age@odoo.com>
Date: Tue Jun 22 16:22:12 2021 +0200
[FIX] prevent shrunk blocks on split during insert html
When inserting HTML, we sometimes need to split blocks to prevent weird
nesting of blocks. However, that process has the potential of generating
shrunk blocks (blocks without a height), such as <p></p>. This prevents
it from happening.
commit 135f47223b83a92862efb1a765310cd0e4b2c644
Author: Antoine Guenet <age@odoo.com>
Date: Tue Jun 22 15:49:09 2021 +0200
[FIX] remove conflit markers, shame on me
commit 434db896983384b525b828254e8172a6d16cbb55
Author: Antoine Guenet <age@odoo.com>
Date: Thu Jun 17 16:31:29 2021 +0200
[FIX] properly create multi-paragraph list with whitespace
This addresses a bug that occurs when selecting over two paragraphs that
are separated by some whitespace. It would create multiple indented
lists.
Task: 2567795
commit cccfffd2787484818eb0508635fa6082fb90c8e0
Author: Antoine Guenet <age@odoo.com>
Date: Mon Jun 14 10:24:39 2021 +0200
[FIX] prevent editing the toolbar with the toolbar
Clicking in the (non-floating) toolbar, then on one of its buttons would
edit the toolbar itself (eg., clicking on a list button would insert a
list in the toolbar).
This adds a check on toolbar events so they can only affect what is in
the editable area.
commit fc55af9a067a869effd6955559d63d880d41e659
Author: Antoine Guenet <age@odoo.com>
Date: Fri May 28 12:33:04 2021 +0200
[FIX] prevent <p><p><br/></p></p> on insert html
When pasting a paragraph within a paragraph, the original paragraph
should split rather than allowing for nested paragraphs.
commit 3b04077549befe8ff10a896fb462b71f557fed6b
Author: Antoine Guenet <age@odoo.com>
Date: Fri May 28 10:13:45 2021 +0200
[FIX] ensure dropping of html behaves the same way as pasting
commit 619332f0349f21751746562de6354610a92eeb8a
Author: Antoine Guenet <age@odoo.com>
Date: Thu May 27 15:23:20 2021 +0200
[FIX] properly paste escaped text and filtered html
Thus far, the editor only handled text-only pasting. This commit makes
it so that it now handles html pasting, and ensures that text pasting is
properly escaped (to prevent evaluating html strings on paste).
When pasting html, the editor filters the nodes, their attributes and
their classes through a combination of a whitelist and a blacklist.
Nodes that match blacklisted or non-whitelisted selectors are removed
and their contents are unwrapped recursively. Attributes and classes
that are blacklisted or non-whitelisted are removed.
What is kept are basic styling elements (eg: h1, strong, ...), images
(with their src attribute), links (with the href attribute), and a
selection of classes the edition of which is supported by the editor.
commit 1ff8ae71fe67320bfaf5d73e1a53cfa8fb8a4e4f
Author: Antoine Guenet <age@odoo.com>
Date: Tue May 11 12:52:55 2021 +0200
[FIX] always identify and unbold bold text
The current method to identify bold text failed when the "bolder"
font-weight was smaller than 500, which happens if the normal
font-weight is set to less than 400. This is the case with Bootstrap's
"lead" class for instance.
Checking if it's bigger than 500 is useful for marking headings as being
bold. However we need to also check if the element's font-weight is
bigger than its parent block - in which case it should be considered
bold.
Using `font-weight: normal` to unbold again fails if the inherited
font-weight is smaller than 400 (eg: text in a ".lead" element inherits
a font-weight of 300 but `font-weight: normal` is the same as
`font-weight: 400` so setting `font-weight: normal` would make the text
still end up bolder than the ".lead" element). In these cases we need to
use the font-weight of said block.
It's an imperfect heuristic but it gets the job done in the vast
majority of cases.
commit c53e8f0d841e4e087924bb1c59ebb1ab49759a1c
Author: Antoine Guenet <age@odoo.com>
Date: Fri May 7 13:28:42 2021 +0200
[IMP] keep cursor in an unremovable inline element after it was emptied
We achieve this by inserting and selecting a zero-width space when
deleting the element.
This is so far limited to unremovable elements but we could potentially
expand this logic to all inlines if we choose to have that behavior. In
that case though we'd have to handle the systematic removal of these
potentially parasitic zero-width spaces, and adapt a lot of tests.
commit 5307b15db8d65fc26f945f9b9622c806aeae0350
Author: Antoine Guenet <age@odoo.com>
Date: Fri May 7 09:28:56 2021 +0200
[ADD] insert four spaces on press tab (always prevent default behavior)
Forward-Port-Of: odoo/odoo#72961
Forward-Port-Of: odoo/odoo#72282This change prevents an automated web test from opening the Odoo Payments menu because that menu does not lead to a usable destination in this context. It reduces false test failures and helps keep quality checks stable without changing the product experience for users.
Original PR description
Avoid to click on Odoo Payments menu during click_all test as this menu leads to nowhere.
This fixes an unreliable automated test in the barcode inventory flow by preventing it from accidentally opening an unintended product screen. It helps keep validation checks consistent and reduces false test failures during development.
Original PR description
In the `test_internal_picking_from_scratch_2` tour, at the end, it opens a line form view and clicks on the product field. As this field is readonly, it opens the product form view which isn't expected. In some case, the test pass because it doesn't have the time to render the product form view and so it's able to click on the save button and then validate the picking. But in case the form view is rendered before that, the test will fail. Also, edits the comment as it didn't describe correctly what is done and so, was more confusing than helping.
Steps to reproduce : - Install 'Accounting' - Create a quotation then send it (without confirming it) - Click on Preview Issue : `Date` field is not preceded by a label. Solution : Display "Quotation Date:" label if quotation in 'Sent' stage. opw-2585000 Forward-Port-Of: odoo/odoo#72941
Original PR description
Steps to reproduce : - Install 'Accounting' - Create a quotation then send it (without confirming it) - Click on Preview Issue : `Date` field is not preceded by a label. Solution : Display "Quotation Date:" label if quotation in 'Sent' stage. opw-2585000 Forward-Port-Of: odoo/odoo#72941
Scenario to reproduce the issue on runbot 12.0 Community: - Go to Settings > Technical > Email > Digest Emails - Select the Weekly Digest - Click on Action > Delete - Click on OK - Go to Settings > Users & Companies > Users - Click on Create - Fill the Name and the Email Address - Save - Odoo Server Error - Missing Record Some users seem to delete this record to stop receiving the digest for everyone, including for future users. The problem is that, even if the digest has been delet
Original PR description
Scenario to reproduce the issue on runbot 12.0 Community: - Go to Settings > Technical > Email > Digest Emails - Select the Weekly Digest - Click on Action > Delete - Click on OK - Go to Settings > Users & Companies > Users - Click on Create - Fill the Name and the Email Address - Save - Odoo Server Error - Missing Record Some users seem to delete this record to stop receiving the digest for everyone, including for future users. The problem is that, even if the digest has been deleted, the config parameters are still referencing it. This commit prevents the exception by having an empty recordset if the digest does not exist. Forward-Port-Of: odoo/odoo#73165 Forward-Port-Of: odoo/odoo#73077
Steps to reproduce: - Create a new pricelist; - In the Price Computation, select "Formula" then change it to "Based on Cost"; - Change the price computation back to "Percentage (discount); - Create a sale and set this new pricelist. Issue: Price discount made on the cost of the product instead to get back to sale price as default Cause: When switching `Compute Price` and != 'formula', not setting back `Based on` (base) to `Public Price` (list_price). S
Original PR description
Steps to reproduce:
- Create a new pricelist;
- In the Price Computation, select "Formula" then
change it to "Based on Cost";
- Change the price computation back to "Percentage (discount);
- Create a sale and set this new pricelist.
Issue:
Price discount made on the cost of the product instead to get back
to sale price as default
Cause:
When switching `Compute Price` and != 'formula', not setting back
`Based on` (base) to `Public Price` (list_price).
Solution:
If compute_price is changed and new value != 'formula'; set
pricelist `Based on` to `Public Price`.
opw-2587295
Forward-Port-Of: odoo/odoo#73220When deleting a SO with an event ticket, the number of attendees becomes incorrect To reproduce the error: 1. In Settings, enable "Tickets" 2. On website, register an attendee to event E 3. In module Events, open E Error: The number of attendees (X) is incorrect. If the user clicks on it, there are X-1 attendees: the one added on step 2 has been deleted but the number is not updated When deleting a SO or a SO line, the associated registration is deleted: https://github.com/odoo/o
Original PR description
When deleting a SO with an event ticket, the number of attendees becomes incorrect To reproduce the error: 1. In Settings, enable "Tickets" 2. On website, register an attendee to event E 3. In module…
When deleting a SO with an event ticket, the number of attendees becomes incorrect To reproduce the error: 1. In Settings, enable "Tickets" 2. On website, register an attendee to event E 3. In module Events, open E Error: The number of attendees (X) is incorrect. If the user clicks on it, there are X-1 attendees: the one added on step 2 has been deleted but the number is not updated When deleting a SO or a SO line, the associated registration is deleted: https://github.com/odoo/odoo/blob/3fd3fc5f782f1422f578ad38e3fad444130273a8/addons/event_sale/models/event.py#L197-L198 This is the problem: it won't trigger the `compute` methods. In the case above, this method won't be called: https://github.com/odoo/odoo/blob/72ce1b867dc81672e6a73a586542b20216388a05/addons/event/models/event.py#L176 So the number of seats won't be updated This fix suggests deleting the registrations from the ORM in order to trigger the `compute` methods. Note: Writing the tests revealed another problem. When deleting the SO, if a wizard `registration.editor` exists and is linked to the SO, the deletion will trigger an SQL constraint. This is the reason why the `ondelete` has been added to the field `sale_order_id` OPW-2452760 Forward-Port-Of: odoo/odoo#73166 Forward-Port-Of: odoo/odoo#72253
Carousels (carousel and quotes_carousel snippets) in pages created by the configurator are not added through a drag'n'drop. onBuilt and _assignUniqueId are thefore not called. We set the unique id directly in the xml to make the carousel slides also work when these snippets are added by the configurator. task-2518565 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
Original PR description
Carousels (carousel and quotes_carousel snippets) in pages created by the configurator are not added through a drag'n'drop. onBuilt and _assignUniqueId are thefore not called. We set the unique id directly in the xml to make the carousel slides also work when these snippets are added by the configurator. task-2518565 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 Forward-Port-Of: odoo/odoo#73242
Steps to reproduce the bug: - Let's consider a product P with sale price = 0€ - P is available in the POS - Set a barcode to P, 2312345000002 (meaning price = 0€ with check digit = 2) - Open a session in the POS and scan 2312345003003 (meaning price = 3€ with check digit = 3) Bug: A line was added with P but its price was 0€ instead of 3€ PS: Function _getAddProductOptions always sets price_extra to 0€ opw:2566502 Forward-Port-Of: odoo/odoo#72744 Forward-Port-Of: odoo/odoo#726
Original PR description
Steps to reproduce the bug: - Let's consider a product P with sale price = 0€ - P is available in the POS - Set a barcode to P, 2312345000002 (meaning price = 0€ with check digit = 2) - Open a session in the POS and scan 2312345003003 (meaning price = 3€ with check digit = 3) Bug: A line was added with P but its price was 0€ instead of 3€ PS: Function _getAddProductOptions always sets price_extra to 0€ opw:2566502 Forward-Port-Of: odoo/odoo#72744 Forward-Port-Of: odoo/odoo#72606
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 Forward-Port-Of: odoo/odoo#73129
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 Forward-Port-Of: odoo/odoo#73129
- Go to Inventory > Configuration > Settings and activate "Expiration Dates" - Create a storable product tracked by lot with expiration date (i.e. Component A) - Update quantity of Component A in a lot with an expired expiration date (i.e. Lot A) - Create a consumable product (i.e. Component B) - Create a storable product (i.e. Product X) with a BoM having Component A & B as components - Create a MO for Product X with a quantity to produce set to 1 - Confirm MO - Edit MO to set quantity p
Original PR description
- Go to Inventory > Configuration > Settings and activate "Expiration Dates" - Create a storable product tracked by lot with expiration date (i.e. Component A) - Update quantity of Component A in a…
- Go to Inventory > Configuration > Settings and activate "Expiration Dates" - Create a storable product tracked by lot with expiration date (i.e. Component A) - Update quantity of Component A in a lot with an expired expiration date (i.e. Lot A) - Create a consumable product (i.e. Component B) - Create a storable product (i.e. Product X) with a BoM having Component A & B as components - Create a MO for Product X with a quantity to produce set to 1 - Confirm MO - Edit MO to set quantity produced to 2 - Set consumed quantity for Component A to Lot A - Mark MO as done - Confirm confirmation wizard about using expired Lot A for Component A The following Validation Error is triggered: "This lot Lot A is incompatible with this product Component B" In order to display lot in the confirmation wizard, the ids of the expired lots are added in the context under key "default_lot_ids". As we have set a produced quantity higher than the original quantity, some additional stock moves will be created for final product and it components. As "default_lot_ids" is still in the context at that point, it will set it for stock move lines of both components, which will generate the Validation Error for Component B. "default_lot_ids" should be removed from context after confirming confirmation wizard for expired lots. opw-2543863 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 Forward-Port-Of: odoo/odoo#73209
Steps to reproduce the bug: - Install manufacturing app - Create a product “A” - Create a Bill of Materials for product A > add any product > save - Create another Product “B” > Create a BOM and add the product “A” in quantity “0” > save - Click on “BOM Structure & Cost” for product “B” > open the sublevel BOM dropdown of the product “A” Problem: An error is triggered because the quantity of the product is "None" opw-2585033 -- I confirm I have signed the CLA and read the P
Original PR description
Steps to reproduce the bug: - Install manufacturing app - Create a product “A” - Create a Bill of Materials for product A > add any product > save - Create another Product “B” > Create a BOM and add the product “A” in quantity “0” > save - Click on “BOM Structure & Cost” for product “B” > open the sublevel BOM dropdown of the product “A” Problem: An error is triggered because the quantity of the product is "None" opw-2585033 -- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#73233
The definition of the field is ```python bank_ids = fields.One2many('res.partner.bank', 'company_id', string='Bank Accounts', help='Bank accounts related to this company') ``` So all the banks of all partners registered for one company. -- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#73293 Forward-Port-Of: odoo/odoo#73226
Original PR description
The definition of the field is
```python
bank_ids = fields.One2many('res.partner.bank', 'company_id', string='Bank Accounts', help='Bank accounts related to this company')
```
So all the banks of all partners registered for one company.
--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Forward-Port-Of: odoo/odoo#73293
Forward-Port-Of: odoo/odoo#73226Before this PR, following an invitation, when multiple partner would have the same email address, the chosen partner may not be the one we wanted (the one with an internal user). Attendee answer would not be taken into account on microsoft. -- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#72932
Original PR description
Before this PR, following an invitation, when multiple partner would have the same email address, the chosen partner may not be the one we wanted (the one with an internal user). Attendee answer would not be taken into account on microsoft. -- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr Forward-Port-Of: odoo/odoo#72932
Steps to reproduce the bug: - Let's consider that l10n_es is installed - Let's consider a user U with Accountant access rights - Log with U and go to Accounting > Report > Balance sheet Bug: An access rights error was raised. opw:537900 Forward-Port-Of: odoo/enterprise#19345
Original PR description
Steps to reproduce the bug: - Let's consider that l10n_es is installed - Let's consider a user U with Accountant access rights - Log with U and go to Accounting > Report > Balance sheet Bug: An access rights error was raised. opw:537900 Forward-Port-Of: odoo/enterprise#19345
Steps to reproduce: - With a user registered for OCN notifications - Duplicate it to create a new user (using it as a "template") - Newly created user will keep the same ocn_token as original one => any notification for of those users will be sent to both. opw-2578310 Forward-Port-Of: odoo/enterprise#19447
Original PR description
Steps to reproduce: - With a user registered for OCN notifications - Duplicate it to create a new user (using it as a "template") - Newly created user will keep the same ocn_token as original one => any notification for of those users will be sent to both. opw-2578310 Forward-Port-Of: odoo/enterprise#19447
**Redo of #18801 which was reverted on #18887 due to missing details now impemented on this PR.** Relevant diff 13.0 vs saas~12.3: ```diff class AccountMoveL10NDe(models.Model): _inherit = 'account.move' @@ -27,18 +45,20 @@ @api.depends('journal_id', 'line_ids', 'journal_id.default_debit_account_id', 'journal_id.default_credit_account_id') def _get_datev_account(self): for move in self: - value = False + move.l10n_de_datev_main_account_id
Original PR description
**Redo of #18801 which was reverted on #18887 due to missing details now impemented on this PR.** Relevant diff 13.0 vs saas~12.3: ```diff class AccountMoveL10NDe(models.Model): _inherit =…
**Redo of #18801 which was reverted on #18887 due to missing details now impemented on this PR.**
Relevant diff 13.0 vs saas~12.3:
```diff
class AccountMoveL10NDe(models.Model):
_inherit = 'account.move'
@@ -27,18 +45,20 @@
@api.depends('journal_id', 'line_ids', 'journal_id.default_debit_account_id', 'journal_id.default_credit_account_id')
def _get_datev_account(self):
for move in self:
- value = False
+ move.l10n_de_datev_main_account_id = value = False
# If move has an invoice, return invoice's account_id
- invoice = move.line_ids.mapped('invoice_id')
- if len(invoice):
- move.l10n_de_datev_main_account_id = invoice[0].account_id
+ if move.is_invoice(include_receipts=True):
+ payment_term_lines = move.line_ids.filtered(
+ lambda line: line.account_id.user_type_id.type in ('receivable', 'payable'))
+ if payment_term_lines:
+ move.l10n_de_datev_main_account_id = payment_term_lines[0].account_id
continue
# If move belongs to a bank journal, return the journal's account (debit/credit should normally be the same)
if move.journal_id.type == 'bank' and move.journal_id.default_debit_account_id:
move.l10n_de_datev_main_account_id = move.journal_id.default_debit_account_id
continue
# If the move is an automatic exchange rate entry, take the gain/loss account set on the exchange journal
- elif move.journal_id.type == 'general' and move.journal_id == self.env.user.company_id.currency_exchange_journal_id:
+ elif move.journal_id.type == 'general' and move.journal_id == self.env.company.currency_exchange_journal_id:
accounts = [
move.journal_id.default_debit_account_id,
move.journal_id.default_credit_account_id,
```
When there are many move lines we get a MemoryError because the ORM
tries to create the fields for each move line.
This fix reproduces creates the column and fill it with SQL on
auto_init.
```
Traceback (most recent call last):
File "/home/odoo/src/odoo/12.0/odoo/service/server.py", line 1162, in preload_registries
registry = Registry.new(dbname, update_module=update_module)
File "/home/odoo/src/odoo/12.0/odoo/modules/registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/odoo/src/odoo/12.0/odoo/modules/loading.py", line 417, in load_modules
force, status, report, loaded_modules, update_module, models_to_check)
File "/home/odoo/src/odoo/12.0/odoo/modules/loading.py", line 313, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "/home/odoo/src/odoo/12.0/odoo/modules/loading.py", line 195, in load_module_graph
registry.init_models(cr, model_names, {'module': package.name})
File "/home/odoo/src/odoo/12.0/odoo/modules/registry.py", line 321, in init_models
models[0].recompute()
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 5320, in recompute
vals = {n: rec[n] for n in ns}
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 5320, in <dictcomp>
vals = {n: rec[n] for n in ns}
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 5167, in __getitem__
return self._fields[key].__get__(self, type(self))
File "/home/odoo/src/odoo/12.0/odoo/fields.py", line 1069, in __get__
self.determine_value(record)
File "/home/odoo/src/odoo/12.0/odoo/fields.py", line 1158, in determine_value
self.compute_value(recs)
File "/home/odoo/src/odoo/12.0/odoo/fields.py", line 1136, in compute_value
self._compute_value(records)
File "/home/odoo/src/odoo/12.0/odoo/fields.py", line 1127, in _compute_value
getattr(records, self.compute)()
File "/home/odoo/src/enterprise/12.0/l10n_de_reports/models/datev_export_csv.py", line 32, in _get_datev_account
invoice = move.line_ids.mapped('invoice_id')
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 4914, in mapped
recs = recs._mapped_func(operator.itemgetter(name))
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 4893, in _mapped_func
vals = [func(rec) for rec in self]
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 4893, in <listcomp>
vals = [func(rec) for rec in self]
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 5167, in __getitem__
return self._fields[key].__get__(self, type(self))
File "/home/odoo/src/odoo/12.0/odoo/fields.py", line 1069, in __get__
self.determine_value(record)
File "/home/odoo/src/odoo/12.0/odoo/fields.py", line 1172, in determine_value
record._prefetch_field(self)
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 2848, in _prefetch_field
records = self._in_cache_without(field)
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 5195, in _in_cache_without
for record_id in self.env.cache.get_missing_ids(recs - self, field):
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 5074, in __sub__
return self.browse([id for id in self._ids if id not in other_ids])
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 4736, in browse
return self._browse(ids, self.env, prefetch)
File "/home/odoo/src/odoo/12.0/odoo/models.py", line 4723, in _browse
prefetch[cls._name].update(ids)
MemoryError
```
This issue was detected during the upgrade of client DB upg-11722.
The DB had 2540514 moves with 5371221 move lines.
Total time spent filling with SQL was little less than 2min (110s).
Commit edited to forward port the original commit
X-original-commit: 6e9616eacdcbdd3f4252c144d887fcb37b697de5
Forward-Port-Of: odoo/enterprise#19173
Forward-Port-Of: odoo/enterprise#18986