diff --git a/sale_credit_limit/__manifest__.py b/sale_credit_limit/__manifest__.py
index f0291499..30ec8fe4 100644
--- a/sale_credit_limit/__manifest__.py
+++ b/sale_credit_limit/__manifest__.py
@@ -1,7 +1,7 @@
{
'name': 'Sale Credit Limit',
'summary': 'Uses credit limit on Partners to warn salespeople if they are over their limit.',
- 'version': '12.0.1.0.0',
+ 'version': '13.0.1.0.0',
'author': "Hibou Corp.",
'category': 'Sale',
'license': 'AGPL-3',
diff --git a/sale_credit_limit/data/sale_exceptions.xml b/sale_credit_limit/data/sale_exceptions.xml
index ba593a13..b8f6192d 100644
--- a/sale_credit_limit/data/sale_exceptions.xml
+++ b/sale_credit_limit/data/sale_exceptions.xml
@@ -7,7 +7,6 @@
This sale order, or the customer has an outstanding balance that, exceeds their credit limit.
50
sale.order
- sale
partner = sale.partner_invoice_id.commercial_partner_id
partner_balance = partner.credit + sale.amount_total
@@ -15,7 +14,6 @@ if partner.credit_limit and partner.credit_limit <= partner_balance:
failed = True
- sale
\ No newline at end of file
diff --git a/sale_credit_limit/models/sale.py b/sale_credit_limit/models/sale.py
index 5b1f9b89..5b90514e 100644
--- a/sale_credit_limit/models/sale.py
+++ b/sale_credit_limit/models/sale.py
@@ -1,5 +1,4 @@
-from odoo import api, models
-from odoo.addons.mail.models.mail_template import format_amount
+from odoo import api, models, tools
class SaleOrder(models.Model):
@@ -11,8 +10,8 @@ class SaleOrder(models.Model):
partner = so.partner_invoice_id.commercial_partner_id
if partner.credit_limit and partner.credit_limit <= partner.credit:
m = 'Partner outstanding receivables %s is above their credit limit of %s' \
- % (format_amount(self.env, partner.credit, so.currency_id),
- format_amount(self.env, partner.credit_limit, so.currency_id))
+ % (tools.format_amount(self.env, partner.credit, so.currency_id),
+ tools.format_amount(self.env, partner.credit_limit, so.currency_id))
return {
'warning': {'title': 'Sale Credit Limit',
'message': m}
diff --git a/sale_credit_limit/tests/__init__.py b/sale_credit_limit/tests/__init__.py
new file mode 100644
index 00000000..a2d422d0
--- /dev/null
+++ b/sale_credit_limit/tests/__init__.py
@@ -0,0 +1 @@
+from . import test_sale_credit_exception
diff --git a/sale_credit_limit/tests/test_sale_credit_exception.py b/sale_credit_limit/tests/test_sale_credit_exception.py
new file mode 100644
index 00000000..d679661f
--- /dev/null
+++ b/sale_credit_limit/tests/test_sale_credit_exception.py
@@ -0,0 +1,32 @@
+
+from odoo.addons.sale_exception.tests.test_sale_exception import TestSaleException
+
+
+class TestSaleCreditException(TestSaleException):
+
+ def setUp(self):
+ super(TestSaleCreditException, self).setUp()
+
+ def test_sale_order_credit_limit_exception(self):
+ self.sale_exception_confirm = self.env['sale.exception.confirm']
+ exception = self.env.ref('sale_credit_limit.excep_sale_credit_limit')
+ exception.active = True
+ partner = self.env.ref('base.res_partner_12')
+ partner.credit_limit = 100.00
+ p = self.env.ref('product.product_product_25_product_template')
+ so1 = self.env['sale.order'].create({
+ 'partner_id': partner.id,
+ 'partner_invoice_id': partner.id,
+ 'partner_shipping_id': partner.id,
+ 'order_line': [(0, 0, {'name': p.name,
+ 'product_id': p.id,
+ 'product_uom_qty': 2,
+ 'product_uom': p.uom_id.id,
+ 'price_unit': p.list_price})],
+ 'pricelist_id': self.env.ref('product.list0').id,
+ })
+
+ # confirm quotation
+ so1.action_confirm()
+ self.assertTrue(so1.state == 'draft')
+ self.assertFalse(so1.ignore_exception)