diff --git a/stock_orderpoint_manual_update/__init__.py b/stock_orderpoint_manual_update/__init__.py index 290e30086..752d189f1 100644 --- a/stock_orderpoint_manual_update/__init__.py +++ b/stock_orderpoint_manual_update/__init__.py @@ -4,7 +4,6 @@ ############################################################################## from . import models from . import wizard -from odoo import api, SUPERUSER_ID def uninstall_hook(env): diff --git a/stock_orderpoint_manual_update/__manifest__.py b/stock_orderpoint_manual_update/__manifest__.py index 95be8f4d5..bb1afcb1f 100644 --- a/stock_orderpoint_manual_update/__manifest__.py +++ b/stock_orderpoint_manual_update/__manifest__.py @@ -19,7 +19,7 @@ ############################################################################## { "name": "Stock Orderpoint Manual Update", - "version": "18.0.1.1.0", + "version": "19.0.1.0.0", "category": "Warehouse Management", "sequence": 14, "summary": "", @@ -43,7 +43,7 @@ ], }, "uninstall_hook": "uninstall_hook", - "installable": False, + "installable": True, "auto_install": False, "application": False, } diff --git a/stock_orderpoint_manual_update/models/stock_orderpoint.py b/stock_orderpoint_manual_update/models/stock_orderpoint.py index 82b14c3b5..ad96aea97 100644 --- a/stock_orderpoint_manual_update/models/stock_orderpoint.py +++ b/stock_orderpoint_manual_update/models/stock_orderpoint.py @@ -1,5 +1,5 @@ from odoo import fields, models -from odoo.osv import expression +from odoo.fields import Domain class StockWarehouseOrderpoint(models.Model): @@ -25,20 +25,20 @@ def update_qty_forecast(self): rec.qty_forecast_stored = rec.qty_forecast def _get_orderpoint_products(self): - domain = [("type", "=", "product"), ("stock_move_ids", "!=", False)] + domain = [("is_storable", "=", True), ("stock_move_ids", "!=", False)] # Filter by suppliers - suppliers_ids = self._context.get("filter_suppliers") + suppliers_ids = self.env.context.get("filter_suppliers") if suppliers_ids: domain.append(("seller_ids.partner_id", "in", suppliers_ids)) # Filter by product categories - category_ids = self._context.get("filter_categories") + category_ids = self.env.context.get("filter_categories") if category_ids: domain.append(("categ_id", "in", category_ids)) # Filter by products - product_ids = self._context.get("filter_products") + product_ids = self.env.context.get("filter_products") if product_ids: domain.append(("id", "in", product_ids)) @@ -47,16 +47,19 @@ def _get_orderpoint_products(self): def _get_orderpoint_locations(self): domain = [("replenish_location", "=", True)] # Filter by locations - location_ids = self._context.get("filter_locations") + location_ids = self.env.context.get("filter_locations") if location_ids: domain.append(("id", "in", location_ids)) return self.env["stock.location"].search(domain) def action_replenish(self): - super().action_replenish() + notification = super().action_replenish() + # Si el super devuelve una notificación (para transferencias inter-warehouse), la devolvemos + if notification: + return notification action = self.with_context()._get_orderpoint_action() orderpoint_domain = self.with_context().env["stock.warehouse.orderpoint.wizard"].get_orderpoint_domain() - action["domain"] = expression.AND( + action["domain"] = Domain.AND( [ action.get("domain", "[]"), orderpoint_domain, @@ -65,7 +68,15 @@ def action_replenish(self): return action def update_qty_to_order_orderpoint(self): - # Esto lo hacemos ya que el metodo es privado y no podemos llamarlo luego en el .js + """ + Updates qty_to_order for orderpoints. + In v19, qty_to_order is a computed field that depends on qty_to_order_computed (stored) + and qty_to_order_manual. We invalidate the cache to force recalculation. + """ valid_orderpoints = self.exists() if valid_orderpoints: - valid_orderpoints._compute_qty_to_order() + # Invalidate cache to force recalculation instead of direct compute + # This avoids concurrency issues during scheduler execution + valid_orderpoints.invalidate_recordset(["qty_to_order_computed", "qty_to_order"]) + # Access the field to safely trigger compute + valid_orderpoints.mapped("qty_to_order") diff --git a/stock_orderpoint_manual_update/wizard/stock_warehouse_orderpoint_wizard.py b/stock_orderpoint_manual_update/wizard/stock_warehouse_orderpoint_wizard.py index c6e1270c6..17cfd8b5a 100644 --- a/stock_orderpoint_manual_update/wizard/stock_warehouse_orderpoint_wizard.py +++ b/stock_orderpoint_manual_update/wizard/stock_warehouse_orderpoint_wizard.py @@ -1,5 +1,5 @@ from odoo import fields, models -from odoo.osv import expression +from odoo.fields import Domain class StockWarehouseOrderpointWizard(models.TransientModel): @@ -31,7 +31,7 @@ def action_confirm(self): if self.compute_rotation: orderpoints._compute_rotation() orderpoints._change_review_toggle_negative() - action["domain"] = expression.AND( + action["domain"] = Domain.AND( [ action.get("domain", "[]"), orderpoint_domain, diff --git a/stock_orderpoint_manual_update/wizard/stock_warehouse_orderpoint_wizard_views.xml b/stock_orderpoint_manual_update/wizard/stock_warehouse_orderpoint_wizard_views.xml index c445fef58..2242859a3 100644 --- a/stock_orderpoint_manual_update/wizard/stock_warehouse_orderpoint_wizard_views.xml +++ b/stock_orderpoint_manual_update/wizard/stock_warehouse_orderpoint_wizard_views.xml @@ -6,7 +6,7 @@ stock.warehouse.orderpoint.wizard
-
+

This action will create replenishment lines for products that matches this criteria.

@@ -18,7 +18,7 @@ - +