Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion stock_orderpoint_manual_update/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
##############################################################################
from . import models
from . import wizard
from odoo import api, SUPERUSER_ID


def uninstall_hook(env):
Expand Down
4 changes: 2 additions & 2 deletions stock_orderpoint_manual_update/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand All @@ -43,7 +43,7 @@
],
},
"uninstall_hook": "uninstall_hook",
"installable": False,
"installable": True,
"auto_install": False,
"application": False,
}
31 changes: 21 additions & 10 deletions stock_orderpoint_manual_update/models/stock_orderpoint.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from odoo import fields, models
from odoo.osv import expression
from odoo.fields import Domain


class StockWarehouseOrderpoint(models.Model):
Expand All @@ -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))

Expand All @@ -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,
Expand All @@ -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")
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from odoo import fields, models
from odoo.osv import expression
from odoo.fields import Domain


class StockWarehouseOrderpointWizard(models.TransientModel):
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<field name="model">stock.warehouse.orderpoint.wizard</field>
<field name="arch" type="xml">
<form string="Replenishment Filter Wizard">
<div colspan="2" class="alert alert-info" role="status" invisible="category_ids == [] or product_ids == [] or supplier_ids == [] or location_ids == []">
<div colspan="2" class="alert alert-info" role="status" invisible="not category_ids or not product_ids or not supplier_ids or not location_ids">
<p><i class="fa fa-info-circle"/>This action will create replenishment lines for products that matches this criteria.</p>
</div>
<group>
Expand All @@ -18,7 +18,7 @@
</group>
<group col="2">
<field name="supplier_ids" widget="many2many_tags" context="{'res_partner_search_mode': 'supplier'}"></field>
<field name="filter_by_main_supplier" invisible="supplier_ids == []"></field>
<field name="filter_by_main_supplier" invisible="not supplier_ids"></field>
<field name="location_ids" widget="many2many_tags"/>
</group>
</group>
Expand Down