summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-07-24 14:44:23 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-07-24 14:44:23 +0700
commitcbe2c5730bcd82ce594e03425c987b17c583b893 (patch)
tree0923a5b2863dcd1546b9670d3681976735a8a41a
parentbdf6d7dbd8850d525809726036c6783b9113028f (diff)
<hafid> add journals in so
-rwxr-xr-xindoteknik_custom/models/sale_order.py42
-rwxr-xr-xindoteknik_custom/views/sale_order.xml8
2 files changed, 42 insertions, 8 deletions
diff --git a/indoteknik_custom/models/sale_order.py b/indoteknik_custom/models/sale_order.py
index 995cafba..febdaabd 100755
--- a/indoteknik_custom/models/sale_order.py
+++ b/indoteknik_custom/models/sale_order.py
@@ -364,6 +364,17 @@ class SaleOrder(models.Model):
compute='_compute_advance_payment_move',
string='Advance Payment Move',
)
+ advance_payment_move_ids = fields.Many2many(
+ 'account.move',
+ compute='_compute_advance_payment_moves',
+ string='All Advance Payment Moves',
+ )
+
+ advance_payment_move_count = fields.Integer(
+ string='Jumlah Jurnal Uang Muka',
+ compute='_compute_advance_payment_moves',
+ store=False
+ )
@api.depends('order_line.product_id', 'date_order')
def _compute_et_products(self):
@@ -3191,15 +3202,38 @@ class SaleOrder(models.Model):
('state', '=', 'posted'),
], limit=1, order="id desc")
order.advance_payment_move_id = move
+
+ @api.depends('invoice_ids')
+ def _compute_advance_payment_moves(self):
+ for order in self:
+ moves = self.env['account.move'].search([
+ ('sale_id', '=', order.id),
+ ('journal_id', '=', 11),
+ ('state', '=', 'posted'),
+ ])
+ order.advance_payment_move_ids = moves
+
+ @api.depends('invoice_ids')
+ def _compute_advance_payment_moves(self):
+ for order in self:
+ moves = self.env['account.move'].search([
+ ('sale_id', '=', order.id),
+ ('journal_id', '=', 11),
+ ('state', '=', 'posted'),
+ ])
+ order.advance_payment_move_ids = moves
+ order.advance_payment_move_count = len(moves)
- def action_open_advance_payment_move(self):
+ def action_open_advance_payment_moves(self):
self.ensure_one()
- if not self.advance_payment_move_id:
+ moves = self.advance_payment_move_ids
+ if not moves:
return
return {
'type': 'ir.actions.act_window',
+ 'name': 'Journals Sales Order',
'res_model': 'account.move',
- 'res_id': self.advance_payment_move_id.id,
- 'view_mode': 'form',
+ 'view_mode': 'tree,form',
+ 'domain': [('id', 'in', moves.ids)],
'target': 'current',
} \ No newline at end of file
diff --git a/indoteknik_custom/views/sale_order.xml b/indoteknik_custom/views/sale_order.xml
index 346dc0f8..5bcd7641 100755
--- a/indoteknik_custom/views/sale_order.xml
+++ b/indoteknik_custom/views/sale_order.xml
@@ -43,13 +43,13 @@
attrs="{'invisible': ['|', ('state', 'not in', ['sale', 'done']), ('has_refund', '=', True)]}" />
</xpath> -->
<div class="oe_button_box" name="button_box">
- <button name="action_open_advance_payment_move"
+ <field name="advance_payment_move_ids" invisible="1"/>
+ <button name="action_open_advance_payment_moves"
type="object"
class="oe_stat_button"
icon="fa-book"
- width="250px"
- attrs="{'invisible': [('advance_payment_move_id','=',False)]}">
- <field name="advance_payment_move_id" string="Journal Uang Muka" widget="statinfo"/>
+ attrs="{'invisible': [('advance_payment_move_ids', '=', [])]}">
+ <field name="advance_payment_move_count" widget="statinfo" string="Journals"/>
</button>
<!-- <button type="object"