From bd02610d6d148eee0196555abb2eac00670dfd2e Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Mon, 6 Feb 2023 13:23:18 +0700 Subject: only accounting can post or reset to draft invoices --- indoteknik_custom/models/account_move.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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: -- cgit v1.2.3