summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-02-11 16:18:57 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-02-11 16:18:57 +0700
commiteeff963c94f4d933b89308f40b387fd67ef881c4 (patch)
tree9700443aaf5c93935386ca1bfc00c40ac8518004
parent751645803b13cbc96d4a554a9c9d8a63cd991486 (diff)
fix bug backorder state reserve
-rw-r--r--indoteknik_custom/models/stock_picking.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index b1b1bdb8..f49c493c 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -470,6 +470,38 @@ class StockPicking(models.Model):
('state', 'not in', ['cancel', 'draft', 'done']),
('picking_type_code', '=', 'outgoing')
])
+
+ count = self.search_count([
+ ('state', 'not in', ['cancel', 'draft', 'done']),
+ ('picking_type_code', '=', 'outgoing')
+ ])
+
+ for picking in pickings:
+ fullfillments = self.env['sales.order.fulfillment.v2'].search([
+ ('sale_order_id', '=', picking.sale_id.id)
+ ])
+
+ picking.state_reserve = 'ready'
+ picking.date_reserved = picking.date_reserved or datetime.datetime.utcnow()
+
+ if any(rec.so_qty != rec.reserved_stock_qty for rec in fullfillments):
+ picking.state_reserve = 'waiting'
+ picking.date_reserved = ''
+
+ self.check_state_reserve_backorder()
+
+ def check_state_reserve_backorder(self):
+ pickings = self.search([
+ ('backorder_id', '!=', False),
+ ('picking_type_code', '=', 'outgoing'),
+ ('state', 'not in', ['cancel', 'draft', 'done'])
+ ])
+
+ count = self.search_count([
+ ('backorder_id', '!=', False),
+ ('picking_type_code', '=', 'outgoing'),
+ ('state', 'not in', ['cancel', 'draft', 'done'])
+ ])
for picking in pickings:
fullfillments = self.env['sales.order.fulfillment.v2'].search([