summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2025-06-18 09:03:58 +0000
committerIT Fixcomart <it@fixcomart.co.id>2025-06-18 09:03:58 +0000
commit393228f1b25d3fa460d8300c45642e66edbca88a (patch)
treeefbdf4f4e5057deadb2e2c78e08435884f2027db
parent4c3550dd2641b3f64d889d939e1eee400088188e (diff)
parent386d64204b1e75d7aaa28cf1c7413b69938ee397 (diff)
Merged in date_bill_account (pull request #337)
Date bill account
-rw-r--r--indoteknik_custom/models/account_move.py40
-rwxr-xr-xindoteknik_custom/models/purchase_order.py12
2 files changed, 50 insertions, 2 deletions
diff --git a/indoteknik_custom/models/account_move.py b/indoteknik_custom/models/account_move.py
index 54eaabcf..66020a69 100644
--- a/indoteknik_custom/models/account_move.py
+++ b/indoteknik_custom/models/account_move.py
@@ -87,6 +87,17 @@ class AccountMove(models.Model):
# result.append((move.id, move.display_name))
# return result
+ @api.onchange('invoice_date')
+ def _onchange_invoice_date(self):
+ if self.invoice_date:
+ self.date = self.invoice_date
+
+ @api.onchange('date')
+ def _onchange_date(self):
+ if self.date:
+ self.invoice_date = self.date
+
+
def compute_length_of_payment(self):
for rec in self:
payment_term = rec.invoice_payment_term_id.line_ids[0].days
@@ -145,13 +156,38 @@ class AccountMove(models.Model):
}
template.send_mail(record.id, email_values=email_values, force_send=True)
+ # @api.model
+ # def create(self, vals):
+ # vals['nomor_kwitansi'] = self.env['ir.sequence'].next_by_code('nomor.kwitansi') or '0'
+ # result = super(AccountMove, self).create(vals)
+ # # result._update_line_name_from_ref()
+ # return result
+
@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)
- # result._update_line_name_from_ref()
+
+ # Tambahan: jika ini Vendor Bill dan tanggal belum diisi
+ if result.move_type == 'in_invoice' and not vals.get('invoice_date') and not vals.get('date'):
+ po = result.purchase_order_id
+ if po:
+ # Cari receipt dari PO
+ picking = self.env['stock.picking'].search([
+ ('purchase_id', '=', po.id),
+ ('picking_type_code', '=', 'incoming'),
+ ('state', '=', 'done'),
+ ('date_done', '!=', False),
+ ], order='date_done desc', limit=1)
+
+ if picking:
+ receipt_date = picking.date_done
+ result.invoice_date = receipt_date
+ result.date = receipt_date
+
return result
+
def compute_so_shipping_paid_by(self):
for record in self:
record.so_shipping_paid_by = record.sale_id.shipping_paid_by
diff --git a/indoteknik_custom/models/purchase_order.py b/indoteknik_custom/models/purchase_order.py
index 004a1fa4..505df735 100755
--- a/indoteknik_custom/models/purchase_order.py
+++ b/indoteknik_custom/models/purchase_order.py
@@ -452,6 +452,18 @@ class PurchaseOrder(models.Model):
'company_id': self.company_id.id,
'payment_schedule': payment_schedule
}
+
+ receipt = self.env['stock.picking'].search([
+ ('purchase_id', '=', self.id),
+ ('state', '=', 'done'),
+ ('picking_type_code', '=', 'incoming'),
+ ('date_done', '!=', False)
+ ], order='date_done desc', limit=1)
+
+ if receipt:
+ invoice_vals['invoice_date'] = receipt.date_done
+ invoice_vals['date'] = receipt.date_done
+
return invoice_vals
def _compute_matches_so(self):