From 844cfbdf7a961dddb8c6c0b63f1dcaf72bc84f51 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Wed, 14 Aug 2024 09:44:48 +0700 Subject: arrival_time do --- indoteknik_custom/models/stock_picking.py | 15 ++++++++++++++- indoteknik_custom/views/res_partner.xml | 9 +++++++++ indoteknik_custom/views/stock_picking.xml | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 47ac3166..9fb4ae82 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -28,6 +28,10 @@ class StockPicking(models.Model): string='Driver Departure Date', copy=False ) + arrival_time = fields.Datetime( + string='Jam Kedatangan', + copy=False + ) driver_arrival_date = fields.Datetime( string='Driver Arrival Date', readonly=True, @@ -98,9 +102,14 @@ class StockPicking(models.Model): ], string='Invoice Status', related="sale_id.invoice_status") @api.constrains('driver_departure_date') - def constrains_driver_departure_date(self): + def constrains_driver_departure_date(self): self.date_doc_kirim = self.driver_departure_date + @api.constrains('arrival_time') + def constrains_arrival_time(self): + if self.arrival_time > datetime.datetime.utcnow(): + raise UserError('Jam kedatangan harus kurang dari Effective Date') + def reset_status_printed(self): for rec in self: rec.status_printed = 'not_printed' @@ -350,6 +359,9 @@ class StockPicking(models.Model): if not self.picking_code: self.picking_code = self.env['ir.sequence'].next_by_code('stock.picking.code') or '0' + if not self.arrival_time: + raise UserError('Jam Kedatangan harus diisi') + if self.picking_type_id.code == 'incoming' and self.group_id.id == False and self.is_internal_use == False: raise UserError(_('Tidak bisa Validate jika tidak dari Document SO / PO')) @@ -381,6 +393,7 @@ class StockPicking(models.Model): res = super(StockPicking, self).button_validate() self.calculate_line_no() + self.date_done = datetime.datetime.utcnow() return res @api.model diff --git a/indoteknik_custom/views/res_partner.xml b/indoteknik_custom/views/res_partner.xml index 8bacd2d2..bfac1eb3 100644 --- a/indoteknik_custom/views/res_partner.xml +++ b/indoteknik_custom/views/res_partner.xml @@ -26,6 +26,15 @@ + + 1 + + + 1 + + + 1 + diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index a58f3003..899d29eb 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -68,6 +68,9 @@ + + + -- cgit v1.2.3