summaryrefslogtreecommitdiff
path: root/fixco_custom/models/purchase_order.py
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-08-04 09:55:46 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-08-04 09:55:46 +0700
commitca5912d9f29f4bb2e7b482cce01f917285ed53cb (patch)
tree5b5a6e3dc607f0bcd0a448c780cacdcad4f949a2 /fixco_custom/models/purchase_order.py
parentc99a62f139fd7dfad7ffb2911eaaa7e7b95c7dd5 (diff)
penyusutan, reklas, journal uang muka
Diffstat (limited to 'fixco_custom/models/purchase_order.py')
-rw-r--r--fixco_custom/models/purchase_order.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/fixco_custom/models/purchase_order.py b/fixco_custom/models/purchase_order.py
index 75263b1..0869cc8 100644
--- a/fixco_custom/models/purchase_order.py
+++ b/fixco_custom/models/purchase_order.py
@@ -24,6 +24,7 @@ class PurchaseOrder(models.Model):
index=True
)
sale_order_id = fields.Many2one('sale.order', string='Sales Order')
+ move_entry_id = fields.Many2one('account.move', string='Journal Entries')
amount_discount = fields.Monetary(
string='Total Discount',
compute='_compute_amount_discount',
@@ -42,6 +43,32 @@ class PurchaseOrder(models.Model):
('purchasing_job', 'Purchasing Job'),
('manual', 'Manual')
], string='Source', default='manual')
+ count_journals = fields.Integer('Count Payment', compute='_compute_count_journals')
+
+ def _compute_count_journals(self):
+ for order in self:
+ journals = self.env['account.move'].search([
+ ('purchase_order_id', '=', order.id),
+ ('move_type', '!=', 'in_invoice')
+ ])
+ order.count_journals = len(journals)
+
+ def action_view_related_journals(self):
+ self.ensure_one()
+
+ journals = self.env['account.move'].search([
+ ('purchase_order_id', '=', self.id),
+ ('move_type', '!=', 'in_invoice')
+ ])
+
+ return {
+ 'name': 'Journals',
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'account.move',
+ 'view_mode': 'tree,form',
+ 'target': 'current',
+ 'domain': [('id', 'in', journals.ids)],
+ }
@api.depends('order_line.price_total', 'biaya_lain_lain')
def _amount_all(self):