summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-02-06 13:23:18 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-02-06 13:23:18 +0700
commitbd02610d6d148eee0196555abb2eac00670dfd2e (patch)
tree3a1fda01cbdd702f9624fad8e8b16523eb1f9ab2
parent46e2f58040b6611e3c9106a5ec7b97e52f67a84d (diff)
only accounting can post or reset to draft invoices
-rw-r--r--indoteknik_custom/models/account_move.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index 1e0c56cf..54e51dcf 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -1,4 +1,5 @@
from odoo import models, api, fields
+from odoo.exceptions import AccessError, UserError, ValidationError
from datetime import timedelta
@@ -12,6 +13,18 @@ class AccountMove(models.Model):
date_terima_tukar_faktur = fields.Date(string='Terima Faktur')
shipper_faktur_id = fields.Many2one('delivery.carrier', string='Shipper Faktur')
+ def button_draft(self):
+ res = super(AccountMove, self).button_draft()
+ if not self.env.user.is_accounting:
+ raise UserError('Hanya Accounting yang bisa Reset to Draft')
+ return res
+
+ def action_post(self):
+ res = super(AccountMove, self).action_post()
+ if not self.env.user.is_accounting:
+ raise UserError('Hanya Accounting yang bisa Posting')
+ return res
+
@api.onchange('date_kirim_tukar_faktur')
def change_date_kirim_tukar_faktur(self):
for invoice in self: