changes
This commit is contained in:
@@ -17,12 +17,26 @@ class AccountMove(models.Model):
|
||||
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()
|
||||
|
||||
@@ -15,6 +15,15 @@ class ResConfigSettings(models.TransientModel):
|
||||
string='Enable RingCentral Faxing',
|
||||
config_parameter='fusion_faxes.ringcentral_enabled',
|
||||
)
|
||||
ff_show_send_fax_button = fields.Boolean(
|
||||
string='Show "Send Fax" Button on Sale Orders & Invoices',
|
||||
config_parameter='fusion_faxes.show_send_fax_button',
|
||||
default=True,
|
||||
help='When enabled, the "Send Fax" header button appears on '
|
||||
'sale order and invoice forms (for users in the Fax User '
|
||||
'group). Turn off to hide the button without removing '
|
||||
'fax-user access.',
|
||||
)
|
||||
ff_ringcentral_server_url = fields.Char(
|
||||
string='RingCentral Server URL',
|
||||
config_parameter='fusion_faxes.ringcentral_server_url',
|
||||
@@ -103,7 +112,15 @@ class ResConfigSettings(models.TransientModel):
|
||||
}
|
||||
|
||||
def set_values(self):
|
||||
"""Protect credential fields from being blanked accidentally."""
|
||||
"""Protect credential fields from being blanked accidentally
|
||||
and force-persist the Send Fax Boolean.
|
||||
|
||||
Odoo's stock ``set_param`` removes the row when a Boolean
|
||||
config_parameter is False, which makes the ``get_param``
|
||||
fallback default kick in — toggling OFF then would silently
|
||||
re-show the button. We bypass that by writing 'True' / 'False'
|
||||
as a string after super() runs so the row always exists.
|
||||
"""
|
||||
protected_keys = [
|
||||
'fusion_faxes.ringcentral_client_id',
|
||||
'fusion_faxes.ringcentral_client_secret',
|
||||
@@ -122,4 +139,9 @@ class ResConfigSettings(models.TransientModel):
|
||||
existing = ICP.get_param(key, '')
|
||||
if existing:
|
||||
ICP.set_param(key, existing)
|
||||
return super().set_values()
|
||||
res = super().set_values()
|
||||
ICP.set_param(
|
||||
'fusion_faxes.show_send_fax_button',
|
||||
'True' if self.ff_show_send_fax_button else 'False',
|
||||
)
|
||||
return res
|
||||
|
||||
@@ -17,12 +17,28 @@ class SaleOrder(models.Model):
|
||||
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). Default True for '
|
||||
'back-compat — the button stays visible until a manager '
|
||||
'turns it off.',
|
||||
)
|
||||
|
||||
@api.depends('x_ff_fax_ids')
|
||||
def _compute_fax_count(self):
|
||||
for order in self:
|
||||
order.x_ff_fax_count = len(order.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 order in self:
|
||||
order.x_ff_show_send_fax_button = show
|
||||
|
||||
def action_send_fax(self):
|
||||
"""Open the Send Fax wizard pre-filled with this sale order."""
|
||||
self.ensure_one()
|
||||
|
||||
Reference in New Issue
Block a user