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 ++++++++++++++++++ indoteknik_custom/models/users.py | 1 + indoteknik_custom/views/stock_picking.xml | 7 +++++++ indoteknik_custom/views/users.xml | 1 + 4 files changed, 27 insertions(+) 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 diff --git a/indoteknik_custom/models/users.py b/indoteknik_custom/models/users.py index bc56fe54..4904a33d 100644 --- a/indoteknik_custom/models/users.py +++ b/indoteknik_custom/models/users.py @@ -8,3 +8,4 @@ class Users(models.Model): is_purchasing_manager = fields.Boolean(String='Purchasing Manager', help='Berhak melakukan Approval PO') is_sales_manager = fields.Boolean(String='Sales Manager', help='Berhak melakukan Approval SO dengan margin 15-25') is_leader = fields.Boolean(String='Leader', help='Berhak Approval SO Margin < 15 dan Approval PO') + is_accounting = fields.Boolean(String='Accounting', help='Berhak Approval Internal Use') diff --git a/indoteknik_custom/views/stock_picking.xml b/indoteknik_custom/views/stock_picking.xml index 5f78ea57..1b648d58 100644 --- a/indoteknik_custom/views/stock_picking.xml +++ b/indoteknik_custom/views/stock_picking.xml @@ -6,6 +6,12 @@ stock.picking +