summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzka Nathan <darizkyfaz@gmail.com>2025-08-05 10:49:44 +0700
committerAzka Nathan <darizkyfaz@gmail.com>2025-08-05 10:49:44 +0700
commit323da166ce71a8a14bedad816d3bbddb9a84139e (patch)
treee8d669b8b47d9d716fb01aea4523d267874bddeb
parentcdcc160fdebac61179c8d8889f5d9c08a698c523 (diff)
skema retur req iqmal
-rw-r--r--fixco_custom/models/account_move.py48
-rw-r--r--fixco_custom/views/account_move.xml12
2 files changed, 58 insertions, 2 deletions
diff --git a/fixco_custom/models/account_move.py b/fixco_custom/models/account_move.py
index 971e9e3..d095eeb 100644
--- a/fixco_custom/models/account_move.py
+++ b/fixco_custom/models/account_move.py
@@ -1,4 +1,4 @@
-from odoo import models, api, fields
+from odoo import models, api, fields, _
from odoo.exceptions import AccessError, UserError, ValidationError
from datetime import timedelta, date, datetime
from pytz import timezone, utc
@@ -36,7 +36,53 @@ class AccountMove(models.Model):
reklas_misc_id = fields.Many2one('account.move', string='Journal Entries Reklas')
purchase_order_id = fields.Many2one('purchase.order', string='Purchase Order')
bill_id = fields.Many2one('account.move', string='Vendor Bill', domain=[('move_type', '=', 'in_invoice')], help='Bill asal dari proses reklas ini')
+ count_reverse = fields.Integer('Count Reverse', compute='_compute_count_reverse')
+
+ def _compute_count_reverse(self):
+ for move in self:
+ accountMove = self.env['account.move']
+
+ reverse = accountMove.search([]).filtered(
+ lambda p: move.id in p.reversed_entry_id.ids
+ )
+
+
+ move.count_reverse = len(reverse)
+
+ def action_view_related_reverse(self):
+ self.ensure_one()
+
+ accountMove = self.env['account.move']
+
+ reverse = accountMove.search([]).filtered(
+ lambda p: self.id in p.reversed_entry_id.ids
+ )
+
+ reverses = reverse
+
+ return {
+ 'name': 'Payments',
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'account.payment',
+ 'view_mode': 'tree,form',
+ 'target': 'current',
+ 'domain': [('id', 'in', list(reverses.ids))],
+ }
+
+ def action_reverse(self):
+ action = self.env["ir.actions.actions"]._for_xml_id("account.action_view_account_move_reversal")
+
+ if self.is_invoice():
+ action['name'] = _('Credit Note')
+
+ if len(self) == 1:
+ action['context'] = {
+ 'default_journal_id': self.journal_id.id,
+ }
+
+ return action
+
def open_form_multi_create_reklas_penjualan(self):
action = self.env['ir.actions.act_window']._for_xml_id('fixco_custom.action_view_invoice_reklas_penjualan')
invoice = self.env['invoice.reklas.penjualan'].create([{
diff --git a/fixco_custom/views/account_move.xml b/fixco_custom/views/account_move.xml
index 421dc49..0e0b381 100644
--- a/fixco_custom/views/account_move.xml
+++ b/fixco_custom/views/account_move.xml
@@ -16,10 +16,20 @@
<button type="object" name="action_view_related_payment"
class="oe_stat_button"
icon="fa-pencil-square-o"
- attrs="{'invisible': [('move_type', '!=', 'in_invoice')]}">
+ attrs="{'invisible': [('count_payment', '=', 0)]}">
<field name="count_payment" widget="statinfo" string="Payments"/>
</button>
+ <button type="object" name="action_view_related_reverse"
+ class="oe_stat_button"
+ icon="fa-book"
+ attrs="{'invisible': [('count_reverse', '=', 0)]}">
+ <field name="count_reverse" widget="statinfo" string="Retur"/>
+ </button>
</button>
+
+ <xpath expr="//button[@name='%(account.action_view_account_move_reversal)d']" position="attributes">
+ <attribute name="context">{'default_journal_id': journal_id}</attribute>
+ </xpath>
<field name="payment_reference" position="after">
<field name="invoice_marketplace" readonly="1" attrs="{'invisible': [('move_type', '!=', 'out_invoice')]}"/>