From ae1c2a5daeffb13cffb010c2b9db062f3baf10e8 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 25 Feb 2023 13:03:25 +0700 Subject: add invoice day to due --- indoteknik_custom/models/account_move.py | 11 ++++++++++- indoteknik_custom/views/account_move.xml | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py index 78fa2ddf..18dbfba7 100644 --- a/indoteknik_custom/models/account_move.py +++ b/indoteknik_custom/models/account_move.py @@ -1,10 +1,11 @@ from odoo import models, api, fields from odoo.exceptions import AccessError, UserError, ValidationError -from datetime import timedelta +from datetime import timedelta, date class AccountMove(models.Model): _inherit = 'account.move' + invoice_day_to_due = fields.Integer(string="Day to Due", compute="_compute_invoice_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 @@ -24,6 +25,14 @@ class AccountMove(models.Model): # if not self.env.user.is_accounting: # raise UserError('Hanya Accounting yang bisa Posting') return res + + def _compute_invoice_day_to_due(self): + for invoice in self: + invoice_day_to_due = 0 + if invoice.payment_state not in ['paid', 'in_payment', 'reversed'] and invoice.invoice_date_due: + invoice_day_to_due = invoice.invoice_date_due - date.today() + invoice_day_to_due = invoice_day_to_due.days + invoice.invoice_day_to_due = invoice_day_to_due @api.onchange('date_kirim_tukar_faktur') def change_date_kirim_tukar_faktur(self): diff --git a/indoteknik_custom/views/account_move.xml b/indoteknik_custom/views/account_move.xml index 6bdc16d0..af4eaa05 100644 --- a/indoteknik_custom/views/account_move.xml +++ b/indoteknik_custom/views/account_move.xml @@ -24,6 +24,13 @@ account.move + + badge + invoice_day_to_due < 0 + + + + -- cgit v1.2.3