Carlos Incaser
9 years ago
7 changed files with 147 additions and 37 deletions
-
19contract/README.rst
-
2contract/__openerp__.py
-
50contract/models/contract.py
-
6contract/tests/__init__.py
-
41contract/tests/test_contract.py
-
19contract/views/account_invoice_view.xml
-
47contract/views/contract.xml
@ -0,0 +1,6 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# (c) 2015 Antiun Ingeniería S.L. - Sergio Teruel |
|||
# (c) 2015 Antiun Ingeniería S.L. - Carlos Dauden |
|||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
|||
|
|||
from . import test_contract |
@ -0,0 +1,41 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Incaser Informatica S.L. - Carlos Dauden |
|||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
|||
from openerp.exceptions import ValidationError |
|||
from openerp.tests.common import TransactionCase |
|||
|
|||
|
|||
class TestContract(TransactionCase): |
|||
# Use case : Prepare some data for current test case |
|||
def setUp(self): |
|||
super(TestContract, self).setUp() |
|||
self.partner = self.env.ref('base.res_partner_2') |
|||
self.product = self.env.ref('product.product_product_2') |
|||
self.contract = self.env['account.analytic.account'].create({ |
|||
'name': 'Test Contract', |
|||
'partner_id': self.partner.id, |
|||
'pricelist_id': self.partner.property_product_pricelist.id, |
|||
'recurring_invoices': True, |
|||
}) |
|||
self.contract_line = self.env['account.analytic.invoice.line'].create({ |
|||
'analytic_account_id': self.contract.id, |
|||
'product_id': self.product.id, |
|||
'name': 'Services from #START# to #END#', |
|||
'quantity': 1, |
|||
'uom_id': self.product.uom_id.id, |
|||
'price_unit': 100, |
|||
'discount': 50, |
|||
}) |
|||
|
|||
def test_check_discount(self): |
|||
with self.assertRaises(ValidationError): |
|||
self.contract_line.write({'discount': 120}) |
|||
|
|||
def test_create_invoice(self): |
|||
self.contract.recurring_create_invoice() |
|||
self.invoice = self.env['account.invoice'].search( |
|||
[('contract_id', '=', self.contract.id)]) |
|||
self.assertTrue(self.invoice) |
|||
|
|||
self.inv_line = self.invoice.invoice_line_ids[0] |
|||
self.assertAlmostEqual(self.inv_line.price_subtotal, 50.0) |
@ -0,0 +1,19 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<!-- Invoice search view with contract --> |
|||
<record id="view_account_invoice_filter_contract" model="ir.ui.view"> |
|||
<field name="name">account.invoice.select.contract</field> |
|||
<field name="model">account.invoice</field> |
|||
<field name="inherit_id" ref="account.view_account_invoice_filter"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="date" position="after"> |
|||
<separator/> |
|||
<field name="contract_id"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue