changes
This commit is contained in:
@@ -3,13 +3,22 @@
|
||||
# License OPL-1 (Odoo Proprietary License v1.0)
|
||||
# Part of the Fusion Plating product family.
|
||||
|
||||
from odoo import api, models, _
|
||||
from odoo import api, fields, models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
# Mirrors the SO-side related field. See sale_order.py for the
|
||||
# rationale (dotted refs in view modifiers are fragile + hold lives
|
||||
# on the commercial partner).
|
||||
x_fc_partner_account_hold = fields.Boolean(
|
||||
string='Customer on Account Hold',
|
||||
related='partner_id.commercial_partner_id.x_fc_account_hold',
|
||||
store=True, readonly=True,
|
||||
)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
"""Auto-inherit payment terms + customer PO# at creation time.
|
||||
@@ -55,17 +64,16 @@ class AccountMove(models.Model):
|
||||
"""
|
||||
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'
|
||||
)
|
||||
hold_partner = move.partner_id.commercial_partner_id
|
||||
if hold_partner.x_fc_account_hold:
|
||||
is_manager = self.env['res.partner']._fp_user_can_override_account_hold()
|
||||
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'))
|
||||
) % (hold_partner.name,
|
||||
hold_partner.x_fc_account_hold_reason or 'No reason specified'))
|
||||
if not move.invoice_payment_term_id:
|
||||
raise UserError(_(
|
||||
'Cannot post invoice "%s" — no payment terms set.\n\n'
|
||||
|
||||
Reference in New Issue
Block a user