[MIG] stock_by_warehouse_sale: Migration to 19.0 T#98915#1732
Open
rolandojduartem wants to merge 18 commits into
Open
[MIG] stock_by_warehouse_sale: Migration to 19.0 T#98915#1732rolandojduartem wants to merge 18 commits into
rolandojduartem wants to merge 18 commits into
Conversation
ebb463a to
6f168c1
Compare
Contributor
Author
|
Hi, @luisg123v and @desdelinux, please, could you review it? this depends on #1731 |
|
@luisg123v review |
luisg123v
requested changes
May 26, 2026
| "demo": [], | ||
| "test": [], | ||
| "installable": True, | ||
| "auto_install": False, |
Contributor
There was a problem hiding this comment.
Do this in the source version, similar as done in #1730.
| def _compute_warehouse_stock(self): | ||
| for record in self: | ||
| record.warehouse_id = self.order_id.warehouse_id | ||
| record.warehouse_id = record.order_id.warehouse_id |
Contributor
There was a problem hiding this comment.
This is a fix, do it in the source version.
|
|
||
| @tagged("sale_order", "post_install", "-at_install") | ||
| class TestStockByWarehouseSale(TransactionCase): | ||
| """Test suite to verify warehouse stock reporting functionality in sales orders.""" |
Contributor
There was a problem hiding this comment.
Superfluous docstring, remove.
Same in similar cases like the setUpClass
| super().setUpClass() | ||
| cls.company = cls.env.company | ||
| cls.partner = cls.env["res.partner"].create({"name": "Test Customer"}) | ||
| cls.warehouse = cls.env["stock.warehouse"].search([("company_id", "=", cls.company.id)], limit=1) |
Contributor
There was a problem hiding this comment.
Doesn't it have an external ID?
| ) | ||
| cls.env["stock.quant"]._update_available_quantity(cls.product, cls.warehouse.lot_stock_id, 10.0) | ||
|
|
||
| def test_sale_order_line_warehouse_stock(self) -> None: |
|
|
||
| sale_order_line = self.env["sale.order.line"].create( | ||
| { | ||
| "order_id": sale_order.id, |
Contributor
There was a problem hiding this comment.
Create it inside the order's vals, using Command.create. That would be more accurate, as usually both are created at the same time.
…warehouse Ensure the JSON stock calculation methods in both product.product and product.template robustly handle context values of 'warehouse_id' that are integers or sequences of integers by automatically browsing them into standard recordsets. This prevents stock calculation issues when Odoo's core query compiler (which expects integer IDs in context for '_get_domain_locations') is invoked by caller modules.
…ad (Vauxoo#1358) We need avoid using compute fields as possible because of the following issue: - odoo/odoo#30578 warehouses_stock is a computed field used just one time but re-computed too many times: - Opening sale order (one time by each line) - Saving sale order - Choosing a product_id And it computation is more and more slow when the database grows. It is making a big overhead saving sale.order. With this change we have the same behaviour using it just for onchange product_id or forcing from a seudo-button (field boolean) A real button is not used since that it requires save the record to work Using the technical of fields with store=False and onchange methods Check more details from Vauxoo#1358
In order to get the real value, since that this field is not set when onchange method is used
The following is performed: - Remove useless test that actually did nothing - Remove data tags from views - Remove encoding headers from Python files - Remove superfluous readonly attribute from related fields - Remove useless keys from the manifest - Fix typos on the README
* [I18N] stock_by_warehouse_sale: Fix term names Some term names are handled differently on v12.0, but those changes were not taken into account when migrating this module from v11.0. * [I18N] stock_by_warehouse_purchase: Fix term names Some term names are handled differently on v12.0, but those changes were not taken into account when migrating this module from v11.0.
This removes: - Hencoding headers, fixing lint `utf8-coding-comment` - Headers like `# Part of Odoo` - And other ones
In previous Odoo versions, the form view was poped up when editing a sale order line, as long as the option "Manage Product packaging" was enabled. This is no longer the case [1], so we re-enable it manually, in order to be able to see current inventory when filling a line. [1] odoo/odoo@e813487e75f1
…able products This functionality is for storable products to show the information in the warehouses, now this field is invisible for products which are not storable products.
- Simplify the way to define modifiers as states, required, readonly, invisible and column_invisible as part of [1]. - Adapt the stock by warehouse field to be computed. [1] odoo/odoo#104741
…tock compute Fix a multi-record issue in _compute_warehouse_stock where 'self' was incorrectly referenced instead of the loop variable 'record' when assigning warehouse_id. This prevented correct evaluation and raised singleton errors on multi-line actions. Additionally, remove redundant empty/default keys from the manifest.
Migrate the module to Odoo 19.0 to ensure the warehouse stock overview feature remains fully operational in sales orders. Changes have been introduced to align with the framework shifts: - Adopt Odoo 19.0's view simplifications [1], where the `tree` view was renamed to `list` view. - Support Odoo 19.0's simplified product type logic [2], where physical products are identified by the `is_storable` flag instead of the legacy `type == 'product'`. - Fix a multi-record context bug in the compute method where looping over `self` was incorrectly referencing the collective `self.order_id`. Looping with `record.order_id` prevents incorrect values and performance loss when processing multiple sale order lines at once. - Clean up manifest keys that match default values to comply with the updated linter guidelines. [1]: odoo/odoo@4d5e84f7 [2]: odoo/odoo@728d9f83
6f168c1 to
4223655
Compare
Contributor
Author
|
@luisg123v done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This migration adapts the
stock_by_warehouse_salemodule to Odoo 19.0, updating its metadata, view structure, context passing, and test suite to align with Odoo 19.0 standards.Changes
1. View Adaptation & Formats (
views/sale_order_views.xml)listto match Odoo 19.0 view architecture changes (//field[@name='order_line']/list).product_type != 'product'visibility check with the Odoo 19.0 standardnot is_storableinside the alert widget layout.editable="bottom") by removing theeditableattribute.2. Context Passing Fix (
models/sale_order_line.py)_compute_get_warehouses_stock) to pass the raw integerline.warehouse_id.idin context instead of the full recordset._get_domain_locations), resolving a silent warning and preventing the inline widget from displaying incorrect0.00values while displaying correct stock levels in the dropdown.record.warehouse_idwas set correcting the assignment path dynamically.3. Manifest (
__manifest__.py)19.0.1.0.0.4. Robust Deterministic Unit Tests (
tests/test_sale_order.py)TestStockByWarehouseSale) validating the warehouse stock calculation and recomputation functionality.warehouses_stock_recomputefield instead of manually invoking calculations.invalidate_recordset(), ensuring solid and repeatable test executions.Testing
Procedure to verify the migration and context correction:
is_storable = True).10.00).warehouses_stock_recomputecheckbox on the sale order line form.