1
# -*- encoding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
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 mx.DateTime import now
29
from tools.translate import _
31
init_form = '''<?xml version="1.0"?>
32
<form string="Ver Líneas de Producción" col="6">
33
<field name="campaign_id"/>
36
'campaign_id': {'type':'many2one', 'relation':'campaign.campaign', 'string':'Campaña', 'required':True},
39
class show_production(wizard.interface):
41
def _show_production_dos_lineas(self, cr, uid, data, context):
42
pool = pooler.get_pool(cr.dbname)
43
campaign_id = data['form']['campaign_id']
44
production_lines_obj = pool.get('crm.agendas.production.order.lines')
45
production_obj = pool.get('crm.agendas.production.order')
47
production_ids = production_obj.search(cr, uid, [('campaign','=',campaign_id)])
48
order_ids = production_lines_obj.search(cr, uid, [('production_id','in',production_ids)])
49
orders = production_lines_obj.read(cr, uid, order_ids, ['production_id'])
50
orders_ids = [x['production_id'][0] for x in orders]
52
set_lista = set(orders_ids)
53
set_lista = list(set_lista)
56
for numero in set_lista:
57
if orders_ids.count(numero) >= 2:
58
lista_final.append(numero)
61
'domain': "[('id','in',(" + str(lista_final) +"))]",
63
'view_mode': 'tree,form',
64
'res_model': 'crm.agendas.production.order',
65
'type': 'ir.actions.act_window',
69
def _suma_de_cantidades_error(self, cr, uid, data, context):
70
pool = pooler.get_pool(cr.dbname)
71
campaign_id = data['form']['campaign_id']
72
production_lines_obj = pool.get('crm.agendas.production.order.lines')
73
production_obj = pool.get('crm.agendas.production.order')
75
production_ids = production_obj.search(cr, uid, [('campaign','=',campaign_id)])
78
for production_id in production_obj.browse(cr, uid, production_ids):
80
if production_id.lines_ids:
81
for line_id in production_id.lines_ids:
82
sum_lines = sum_lines + line_id.cantidad
83
sum_cantidad = production_id.primaria + production_id.secundaria + \
84
production_id.bachillerato + production_id.bilingue + \
85
production_id.inf_0a3 + production_id.inf_3a6 + production_id.cantidad
86
if sum_cantidad != sum_lines:
87
lista_final.append(production_id.id)
90
'domain': "[('id','in',(" + str(lista_final) +"))]",
92
'view_mode': 'tree,form',
93
'res_model': 'crm.agendas.production.order',
94
'type': 'ir.actions.act_window',
101
'result': {'type':'form', 'arch':init_form, 'fields':init_fields,
102
'state':[('end','Cancel','gtk-cancel')
103
,('dos_lineas_pers','Dos Líneas Personalizadas','gtk-go-forward')
104
,('error_cantidades','Error Cantidades','gtk-go-forward')]}
108
'result':{'type':'action', 'action':_show_production_dos_lineas, 'state':'end'}
112
'result':{'type':'action', 'action':_suma_de_cantidades_error, 'state':'end'}
117
show_production('crm_agendas_escolares.show_production')
118
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: