1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
from odoo.exceptions import UserError, RedirectWarning, ValidationError, except_orm, Warning
from datetime import datetime
# class SaleOrder(models.Model):
# _inherit = "sale.order"
# @api.multi
# def action_confirm(self):
# for order in self:
# # Check Invoice Limit
# if order.partner_id.invoice_limit < order.partner_id.total_receivable:
# raise ValidationError(_("This Customer has reached the Limit of Outstanding Invoices"))
# elif order.partner_id.invoice_limit < order.amount_total:
# raise ValidationError(_("This order is more than this Customer Limit"))
# # Check Overdue invoices
# outstanding_invoice = self.env['account.move'].search([
# ('partner_id','=',order.partner_id.id),
# ('state','=','open'),
# ('date_due','<',fields.Date.today())])
# if outstanding_invoice:
# raise ValidationError(_("There are Overdue Invoices for this Customer"))
# return super(SaleOrder, self).action_confirm()
|