mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[MIG] sale_credit_limit: For Odoo13.0
This commit is contained in:
committed by
Jared Kipe
parent
ec82434f61
commit
dbb450f91f
@@ -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',
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
This sale order, or the customer has an outstanding balance that, exceeds their credit limit.</field>
|
||||
<field name="sequence">50</field>
|
||||
<field name="model">sale.order</field>
|
||||
<field name="rule_group">sale</field>
|
||||
<field name="code">
|
||||
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
|
||||
</field>
|
||||
<field name="active" eval="True" />
|
||||
<field name="rule_group">sale</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
@@ -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}
|
||||
|
||||
1
sale_credit_limit/tests/__init__.py
Normal file
1
sale_credit_limit/tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import test_sale_credit_exception
|
||||
32
sale_credit_limit/tests/test_sale_credit_exception.py
Normal file
32
sale_credit_limit/tests/test_sale_credit_exception.py
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user