diff options
Diffstat (limited to 'fixco_custom/models/account_move.py')
| -rw-r--r-- | fixco_custom/models/account_move.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/fixco_custom/models/account_move.py b/fixco_custom/models/account_move.py index e40e65f..b96bed3 100644 --- a/fixco_custom/models/account_move.py +++ b/fixco_custom/models/account_move.py @@ -47,6 +47,29 @@ class AccountMove(models.Model): compute="_compute_need_refund", help="Flag otomatis kalau invoice sudah paid dan picking terkait di-return." ) + approval_refund = fields.Selection( + [('approved', 'Approved'), + ('rejected', 'Rejected'), + ('pending', 'Pending')], + string='Approval Refund', + copy=False, + tracking=True + ) + + def reject_refund(self): + if self.move_type == 'entry' and self.sale_id and self.ref.startswith('UANG MUKA PENJUALAN') and self.env.user.id in [9, 10, 15]: + self.approval_refund = 'rejected' + else: + raise UserError(_('Anda tidak memiliki akses untuk melakukan reject Uang Muka Penjualan!')) + + # def approve_refund(self): + # if self.move_type == 'entry' and self.sale_id and self.ref.startswith('UANG MUKA PENJUALAN') and self.env.user.id in [9, 10, 15]: + # self.approval_refund = 'approved' + # else: + # raise UserError(_('Anda tidak memiliki akses untuk melakukan approve Uang Muka Penjualan!')) + + def pending_refund(self): + self.approval_refund = 'pending' def queue_job_cancel_bill(self): QueueJob = self.env['queue.job'] @@ -73,7 +96,19 @@ class AccountMove(models.Model): 'res_id': move.id, } ]) - + + def button_draft(self): + if self.env.user.id not in [24, 13, 10, 2, 9, 15, 8]: + raise UserError("Hanya Finance yang bisa ubah Draft") + res = super(AccountMove, self).button_draft() + return res + + def button_cancel(self): + if self.env.user.id not in [24, 13, 10, 2, 9, 15, 8]: + raise UserError('Hanya Accounting yang bisa Cancel') + res = super(AccountMove, self).button_cancel() + + return res def _compute_need_refund(self): for move in self: @@ -223,6 +258,8 @@ class AccountMove(models.Model): } def action_post(self): + if self.env.user.id not in [24, 13, 10, 2, 9, 15, 8]: + raise UserError('Hanya Accounting yang bisa Post') res = super(AccountMove, self).action_post() for entry in self: if entry.move_type == 'out_invoice': |
