Files
Odoo-Modules/fusion_faxes/models/account_move.py
gsinghpal f661724c72 changes
2026-05-22 18:01:31 -04:00

66 lines
2.0 KiB
Python

# -*- coding: utf-8 -*-
# Copyright 2026 Nexa Systems Inc.
# License OPL-1 (Odoo Proprietary License v1.0)
from odoo import api, fields, models
class AccountMove(models.Model):
_inherit = 'account.move'
x_ff_fax_ids = fields.One2many(
'fusion.fax',
'account_move_id',
string='Faxes',
)
x_ff_fax_count = fields.Integer(
string='Fax Count',
compute='_compute_fax_count',
)
x_ff_show_send_fax_button = fields.Boolean(
string='Show Send Fax Button',
compute='_compute_show_send_fax_button',
help='Driven by the Settings toggle '
'(fusion_faxes.show_send_fax_button).',
)
@api.depends('x_ff_fax_ids')
def _compute_fax_count(self):
for move in self:
move.x_ff_fax_count = len(move.x_ff_fax_ids)
def _compute_show_send_fax_button(self):
param = self.env['ir.config_parameter'].sudo().get_param(
'fusion_faxes.show_send_fax_button', 'True',
)
show = str(param).lower() not in ('false', '0', '')
for move in self:
move.x_ff_show_send_fax_button = show
def action_send_fax(self):
"""Open the Send Fax wizard pre-filled with this invoice."""
self.ensure_one()
return {
'type': 'ir.actions.act_window',
'name': 'Send Fax',
'res_model': 'fusion_faxes.send.fax.wizard',
'view_mode': 'form',
'target': 'new',
'context': {
'active_model': 'account.move',
'active_id': self.id,
},
}
def action_view_faxes(self):
"""Open fax history for this invoice."""
self.ensure_one()
return {
'type': 'ir.actions.act_window',
'name': 'Faxes',
'res_model': 'fusion.fax',
'view_mode': 'list,form',
'domain': [('account_move_id', '=', self.id)],
'context': {'default_account_move_id': self.id},
}