Browse Source

[IMP] Add tests and dependencies to pass travis and build runbot

pull/367/head
cubells 8 years ago
parent
commit
628e8a3b17
  1. 1
      oca_dependencies.txt
  2. 2
      partner_payment_return_risk/models/res_partner.py
  3. 5
      partner_payment_return_risk/tests/__init__.py
  4. 38
      partner_payment_return_risk/tests/test_payment_return_risk.py

1
oca_dependencies.txt

@ -1 +1,2 @@
account-payment
product-attribute

2
partner_payment_return_risk/models/res_partner.py

@ -23,7 +23,7 @@ class ResPartner(models.Model):
AccountInvoice = self.env['account.invoice']
for partner in self:
partner.risk_payment_return = AccountInvoice.read_group(
[('id', '=', partner.id),
[('partner_id', '=', partner.id),
('returned_payment', '=', True),
('state', '=', 'open'),
],

5
partner_payment_return_risk/tests/__init__.py

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Carlos Dauden <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_payment_return_risk

38
partner_payment_return_risk/tests/test_payment_return_risk.py

@ -0,0 +1,38 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Carlos Dauden <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.tests import common
class TestPartnerPaymentReturnRisk(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestPartnerPaymentReturnRisk, cls).setUpClass()
cls.partner = cls.env['res.partner'].create({
'name': 'Test partner',
'risk_payment_return_include': True,
'risk_payment_return_limit': 50.0,
})
cls.user_type = cls.env.ref('account.data_account_type_revenue')
cls.invoice = cls.env['account.invoice'].create({
'partner_id': cls.partner.id,
'invoice_line_ids': [(0, 0, {
'name': 'Product Test',
'quantity': 1.0,
'uom_id': cls.env.ref('product.product_uom_unit').id,
'price_unit': 100.0,
'account_id': cls.env['account.account'].search([
('user_type_id', '=', cls.user_type.id)], limit=1).id,
})]
})
def test_payment_return_risk(self):
self.invoice.signal_workflow('invoice_open')
# Partner risk is zero because invoice is not returned
self.assertAlmostEqual(self.partner.risk_payment_return, 0.0)
# We simulate that the invoice is returned
self.invoice.returned_payment = True
# Partner risk has increased
self.assertAlmostEqual(self.partner.risk_payment_return, 100.0)
Loading…
Cancel
Save