From b48a351927af1dfde51d9f7cbced19c8d84c9152 Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Fri, 21 Oct 2022 09:40:37 +0700 Subject: Internal Use Approval --- indoteknik_custom/models/stock_picking.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'indoteknik_custom/models/stock_picking.py') diff --git a/indoteknik_custom/models/stock_picking.py b/indoteknik_custom/models/stock_picking.py index 221aff31..70e9b68a 100644 --- a/indoteknik_custom/models/stock_picking.py +++ b/indoteknik_custom/models/stock_picking.py @@ -43,6 +43,22 @@ class StockPicking(models.Model): copy=False ) + approval_status = fields.Selection([ + ('pengajuan1', 'Approval Accounting'), + ('approved', 'Approved'), + ], string='Approval Status', readonly=True, copy=False, index=True, tracking=3) + + def ask_approval(self): + if self.env.user.is_accounting: + raise UserError("Bisa langsung Validate") + for pick in self: + if not pick.is_internal_use: + raise UserError("Selain Internal Use bisa langsung Validate") + for line in pick.move_line_ids_without_package: + if line.qty_done <= 0: + raise UserError("Qty tidak boleh 0") + pick.approval_status = 'pengajuan1' + def calculate_line_no(self): line_no = 0 for picking in self: @@ -74,6 +90,8 @@ class StockPicking(models.Model): def button_validate(self): 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')) + if self.is_internal_use and not self.env.user.is_accounting: + raise UserError("Harus di Approve oleh Accounting") res = super(StockPicking, self).button_validate() return res -- cgit v1.2.3