summaryrefslogtreecommitdiff
path: root/indoteknik_custom/models/account_move.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-01-21 13:53:28 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-01-21 13:53:28 +0700
commit63433ff471ba98e6fc63bca16abd9a585471498b (patch)
tree7fe83758b1c40888bab68f5498e4a1c7da4d7891 /indoteknik_custom/models/account_move.py
parentff20b62d6932c6be4ffb56f63f3c05be3aa72c06 (diff)
parente3521c2153c36cee6629cee9146e1b4b0201da9f (diff)
Merge branch 'odoo-production' into CR/form-merchant
# Conflicts: # indoteknik_api/models/res_partner.py # indoteknik_api/models/res_users.py # indoteknik_custom/__manifest__.py # indoteknik_custom/models/__init__.py # indoteknik_custom/models/res_partner.py # indoteknik_custom/security/ir.model.access.csv # indoteknik_custom/views/res_partner.xml # indoteknik_custom/views/user_company_request.xml
Diffstat (limited to 'indoteknik_custom/models/account_move.py')
-rw-r--r--indoteknik_custom/models/account_move.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index 725b3c2d..85ed1d54 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -62,6 +62,16 @@ class AccountMove(models.Model):
so_delivery_amt = fields.Char(string="SO Delivery Amount", compute='compute_so_shipping_paid_by')
flag_delivery_amt = fields.Boolean(string="Flag Delivery Amount", compute='compute_flag_delivery_amt')
nomor_kwitansi = fields.Char(string="Nomor Kwitansi")
+ other_subtotal = fields.Float(string="Other Subtotal", compute='compute_other_subtotal')
+ other_taxes = fields.Float(string="Other Taxes", compute='compute_other_taxes')
+
+ def compute_other_taxes(self):
+ for rec in self:
+ rec.other_taxes = rec.other_subtotal * 0.12
+
+ def compute_other_subtotal(self):
+ for rec in self:
+ rec.other_subtotal = rec.amount_untaxed * (11 / 12)
@api.model
def generate_attachment(self, record):
@@ -253,6 +263,11 @@ class AccountMove(models.Model):
line.date_maturity = entry.date
return res
+ def button_draft(self):
+ res = super(AccountMove, self).button_draft()
+ 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:
@@ -325,3 +340,35 @@ 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
+ inv.move_type == 'out_invoice')
+
+ invalid_invoices = self - invoices
+ if invalid_invoices:
+ invalid_ids = ", ".join(str(inv.id) for inv in invalid_invoices)
+ raise UserError((
+ "Faktur dengan ID berikut tidak valid untuk diekspor: {}.\n"
+ "Pastikan faktur dalam status 'posted', belum diekspor, dan merupakan 'out_invoice'.".format(invalid_ids)
+ ))
+
+ return invoices
+
+ def export_faktur_to_xml(self):
+
+ valid_invoices = self
+
+ # Panggil model coretax.faktur untuk menghasilkan XML
+ coretax_faktur = self.env['coretax.faktur'].create({})
+ response = coretax_faktur.export_to_download(invoices=valid_invoices)
+
+ current_time = datetime.utcnow()
+ # Tandai faktur sebagai sudah diekspor
+ valid_invoices.write({
+ 'is_efaktur_exported': True,
+ 'date_efaktur_exported': current_time, # Set tanggal ekspor
+ })
+
+ return response