summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/stock_picking.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2024-10-16 10:29:16 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2024-10-16 10:29:16 +0700
commit0f11923903736a7ccbfc6df815103f890d55d7e9 (patch)
treefae1174a4f58be9adcc82c2c205295033d22f808 /indoteknik_custom/models/stock_picking.py
parent53e39ccf1780beda4f27ae2e67566d57ac915654 (diff)
add state reserve on stock.picking
Diffstat (limited to 'indoteknik_custom/models/stock_picking.py')
-rw-r--r--indoteknik_custom/models/stock_picking.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py
index 14190474..33e577bc 100644
--- a/indoteknik_custom/models/stock_picking.py
+++ b/indoteknik_custom/models/stock_picking.py
@@ -101,6 +101,13 @@ class StockPicking(models.Model):
('no', 'Nothing to Invoice')
], string='Invoice Status', related="sale_id.invoice_status")
+ state_reserve = fields.Selection([
+ ('waiting', 'Waiting For Fullfilment'),
+ ('ready', 'Ready to Ship'),
+ ('done', 'Done'),
+ ('cancel', 'Cancelled'),
+ ], string='Status Reserve', readonly=True, tracking=True, help="The current state of the stock picking.")
+
@api.constrains('driver_departure_date')
def constrains_driver_departure_date(self):
self.date_doc_kirim = self.driver_departure_date
@@ -134,9 +141,18 @@ class StockPicking(models.Model):
res = super(StockPicking, self).do_unreserve()
current_time = datetime.datetime.utcnow()
self.date_unreserve = current_time
+ self.check_state_reserve()
return res
+ def check_state_reserve(self):
+ self.state_reserve = 'ready'
+
+ for line in self.move_ids_without_package:
+ if line.product_uom_qty > line.reserved_availability:
+ self.state_reserve = 'waiting'
+ break
+
def _create_approval_notification(self, approval_role):
title = 'Warning'
message = f'Butuh approval sales untuk unreserved'
@@ -275,6 +291,7 @@ class StockPicking(models.Model):
current_time = datetime.datetime.utcnow()
self.real_shipping_id = self.sale_id.real_shipping_id
self.date_availability = current_time
+ self.check_state_reserve()
return res
def ask_approval(self):
@@ -421,6 +438,7 @@ class StockPicking(models.Model):
res = super(StockPicking, self).button_validate()
self.calculate_line_no()
self.date_done = datetime.datetime.utcnow()
+ self.state_reserve = 'done'
return res
@api.model