summaryrefslogtreecommitdiff
path: root/fixco_custom/models/account_move.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-07-18 09:25:57 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-07-18 09:25:57 +0700
commit10e171ea5389873fea3fb13c90242b322a37a990 (patch)
tree9288e4c9693cb5ea1a3d18e66e0bb723f9be5133 /fixco_custom/models/account_move.py
parent66b6b5863a15377c91300079026b11e7f81d60e4 (diff)
On change product otomatis terisi di requisition
Create bills by search PO & SKU Create bills by upload
Diffstat (limited to 'fixco_custom/models/account_move.py')
-rw-r--r--fixco_custom/models/account_move.py38
1 files changed, 36 insertions, 2 deletions
diff --git a/fixco_custom/models/account_move.py b/fixco_custom/models/account_move.py
index 0a417cd..f491bc4 100644
--- a/fixco_custom/models/account_move.py
+++ b/fixco_custom/models/account_move.py
@@ -31,12 +31,45 @@ class AccountMove(models.Model):
states={'draft': [('readonly', False)]},
help="Auto-complete from multiple past bills / purchase orders.",
)
+ faktur_pajak = fields.Char('Faktur Pajak')
+ count_payment = fields.Integer('Count Payment', compute='_compute_count_payment')
+ def _compute_count_payment(self):
+ for move in self:
+ accountPayment = self.env['account.payment']
+
+ payment = accountPayment.search([]).filtered(
+ lambda p: move.id in p.reconciled_bill_ids.ids
+ )
+
+
+ move.count_payment = len(payment)
+
+ def action_view_related_payment(self):
+ self.ensure_one()
+
+ accountPayment = self.env['account.payment']
+
+ payment = accountPayment.search([]).filtered(
+ lambda p: self.id in p.reconciled_bill_ids.ids
+ )
+
+ payments = payment
+
+ return {
+ 'name': 'Payments',
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'account.payment',
+ 'view_mode': 'tree,form',
+ 'target': 'current',
+ 'domain': [('id', 'in', list(payments.ids))],
+ }
def action_post(self):
res = super(AccountMove, self).action_post()
for entry in self:
- entry.invoice_date = entry.picking_id.date_done
+ if entry.move_type == 'out_invoice':
+ entry.invoice_date = entry.picking_id.date_done
return res
@@ -59,7 +92,7 @@ class AccountMove(models.Model):
invoice_vals.pop('ref', None)
self.update(invoice_vals)
- po_lines = po.order_line - self.line_ids.mapped('purchase_line_id')
+ po_lines = po.order_line.filtered(lambda l: l.qty_received != l.qty_invoiced and l.qty_invoiced <= l.qty_received) - self.line_ids.mapped('purchase_line_id')
new_lines = self.env['account.move.line']
sequence = max(self.line_ids.mapped('sequence')) + 1 if self.line_ids else 10
@@ -73,6 +106,7 @@ class AccountMove(models.Model):
new_lines += new_line
new_lines._onchange_mark_recompute_taxes()
+
# Compute invoice_origin
origins = set(self.line_ids.mapped('purchase_line_id.order_id.name'))