mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
============================================== Analytic plans for contract recurring invoices ============================================== This module allows to include an analytic plan on each recurring invoice line, so if you set it, this will be taken to be transferred to the invoice instead of the analytic account of the contract. Usage ===== On the contract view, select or create an analytic distribution for the invoice recurring lines that you want.
48 lines
2.0 KiB
Python
48 lines
2.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
import openerp.tests.common as common
|
|
|
|
|
|
class TestContractRecurringPlans(common.TransactionCase):
|
|
|
|
def setUp(self):
|
|
super(TestContractRecurringPlans, self).setUp()
|
|
self.partner = self.env['res.partner'].create({'name': 'Test'})
|
|
self.product = self.env.ref('product.product_product_consultant')
|
|
self.uom = self.env.ref('product.product_uom_hour')
|
|
self.contract = self.env['account.analytic.account'].create({
|
|
'name': 'Test contract',
|
|
'partner_id': self.partner.id,
|
|
'type': 'contract',
|
|
'recurring_invoices': 1,
|
|
'recurring_interval': 1,
|
|
'recurring_invoice_line_ids': [
|
|
(0, 0, {'quantity': 2.0,
|
|
'price_unit': 100.0,
|
|
'name': 'Test',
|
|
'product_id': self.product.id,
|
|
'uom_id': self.uom.id})],
|
|
})
|
|
plan = self.env['account.analytic.plan'].create({'name': 'Test'})
|
|
self.analytics = self.env['account.analytic.plan.instance'].create(
|
|
{'plan_id': plan.id})
|
|
|
|
def test_invoice_without_plans(self):
|
|
self.contract.recurring_create_invoice()
|
|
invoice = self.env['account.invoice'].search(
|
|
[('partner_id', '=', self.partner.id)])
|
|
self.assertEqual(
|
|
invoice.invoice_line[0].account_analytic_id, self.contract)
|
|
|
|
def test_invoice_with_plans(self):
|
|
self.contract.recurring_invoice_line_ids.analytics_id = (
|
|
self.analytics.id)
|
|
self.contract.recurring_create_invoice()
|
|
invoice = self.env['account.invoice'].search(
|
|
[('partner_id', '=', self.partner.id)])
|
|
self.assertFalse(invoice.invoice_line[0].account_analytic_id)
|
|
self.assertEqual(
|
|
invoice.invoice_line[0].analytics_id, self.analytics)
|