From 566a20db595a2b0a1959a12d289361b16e1ef172 Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Fri, 3 Nov 2023 13:42:51 +0700 Subject: add approval in editing reconcile & journal entries --- indoteknik_custom/__manifest__.py | 1 + indoteknik_custom/models/__init__.py | 3 ++- indoteknik_custom/models/account_bank_statement.py | 19 +++++++++++++ indoteknik_custom/models/account_move.py | 12 ++++++++- indoteknik_custom/models/users.py | 1 + indoteknik_custom/views/account_bank_statement.xml | 31 ++++++++++++++++++++++ indoteknik_custom/views/users.xml | 1 + 7 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 indoteknik_custom/models/account_bank_statement.py create mode 100644 indoteknik_custom/views/account_bank_statement.xml diff --git a/indoteknik_custom/__manifest__.py b/indoteknik_custom/__manifest__.py index 23abc084..b054d594 100755 --- a/indoteknik_custom/__manifest__.py +++ b/indoteknik_custom/__manifest__.py @@ -99,6 +99,7 @@ 'views/quotation_so_multi_update.xml', 'views/stock_move_line.xml', 'views/product_monitoring.xml', + 'views/account_bank_statement.xml', 'report/report.xml', 'report/report_banner_banner.xml', 'report/report_banner_banner2.xml', diff --git a/indoteknik_custom/models/__init__.py b/indoteknik_custom/models/__init__.py index 1133c3e7..23a7331c 100755 --- a/indoteknik_custom/models/__init__.py +++ b/indoteknik_custom/models/__init__.py @@ -89,4 +89,5 @@ from . import stock_scheduler_compute from . import promotion from . import sale_orders_multi_update from . import quotation_so_multi_update -from . import product_monitoring \ No newline at end of file +from . import product_monitoring +from . import account_bank_statement \ No newline at end of file diff --git a/indoteknik_custom/models/account_bank_statement.py b/indoteknik_custom/models/account_bank_statement.py new file mode 100644 index 00000000..495367e8 --- /dev/null +++ b/indoteknik_custom/models/account_bank_statement.py @@ -0,0 +1,19 @@ +from odoo import fields, models, api, _ +from odoo.exceptions import AccessError, UserError, ValidationError + +class AccountBankStatement(models.Model): + _inherit = "account.bank.statement" + + is_edit = fields.Boolean(string='Edit', default=False) + + def is_edited(self): + if not self.env.user.is_admin_reconcile: + raise UserError('Yang berhak hanya Mba Tania') + + self.is_edit = True + + def not_edited(self): + if not self.env.user.is_admin_reconcile: + raise UserError('Yang berhak hanya Mba Tania') + + self.is_edit = False \ No newline at end of file diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index a85e8caa..c55e2e1b 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -62,6 +62,10 @@ class AccountMove(models.Model): res = super(AccountMove, self).button_draft() if not self.env.user.is_accounting: raise UserError('Hanya Accounting yang bisa Reset to Draft') + + if self.write_date != self.create_date: + if self.statement_line_id and not self.statement_line_id.statement_id.is_edit and self.statement_line_id.statement_id.state == 'confirm': + raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') return res def action_post(self): @@ -145,4 +149,10 @@ class AccountMove(models.Model): 'move_ids': [x.id for x in self] } return action - \ No newline at end of file + + def write(self, vals): + res = super(AccountMove, self).write(vals) + if self.write_date != self.create_date: + if self.statement_line_id and not self.statement_line_id.statement_id.is_edit and self.statement_line_id.statement_id.state == 'confirm': + raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') + return res diff --git a/indoteknik_custom/models/users.py b/indoteknik_custom/models/users.py index b90c0097..2ff9933e 100644 --- a/indoteknik_custom/models/users.py +++ b/indoteknik_custom/models/users.py @@ -11,6 +11,7 @@ class Users(models.Model): is_accounting = fields.Boolean(string='Accounting', help='Berhak Approval Internal Use') is_logistic_approver = fields.Boolean(string='Logistic Approver', help='Berhak Approval Penerimaan Barang') is_editor_product = fields.Boolean(string='Editor Product', help='Berhak Mengedit Data Product') + is_admin_reconcile = fields.Boolean(string='Admin Reconcile', help='Berhak Mengedit Journal Reconcile') def notify_internal_users(self, message, title): users = self.search([('share', '=', False)]) diff --git a/indoteknik_custom/views/account_bank_statement.xml b/indoteknik_custom/views/account_bank_statement.xml new file mode 100644 index 00000000..a4e4f7e5 --- /dev/null +++ b/indoteknik_custom/views/account_bank_statement.xml @@ -0,0 +1,31 @@ + + + + + account.bank.statement.tree + account.bank.statement + + + + + + + + + + account.bank.statement.form + account.bank.statement + + + + + + + + + + \ No newline at end of file diff --git a/indoteknik_custom/views/users.xml b/indoteknik_custom/views/users.xml index d67b4474..020d8ddc 100644 --- a/indoteknik_custom/views/users.xml +++ b/indoteknik_custom/views/users.xml @@ -13,6 +13,7 @@ + -- cgit v1.2.3 From d05d1f609441ff0ead57d447c0ece63a968410de Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 4 Nov 2023 09:19:07 +0700 Subject: invisible field edit on reconcile --- indoteknik_custom/models/account_bank_statement.py | 6 +++--- indoteknik_custom/views/account_bank_statement.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/indoteknik_custom/models/account_bank_statement.py b/indoteknik_custom/models/account_bank_statement.py index 495367e8..23008f13 100644 --- a/indoteknik_custom/models/account_bank_statement.py +++ b/indoteknik_custom/models/account_bank_statement.py @@ -4,16 +4,16 @@ from odoo.exceptions import AccessError, UserError, ValidationError class AccountBankStatement(models.Model): _inherit = "account.bank.statement" - is_edit = fields.Boolean(string='Edit', default=False) + is_edit = fields.Boolean(string='Unlock', default=False) def is_edited(self): if not self.env.user.is_admin_reconcile: - raise UserError('Yang berhak hanya Mba Tania') + raise UserError('Yang berhak hanya Mba Tania dan Iqmal Saputra') self.is_edit = True def not_edited(self): if not self.env.user.is_admin_reconcile: - raise UserError('Yang berhak hanya Mba Tania') + raise UserError('Yang berhak hanya Mba Tania dan Iqmal Saputra') self.is_edit = False \ No newline at end of file diff --git a/indoteknik_custom/views/account_bank_statement.xml b/indoteknik_custom/views/account_bank_statement.xml index a4e4f7e5..db380f37 100644 --- a/indoteknik_custom/views/account_bank_statement.xml +++ b/indoteknik_custom/views/account_bank_statement.xml @@ -23,7 +23,7 @@ - + -- cgit v1.2.3 From f8fcf079afbe107ed8bda3e6e832b58786d2a42a Mon Sep 17 00:00:00 2001 From: Azka Nathan Date: Sat, 4 Nov 2023 11:53:45 +0700 Subject: fix error account move --- indoteknik_custom/models/account_move.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index c55e2e1b..ee4279b2 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -63,9 +63,10 @@ class AccountMove(models.Model): if not self.env.user.is_accounting: raise UserError('Hanya Accounting yang bisa Reset to Draft') - if self.write_date != self.create_date: - if self.statement_line_id and not self.statement_line_id.statement_id.is_edit and self.statement_line_id.statement_id.state == 'confirm': - raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') + for rec in self: + if rec.write_date != rec.create_date: + if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm': + raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') return res def action_post(self): @@ -152,7 +153,8 @@ class AccountMove(models.Model): def write(self, vals): res = super(AccountMove, self).write(vals) - if self.write_date != self.create_date: - if self.statement_line_id and not self.statement_line_id.statement_id.is_edit and self.statement_line_id.statement_id.state == 'confirm': - raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') + for rec in self: + if rec.write_date != rec.create_date: + if rec.statement_line_id and not rec.statement_line_id.statement_id.is_edit and rec.statement_line_id.statement_id.state == 'confirm': + raise UserError('Bank Statement di Lock, Minta admin reconcile untuk unlock') return res -- cgit v1.2.3