summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-02-25 13:03:25 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-02-25 13:03:25 +0700
commitae1c2a5daeffb13cffb010c2b9db062f3baf10e8 (patch)
treef6b009efd5e1ce26f7af32a8cf813eba4362378c
parent13c90b5a95391d797b89c39b90c1430400ed29b7 (diff)
add invoice day to due
-rw-r--r--indoteknik_custom/models/account_move.py11
-rw-r--r--indoteknik_custom/views/account_move.xml7
2 files changed, 17 insertions, 1 deletions
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 @@
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_out_invoice_tree"/>
<field name="arch" type="xml">
+ <field name="invoice_date_due" position="attributes">
+ <attribute name="widget">badge</attribute>
+ <attribute name="decoration-danger">invoice_day_to_due &lt; 0</attribute>
+ </field>
+ <field name="invoice_date_due" position="after">
+ <field name="invoice_day_to_due" attrs="{'invisible': [['payment_state', 'in', ('paid', 'in_payment', 'reversed')]]}"/>
+ </field>
<field name="payment_state" position="after">
<field name="invoice_payment_term_id"/>
<field name="date_kirim_tukar_faktur"/>