diff options
| author | Azka Nathan <darizkyfaz@gmail.com> | 2024-01-10 11:10:50 +0700 |
|---|---|---|
| committer | Azka Nathan <darizkyfaz@gmail.com> | 2024-01-10 11:10:50 +0700 |
| commit | 5005eebb8fdd82db1e65a1d3de715d8bb5a63b32 (patch) | |
| tree | 3d1e2c2ad6ef35f7069116584e90e624551b8024 /indoteknik_custom/models/stock_picking.py | |
| parent | 893fbb7a4d1467686c4de435393f1162c4d04bd7 (diff) | |
IU minus inventory validation
Diffstat (limited to 'indoteknik_custom/models/stock_picking.py')
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 13 |
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() |
