diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2024-10-16 15:47:07 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2024-10-16 15:47:07 +0700 |
| commit | 8914f55dba0a2d4a1e992c9d0635ae993950bcf1 (patch) | |
| tree | f41be6b8474db4f61e0122c68614a191829e39cf /indoteknik_custom/models/stock_picking.py | |
| parent | d7f4569c5d2dcda1316ca4ef37fed53f467df9df (diff) | |
| parent | a1b2542ebc2d527d07edbcbaab467152a46f1d33 (diff) | |
Merge branch 'production' into feature/generate_url
Diffstat (limited to 'indoteknik_custom/models/stock_picking.py')
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 14190474..1b2baea7 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,24 @@ 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): + do = self.search([ + ('state', 'not in', ['cancel', 'draft', 'done']), + ('picking_type_code', '=', 'outgoing') + ]) + + for rec in do: + rec.state_reserve = 'ready' + + for line in rec.move_ids_without_package: + if line.product_uom_qty > line.reserved_availability: + rec.state_reserve = 'waiting' + break + def _create_approval_notification(self, approval_role): title = 'Warning' message = f'Butuh approval sales untuk unreserved' @@ -275,6 +297,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 +444,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 |
