summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiqdad <ahmadmiqdad27@gmail.com>2025-05-16 09:35:23 +0700
committerMiqdad <ahmadmiqdad27@gmail.com>2025-05-16 09:35:23 +0700
commitf8811bdf897fe0176921cc01b0ee8c9b98c883d3 (patch)
tree96b3825847e2fe423cf8f30bb770d26d4c1ebe17
parenta6a26665953d36578c62b6f4d5608b716d9fac88 (diff)
<miqdad> filter using account_id
-rw-r--r--indoteknik_custom/models/coretax_fatur.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/indoteknik_custom/models/coretax_fatur.py b/indoteknik_custom/models/coretax_fatur.py
index f2a1f793..92ff1a72 100644
--- a/indoteknik_custom/models/coretax_fatur.py
+++ b/indoteknik_custom/models/coretax_fatur.py
@@ -12,6 +12,8 @@ class CoretaxFaktur(models.Model):
export_file = fields.Binary(string="Export File", )
export_filename = fields.Char(string="Export File", )
+ DISCOUNT_ACCOUNT_ID = 463
+
def validate_and_format_number(slef, input_number):
# Hapus semua karakter non-digit
cleaned_number = re.sub(r'\D', '', input_number)
@@ -70,18 +72,19 @@ class CoretaxFaktur(models.Model):
ET.SubElement(tax_invoice, 'BuyerEmail').text = invoice.partner_id.email or ''
ET.SubElement(tax_invoice, 'BuyerIDTKU').text = buyerIDTKU
- # cari product
+ # Filter product
product_lines = invoice.invoice_line_ids.filtered(
- lambda l: not l.display_type and l.product_id and
- hasattr(l, 'account_id') and l.account_id and
- 'Diskon' not in (l.account_id.name or '')
+ lambda l: not l.display_type and hasattr(l, 'account_id') and
+ l.account_id and l.product_id and
+ l.account_id.id != self.DISCOUNT_ACCOUNT_ID and
+ l.quantity != -1
)
- # cari diskon/potongan
+ # Filter discount
discount_lines = invoice.invoice_line_ids.filtered(
lambda l: not l.display_type and (
- (hasattr(l, 'account_id') and l.account_id and 'Diskon' in (l.account_id.name or '')) or
- (l.name and isinstance(l.name, str) and 'Diskon' in l.name) or
+ (hasattr(l, 'account_id') and l.account_id and
+ l.account_id.id == self.DISCOUNT_ACCOUNT_ID) or
(l.quantity == -1)
)
)