Squashed commit of the following: commit5adce1fd15Author: Marc Durepos <marc@bemade.org> Date: Thu Sep 4 12:33:00 2025 -0400 [MIG] 17.0..18.0 account_credit_hold Migrated module account_credit_hold from 17.0 to 18.0. Fixed views and models and wrote test cases to check functionality. commit91c52af6f4Author: Marc Durepos <marc@bemade.org> Date: Thu Sep 4 11:38:37 2025 -0400 Initial migration of account_credit_hold for testing in 18.0
16 lines
703 B
Python
16 lines
703 B
Python
from odoo import fields, models, api, _
|
|
from odoo.exceptions import UserError
|
|
|
|
|
|
class SaleOrder(models.Model):
|
|
_inherit = "sale.order"
|
|
|
|
client_on_hold = fields.Boolean(string='Client on Hold',
|
|
help="Whether or not a client has been put on hold due to unpaid invoices.",
|
|
related="partner_id.on_hold")
|
|
|
|
def action_confirm(self):
|
|
if any(self.mapped('client_on_hold')):
|
|
raise UserError(_("This client is on credit hold. No new orders can be confirmed until past-due invoices "
|
|
"are paid or the accounting team postpones the hold."))
|
|
return super().action_confirm()
|