summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/stock_picking.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-01-10 11:10:50 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-01-10 11:10:50 +0700
commit5005eebb8fdd82db1e65a1d3de715d8bb5a63b32 (patch)
tree3d1e2c2ad6ef35f7069116584e90e624551b8024 /indoteknik_custom/models/stock_picking.py
parent893fbb7a4d1467686c4de435393f1162c4d04bd7 (diff)
IU minus inventory validation
Diffstat (limited to 'indoteknik_custom/models/stock_picking.py')
-rw-r--r--indoteknik_custom/models/stock_picking.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index a5e533b1..0c810ef7 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -281,6 +281,17 @@ class StockPicking(models.Model):
self.is_internal_use = self.picking_type_id.is_internal_use
return
+ def validation_minus_onhand_quantity(self):
+ bu_location_id = 57
+ for line in self.move_line_ids_without_package:
+ quant = self.env['stock.quant'].search([
+ ('product_id', '=', line.product_id.id),
+ ('location_id', '=', bu_location_id)
+ ])
+
+ if quant and quant.inventory_quantity < line.product_uom_qty:
+ raise UserError('Quantity reserved lebih besar dari quantity onhand di product')
+
def button_validate(self):
if self._name != 'stock.picking':
return super(StockPicking, self).button_validate()
@@ -314,6 +325,8 @@ class StockPicking(models.Model):
if not self.date_reserved:
current_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
self.date_reserved = current_time
+
+ self.validation_minus_onhand_quantity()
res = super(StockPicking, self).button_validate()
self.calculate_line_no()