Migrated module account_credit_hold from 17.0 to 18.0. Fixed views and models and wrote test cases to check functionality.
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()
|