summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMqdd <ahmadmiqdad27@gmail.com>2026-01-05 18:48:14 +0700
committerMqdd <ahmadmiqdad27@gmail.com>2026-01-05 18:48:14 +0700
commit7b0a84a6e834fc20784812536e17adb5f7817cc4 (patch)
treebe796b582b0b46d3e80d58d411976b77ca6460fc
parent449e19edc55b2b64b218e56b8216ba56a04c5d3f (diff)
<Miqdad> copy date maturity to date now
-rw-r--r--indoteknik_custom/models/account_move.py84
1 files changed, 53 insertions, 31 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index 37808f94..e1360cfa 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -49,7 +49,7 @@ class AccountMove(models.Model):
states={'draft': [('readonly', False)], 'sent': [('readonly', False)], 'sale': [('readonly', False)]},
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
help="Dipakai untuk alamat tempel")
-
+
address_invoice = fields.Char(related='real_invoice_id.street', string='Invoice Address', readonly=True)
bills_efaktur_exporter = fields.Many2one('res.users', string='Efaktur Exporter')
bills_date_efaktur = fields.Datetime(string="eFaktur Exported Date", required=False)
@@ -176,7 +176,7 @@ class AccountMove(models.Model):
lambda p: move.id in p.reconciled_invoice_ids.ids
)
- if payment:
+ if payment:
move.payment_date = payment[0].date
elif move.reklas_misc_id:
move.payment_date = move.reklas_misc_id.date
@@ -185,7 +185,7 @@ class AccountMove(models.Model):
def action_sync_promise_date(self):
self.ensure_one()
- finance_user_ids = [688]
+ finance_user_ids = [688]
is_it = self.env.user.has_group('indoteknik_custom.group_role_it')
if self.env.user.id not in finance_user_ids and not is_it:
raise UserError('Hanya Finance (Widya) yang dapat menggunakan fitur ini.')
@@ -286,7 +286,7 @@ class AccountMove(models.Model):
if all(inv.reminder_sent_date == today for inv in invs):
_logger.info(f"Reminder untuk {partner.name} sudah terkirim hari ini, skip.")
continue
-
+
promise_dates = [inv.customer_promise_date for inv in invs if inv.customer_promise_date]
if promise_dates:
earliest_promise = min(promise_dates) # ambil janji paling awal
@@ -300,11 +300,11 @@ class AccountMove(models.Model):
# skip semua jika partner centang dont_send_reminder_inv_all
if partner.dont_send_reminder_inv_all:
_logger.info(f"Partner {partner.name} skip karena dont_send_reminder_inv_all aktif")
- continue
+ continue
# cek parent hanya dengan flag dont_sent_reminder_inv_parent
if not partner.dont_send_reminder_inv_parent and partner.email:
emails.append(partner.email)
-
+
# Ambil child contact yang di-checklist reminder_invoices
reminder_contacts = self.env['res.partner'].search([
('parent_id', '=', partner.id),
@@ -312,7 +312,7 @@ class AccountMove(models.Model):
('email', '!=', False),
])
_logger.info(f"Email Reminder Child {reminder_contacts}")
-
+
emails += reminder_contacts.mapped('email')
if reminder_contacts:
_logger.info(f"Email Reminder Child {reminder_contacts}")
@@ -381,7 +381,7 @@ class AccountMove(models.Model):
# tempo_link = 'http://localhost:2100/my/tempo'
# payment_term = partner.previous_payment_term_id if partner.is_cbd_locked else partner.property_payment_term_id
payment_term = invs[0].invoice_payment_term_id
-
+
limit_info_html = f"""
<p><b>Informasi Tambahan:</b></p>
<ul style="font-size:12px; color:#333; line-height:1.4; margin:0; padding-left:0; list-style-position:inside;">
@@ -391,11 +391,11 @@ class AccountMove(models.Model):
Sisa Kredit Limit: {formatLang(self.env, blocking_limit - outstanding_amount, currency_obj=currency)}
</li>
<li style="color:red;">
- Kredit Limit Terpakai: {formatLang(self.env, outstanding_amount, currency_obj=currency)}
+ Kredit Limit Terpakai: {formatLang(self.env, outstanding_amount, currency_obj=currency)}
<span style="font-size:12px; color:#666;">({len(outstanding_invoices)} Transaksi)</span>
</li>
<li style="color:red;">
- Jatuh Tempo: {formatLang(self.env, overdue_amount, currency_obj=currency)}
+ Jatuh Tempo: {formatLang(self.env, overdue_amount, currency_obj=currency)}
<span style="font-size:12px; color:#666;">({len(overdue_invoices)} Invoice)</span>
</li>
</ul>
@@ -472,7 +472,7 @@ class AccountMove(models.Model):
values = {
'subject': f"Reminder Invoice Due - {partner.name}",
# 'email_to': 'andrifebriyadiputra@gmail.com',
- 'email_to': email_to,
+ 'email_to': email_to,
'email_from': 'finance@indoteknik.co.id',
'email_cc': ",".join(sorted(set(cc_list))),
'body_html': body_html,
@@ -528,7 +528,7 @@ class AccountMove(models.Model):
# payment_term = rec.invoice_payment_term_id.line_ids[0].days
# terima_faktur = rec.date_terima_tukar_faktur
# payment = self.search([('ref', '=', rec.name), ('move_type', '=', 'entry')], limit=1)
-
+
# if payment and terima_faktur:
# date_diff = terima_faktur - payment.date
# rec.length_of_payment = date_diff.days + payment_term
@@ -589,7 +589,7 @@ class AccountMove(models.Model):
template = self.env.ref('indoteknik_custom.mail_template_efaktur_document')
for record in records:
- if record.invoice_payment_term_id.id == 26:
+ if record.invoice_payment_term_id.id == 26:
attachment = self.generate_attachment(record)
email_values = {
'attachment_ids': [(4, attachment.id)]
@@ -605,7 +605,7 @@ class AccountMove(models.Model):
@api.model
def create(self, vals):
- vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0'
+ vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0'
result = super(AccountMove, self).create(vals)
# Tambahan: jika ini Vendor Bill dan tanggal belum diisi
@@ -640,13 +640,13 @@ class AccountMove(models.Model):
record.flag_delivery_amt = True
else:
record.flag_delivery_amt = False
-
+
def compute_delivery_amt_text(self):
tb = Terbilang()
for record in self:
res = ''
-
+
try:
if record.sale_id.delivery_amt > 0:
tb.parse(int(record.sale_id.delivery_amt))
@@ -654,7 +654,7 @@ class AccountMove(models.Model):
record.delivery_amt_text = res + ' Rupiah'
except:
record.delivery_amt_text = res
-
+
@api.constrains('bills_efaktur_document')
def _constrains_efaktur_document(self):
@@ -722,13 +722,35 @@ class AccountMove(models.Model):
raise UserError('Data Hanya Bisa Di Cancel')
return res
+ def copy(self, default=None):
+ default = dict(default or {})
+
+ today = fields.Date.context_today(self)
+
+ if self.invoice_date_due:
+ default.update({
+ 'invoice_date_due': today,
+ })
+
+ move = super().copy(default)
+
+ for line in move.line_ids:
+ if (
+ line.account_id.user_type_id.type in ('receivable', 'payable')
+ and line.date_maturity
+ ):
+ line.date_maturity = today
+
+ return move
+
+
def button_cancel(self):
res = super(AccountMove, self).button_cancel()
if self.move_type == 'entry':
po = self.env['purchase.order'].search([
('move_id', 'in', [self.id])
])
-
+
for order in po:
if order:
order.is_create_uangmuka = False
@@ -741,7 +763,7 @@ 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':
@@ -751,7 +773,7 @@ class AccountMove(models.Model):
def action_post(self):
if self._name != 'account.move':
return super(AccountMove, self).action_post()
-
+
# validation cant qty invoice greater than qty order
if self.move_type == 'out_invoice':
query = ["&",("name","=",self.invoice_origin),"|",("state","=","sale"),("state","=","done")]
@@ -777,7 +799,7 @@ 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()
+ # entry.date_completed = datetime.utcnow()
# for line in entry.line_ids:
# line.date_maturity = entry.date
@@ -787,7 +809,7 @@ class AccountMove(models.Model):
if not self.env.user.is_accounting:
raise UserError("Hanya Finence yang bisa ubah data")
return res
-
+
def _compute_invoice_day_to_due(self):
for invoice in self:
invoice_day_to_due = 0
@@ -801,7 +823,7 @@ class AccountMove(models.Model):
new_invoice_day_to_due = new_invoice_day_to_due.days
invoice.invoice_day_to_due = invoice_day_to_due
invoice.new_invoice_day_to_due = new_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
@@ -831,21 +853,21 @@ class AccountMove(models.Model):
add_days += line.days
due_date = tukar_date + timedelta(days=add_days)
invoice.invoice_date_due = due_date
-
+
def open_form_multi_update(self):
action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_account_move_multi_update')
action['context'] = {
'move_ids': [x.id for x in self]
}
return action
-
+
def open_form_multi_update_bills(self):
action = self.env['ir.actions.act_window']._for_xml_id('indoteknik_custom.action_account_move_multi_update_bills')
action['context'] = {
'move_ids': [x.id for x in self]
}
return action
-
+
@api.constrains('efaktur_id', 'ref', 'date', 'journal_id', 'name')
def constrains_edit(self):
for rec in self.line_ids:
@@ -859,10 +881,10 @@ class AccountMove(models.Model):
# 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 validate_faktur_for_export(self):
- invoices = self.filtered(lambda inv: not inv.is_efaktur_exported and
- inv.state == 'posted' and
+ invoices = self.filtered(lambda inv: not inv.is_efaktur_exported and
+ inv.state == 'posted' and
inv.move_type == 'out_invoice')
invalid_invoices = self - invoices
@@ -874,10 +896,10 @@ class AccountMove(models.Model):
))
return invoices
-
+
def export_faktur_to_xml(self):
valid_invoices = self
-
+
coretax_faktur = self.env['coretax.faktur'].create({})
response = coretax_faktur.export_to_download(