summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-11-17 17:20:16 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-11-17 17:20:16 +0700
commitfa27a62a2ecc046020e57849838b633d78a99c36 (patch)
treeae3b6a4860750b860f7a7d38d4b88cfd7f4a2495
parent390cc9e5b2e2b02eecb37472d4362c829a3745db (diff)
add validation for calendar
-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 2bdfbd9e..dc30570e 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -118,6 +118,19 @@ class StockPicking(models.Model):
if self.is_internal_use and not self.env.user.is_accounting:
raise UserError("Harus di Approve oleh Accounting")
+ if self.is_internal_use:
+ stock_move_lines = self.env['stock.move.line'].search([
+ ('picking_id', '!=', False),
+ ('product_id', '=', 236805),
+ ('picking_id.partner_id', '=', self.partner_id.id),
+ ('qty_done', '>', 0),
+ ])
+ list_state = ['confirmed', 'done']
+ for stock_move_line in stock_move_lines:
+ if stock_move_line.picking_id.state not in list_state:
+ continue
+ raise UserError('Sudah pernah dikirim kalender')
+
for line in self.move_line_ids_without_package:
if line.move_id.sale_line_id and self.picking_type_id.code == 'outgoing':
if line.move_id.sale_line_id.qty_delivered + line.qty_done > line.move_id.sale_line_id.product_uom_qty: