diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-10-21 09:40:37 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-10-21 09:40:37 +0700 |
| commit | b48a351927af1dfde51d9f7cbced19c8d84c9152 (patch) | |
| tree | b62c38341d38ffc78bb780230740bba4d97dd031 /indoteknik_custom/models/stock_picking.py | |
| parent | 752768d6cc29a231b47637653d4f3e4e293a4590 (diff) | |
Internal Use Approval
Diffstat (limited to 'indoteknik_custom/models/stock_picking.py')
| -rw-r--r-- | indoteknik_custom/models/stock_picking.py | 18 |
1 files changed, 18 insertions, 0 deletions
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 |
