Thursday, December 24, 2020
5 changes · master
Miscellaneous changes
Bounch of fixes to improve the performance of `_action_validate`. [FIX] stock: improve perf of `_compute_has_packages` of `stock.picking` When a picking contains a lot (> 10000) of stock move line, the time to open the picking become a issue (for 50000 sml, +- 6.5 sec) because of the `_compute_has_packages`. Use a search with a limit=1 to avoid fetching all `stock.move.line` with `result_package_id` (for 50000 sml, +- 2.5 sec). backport of 8551836af8935f8f2badb0322c7032be7bff37ea
Original PR description
Bounch of fixes to improve the performance of `_action_validate`. [FIX] stock: improve perf of `_compute_has_packages` of `stock.picking` When a picking contains a lot (> 10000) of stock move line,…
Bounch of fixes to improve the performance of `_action_validate`. [FIX] stock: improve perf of `_compute_has_packages` of `stock.picking` When a picking contains a lot (> 10000) of stock move line, the time to open the picking become a issue (for 50000 sml, +- 6.5 sec) because of the `_compute_has_packages`. Use a search with a limit=1 to avoid fetching all `stock.move.line` with `result_package_id` (for 50000 sml, +- 2.5 sec). backport of 8551836af8935f8f2badb0322c7032be7bff37ea [FIX] stock: avoid flush all env in quants update Issue: The `_update_available_quantity` will flush the all environment due to the savepoint (at each call). When we working with the package, it becomes bottleneck due to the `_compute_package_info`. Indeed, it computes two compute store field (`location_id` and `company_id`) and depends of multiple field of related quants `quants_ids.xxx`. It means that each time we enter/exit in the savepoint to update quants, this compute will be execute (because of flush + compute_store). Solution: Avoid flushing when enter in the savepoint of `_update_available_quantity` (`flush=False`) backport of 8e7c0e544a8d3d18c57634750ee7ea03052c84b1 [FIX] stock: add index on `lot_id` of `stock.quant` For validate 5K stock move line with SN: Without index: 200 sec of SQL execution With index: 15 of SQL execution [FIX] stock: `_action_done` with OrderedSet for scalability Make more scalable the `_action_done` by replacing recordset/union by OrderedSet/add. [FIX] stock: batch create of lots in `_action_done` [FIX] stock_account: fix performance of `_get_in_move_lines` stock.move can contain thousands of move_line. Then to covers that case change the orderset union by a OrderedSet. opw-2347525 Forward-Port-Of: odoo/odoo#63737 Forward-Port-Of: odoo/odoo#62913
When attempting to resize or crop an attachment through the '/web/image' route, if the attachment isn't actually an image (even if the record's mimetype says so) or doesn't match one of the format supported by PIL (Python Imaging Library) - like Apple's HEIF - the request crashes with a "500 Internal Error". Although it makes sense to return a response with an HTTP error code, a more sensible approach would be to return a "404 Not Found" response instead. The point by handling the E
Original PR description
When attempting to resize or crop an attachment through the '/web/image' route, if the attachment isn't actually an image (even if the record's mimetype says so) or doesn't match one of the format…
When attempting to resize or crop an attachment through the '/web/image' route, if the attachment isn't actually an image (even if the record's mimetype says so) or doesn't match one of the format supported by PIL (Python Imaging Library) - like Apple's HEIF - the request crashes with a "500 Internal Error". Although it makes sense to return a response with an HTTP error code, a more sensible approach would be to return a "404 Not Found" response instead. The point by handling the Exception thrown by PIL and returning a 404 status code is to more closely match the semantic of this HTTP status code. Getting a resized version of a non-image doesn't really make sense as this resource doesn't exist at all ; hence the "404 Not Found" response. On the other hand returning a "500 Internal Error" would denote that a legitimate request failed on the server side, which is not the case here. Note: this difference of semantic, even if only visible in a regular browser, has its importance in the mobile apps because we use it to given a meaningful feedback to the user in case if failed HTTP requests. Note: the mimetype detection could be improved to ease the handling of this kind of errors but would require too much changes to be done in stable branch. Steps to reproduce in Documents: - rename an HEIF file with a ".jpeg" extension - upload it in documents - select the document in kanban view => the thumbnail in the document inspector (right panel) throws an HTTP error 500 Steps to reproduce in Discuss: - rename an HEIF file with a ".jpeg" extension - upload it in a chat window => the thumbnail in the chat window throws an HTTP error 500 opw-2417172 Forward-Port-Of: odoo/odoo#63759 Forward-Port-Of: odoo/odoo#63739
When adding a credit note, the user can only select the "Partial Refund" credit method. To reproduce the error: 1. Go to Invoicing 2. Create a new one - Add at least one invoice line 3. Save, Confirm 4. Click on "Add Credit Note" => You can not change the credit method. The method field is editable only when the residual amount is different from 0. Here is the issue: when clicking on "Add Credit Note", it actually triggers some `onchange` methods. The latter uses a new record
Original PR description
When adding a credit note, the user can only select the "Partial Refund" credit method. To reproduce the error: 1. Go to Invoicing 2. Create a new one - Add at least one invoice line 3. Save, Confirm…
When adding a credit note, the user can only select the "Partial Refund" credit method. To reproduce the error: 1. Go to Invoicing 2. Create a new one - Add at least one invoice line 3. Save, Confirm 4. Click on "Add Credit Note" => You can not change the credit method. The method field is editable only when the residual amount is different from 0. Here is the issue: when clicking on "Add Credit Note", it actually triggers some `onchange` methods. The latter uses a new record to compute the values: https://github.com/odoo/odoo/blob/45422d56bce413b8577f1784e10dd22ede93c751/odoo/models.py#L6147-L6148 Then, some `_compute` methods are also triggered. Among them, the amount residual computation of the associated `account_move_line`. However, `_compute_amount_residual` will skip the not-yet-created objects and set the amount residual to 0. This is the reason why the residual amount of the account move is zero and therefore, the user can't change the credit method. OPW-2418582 Forward-Port-Of: odoo/odoo#63674
When attempting to resize or crop an attachment through the '/web/image' route, if the attachment isn't actually an image (even if the record's mimetype says so) or doesn't match one of the format supported by PIL (Python Imaging Library) - like Apple's HEIF - the request crashes with a "500 Internal Error". Although it makes sense to return a response with an HTTP error code, a more sensible approach would be to return a "404 Not Found" response instead. The point by handling the E
Original PR description
When attempting to resize or crop an attachment through the '/web/image' route, if the attachment isn't actually an image (even if the record's mimetype says so) or doesn't match one of the format…
When attempting to resize or crop an attachment through the '/web/image' route, if the attachment isn't actually an image (even if the record's mimetype says so) or doesn't match one of the format supported by PIL (Python Imaging Library) - like Apple's HEIF - the request crashes with a "500 Internal Error". Although it makes sense to return a response with an HTTP error code, a more sensible approach would be to return a "404 Not Found" response instead. The point by handling the Exception thrown by PIL and returning a 404 status code is to more closely match the semantic of this HTTP status code. Getting a resized version of a non-image doesn't really make sense as this resource doesn't exist at all ; hence the "404 Not Found" response. On the other hand returning a "500 Internal Error" would denote that a legitimate request failed on the server side, which is not the case here. Note: this difference of semantic, even if only visible in a regular browser, has its importance in the mobile apps because we use it to given a meaningful feedback to the user in case if failed HTTP requests. Note: the mimetype detection could be improved to ease the handling of this kind of errors but would require too much changes to be done in stable branch. Steps to reproduce in Documents: - rename an HEIF file with a ".jpeg" extension - upload it in documents - select the document in kanban view => the thumbnail in the document inspector (right panel) throws an HTTP error 500 opw-2417172 X-original-commit: odoo/odoo@c132f06911a44b95ef559b8c65a1a0bce6a8f6c7 Forward-Port-Of: odoo/enterprise#15452 Forward-Port-Of: odoo/enterprise#15446
…gue effective 28/12/2020 TASK ID: 2421441 Forward-Port-Of: odoo/enterprise#15441
Original PR description
…gue effective 28/12/2020 TASK ID: 2421441 Forward-Port-Of: odoo/enterprise#15441