diff options
Diffstat (limited to 'indoteknik_custom/models/account_move.py')
| -rw-r--r-- | indoteknik_custom/models/account_move.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index c3cd7ef9..fe9db583 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -1,6 +1,7 @@ from odoo import models, api, fields from odoo.exceptions import AccessError, UserError, ValidationError -from datetime import timedelta, date +from datetime import timedelta, date, datetime +from pytz import timezone, utc import logging import base64 import PyPDF2 @@ -13,6 +14,7 @@ _logger = logging.getLogger(__name__) class AccountMove(models.Model): _inherit = 'account.move' invoice_day_to_due = fields.Integer(string="Day to Due", compute="_compute_invoice_day_to_due") + bill_day_to_due = fields.Date(string="Day to Due", compute="_compute_bill_day_to_due") date_send_fp = fields.Datetime(string="Tanggal Kirim Faktur Pajak") last_log_fp = fields.Char(string="Log Terakhir Faktur Pajak") # use for industry business @@ -28,6 +30,7 @@ class AccountMove(models.Model): analytic_account_ids = fields.Many2many('account.analytic.account', string='Analytic Account') due_line = fields.One2many('due.extension.line', 'invoice_id', compute='_compute_due_line', string='Due Extension Lines') no_faktur_pajak = fields.Char(string='No Faktur Pajak') + date_completed = fields.Datetime(string='Date Completed') @api.onchange('efaktur_id') def change_efaktur_id(self): @@ -59,6 +62,11 @@ 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') + + for rec in self.line_ids: + 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): @@ -90,8 +98,10 @@ class AccountMove(models.Model): # raise UserError('Hanya Accounting yang bisa Posting') # if self._name == 'account.move': for entry in self: + entry.date_completed = datetime.utcnow() for line in entry.line_ids: line.date_maturity = entry.date + return res def _compute_invoice_day_to_due(self): @@ -103,6 +113,10 @@ class AccountMove(models.Model): invoice_day_to_due = invoice.new_due_date - date.today() invoice_day_to_due = invoice_day_to_due.days invoice.invoice_day_to_due = invoice_day_to_due + + def _compute_bill_day_to_due(self): + for rec in self: + rec.bill_day_to_due = rec.payment_schedule or rec.invoice_date_due @api.onchange('date_kirim_tukar_faktur') def change_date_kirim_tukar_faktur(self): @@ -136,4 +150,17 @@ class AccountMove(models.Model): 'move_ids': [x.id for x in self] } return action -
\ No newline at end of file + + @api.constrains('efaktur_id', 'ref', 'date', 'journal_id', 'name') + def constrains_edit(self): + for rec in self.line_ids: + 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') + + # def write(self, vals): + # res = super(AccountMove, self).write(vals) + # for rec in self.line_ids: + # 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 |
