1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (c) 2012 Serv. Tecnol. Avanzados (http://www.serviciosbaeza.com) All Rights Reserved.
6
# Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
23
from osv import osv, fields
24
from tools.translate import _
26
class renew_wizard(osv.osv_memory):
28
_name = "sale.recurring_orders.renew_wizard"
30
def _get_renovation_date(self, cr, uid, context=None):
32
It returns the next expiration date of the active agreement.
33
@rtype: string with date
34
@return: Next expiration date of the agreement.
36
agreements = self.pool.get('sale.recurring_orders.agreement').browse(cr, uid, context.get('active_ids',[]), context=context)
37
return agreements[0].next_expiration_date
40
'date': fields.date('Renewal date', help="Effective date of the renewal. This date is the one taken into account in the next renewal", required=True),
41
'comments': fields.char('Comments', size=200, help='Renewal comments'),
45
'date': _get_renovation_date,
48
def create_renewal(self, cr, uid, ids, context=None):
50
It creates agreement renewal records with data given in this wizard.
52
if context is None: context = {}
54
# Create agreement renewal record
55
renew_wizard = self.browse(cr, uid, ids[0], context=context)
56
agreement_ids = context.get('active_ids',[])
57
for agreement_id in agreement_ids:
58
self.pool.get('sale.recurring_orders.agreement.renewal').create(cr, uid, {
59
'agreement_id': agreement_id,
60
'date': renew_wizard.date,
61
'comments': renew_wizard.comments,
64
# Change last renovation date and state in agreement
65
self.pool.get('sale.recurring_orders.agreement').write(cr, uid, agreement_ids, { 'last_renovation_date': renew_wizard.date, 'renewal_state': 'renewed' }, context=context)
67
return {'type': 'ir.actions.act_window_close'}
b'\\ No newline at end of file'