29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2026 Nexa Systems Inc.
|
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
|
# Part of the Fusion Plating product family.
|
|
|
|
from odoo import models, _
|
|
from odoo.exceptions import UserError
|
|
|
|
|
|
class AccountMove(models.Model):
|
|
_inherit = 'account.move'
|
|
|
|
def action_post(self):
|
|
"""Check account hold before posting invoices."""
|
|
for move in self:
|
|
if move.move_type in ('out_invoice', 'out_refund') and move.partner_id:
|
|
if move.partner_id.x_fc_account_hold:
|
|
is_manager = self.env.user.has_group(
|
|
'fusion_plating.group_fusion_plating_manager'
|
|
)
|
|
if not is_manager:
|
|
raise UserError(_(
|
|
'Cannot post invoice — customer "%s" is on account hold.\n'
|
|
'Reason: %s\n\n'
|
|
'Contact a manager to override.'
|
|
) % (move.partner_id.name,
|
|
move.partner_id.x_fc_account_hold_reason or 'No reason specified'))
|
|
return super().action_post()
|