diff options
Diffstat (limited to 'fixco_custom/models/account_move.py')
| -rw-r--r-- | fixco_custom/models/account_move.py | 48 |
1 files changed, 47 insertions, 1 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([{ |
