[IMP]: event_project: convert wizard into osv memory wizard.

bzr revid: atp@tinyerp.co.in-20100630142254-8h224pl84cofbjy9
This commit is contained in:
atp (Open ERP) 2010-06-30 19:52:54 +05:30
parent ab3047a80a
commit c7a063949a
7 changed files with 66 additions and 145 deletions

View File

@ -31,7 +31,7 @@
'author': 'Tiny',
'depends': ['project_retro_planning', 'event'],
'init_xml': [],
'update_xml': ['event_wizard.xml', 'event_view.xml'],
'update_xml': ['wizard/event_project_view.xml', 'event_view.xml'],
'demo_xml': [],
'installable': True,
'active': False,

View File

@ -13,7 +13,7 @@
<field name="register_max" position="after">
<separator string="Tasks management" colspan="4"/>
<field name="project_id"/>
<button string="Create Retro-Planning" name="%(event_wiz)d" type="action" icon="gtk-execute"/>
<button string="Create Retro-Planning" name="%(action_event_project)d" type="action" icon="gtk-execute"/>
</field>
</field>
</record>
@ -39,6 +39,15 @@
</field>
</field>
</record>
<act_window
id="act_event_task"
name="Tasks"
res_model="project.task"
src_model="event.event"
view_mode="tree,form,calendar,graph"
domain="[('project_id', '=', project_id)]"
view_type="form"/>
</data>
</openerp>

View File

@ -1,18 +1,6 @@
<?xml version="1.0" ?>
<openerp>
<data>
<wizard string="Project"
model="event.event"
name="event.project"
id="event_wiz"
menu="False"/>
<wizard
string="Tasks"
model="event.event"
name="wizard_event_tasks"
id="wizard_event_task"/>
</data>
</openerp>

View File

@ -19,8 +19,7 @@
#
##############################################################################
import project_wizard
import event_task
import event_project
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
#
# Order Point Method:
# - Order if the virtual stock of today is bellow the min of the defined order point
#
from osv import fields, osv
from tools.translate import _
import time
class event_project(osv.osv_memory):
"""
Event Project
"""
_name = "event.project"
_description = "Event Project"
_columns = {
'project_id': fields.many2one('project.project', 'Project', domain = [('active', '<>', False), ('state', '=', 'template')], required =True)
}
def create_duplicate(self, cr, uid, ids, context):
event_obj=self.pool.get('event.event')
project_obj = self.pool.get('project.project')
for current in self.browse(cr, uid, ids):
duplicate_project_id= project_obj.copy(cr, uid, current.project_id.id, {'active': True})
project_obj.write(cr, uid, [duplicate_project_id], {'name': "copy of " + project_obj.browse(cr, uid, duplicate_project_id, context).name , 'date_start':time.strftime('%Y-%m-%d'), 'date': event_obj.browse(cr, uid, context.get('active_ids', []))[0].date_begin[0:10] })
event_obj.write(cr, uid, context.get('active_ids', []), {'project_id': duplicate_project_id })
return {}
event_project()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,62 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import wizard
import pooler
from tools.translate import _
def _event_tasks(self, cr, uid, data, context):
pool = pooler.get_pool(cr.dbname)
mod_obj = pool.get('ir.model.data')
result = mod_obj._get_id(cr, uid, 'project', 'view_task_search_form')
id = mod_obj.read(cr, uid, result, ['res_id'])
event_id = data['id']
cr.execute('SELECT project_id FROM event_event WHERE id = %s', (event_id, ))
res = cr.fetchone()
if not res[0]:
raise wizard.except_wizard(_('Error !'), _('No project defined for this event.\nYou can create one with the retro-planning button !'))
value = {
'domain': [('project_id', '=', res[0])],
'name': 'Tasks',
'view_type': 'form',
'view_mode': 'tree,form,calendar',
'res_model': 'project.task',
'context': { },
'type': 'ir.actions.act_window',
'search_view_id': id['res_id']
}
return value
class wizard_event_tasks(wizard.interface):
states = {
'init': {
'actions': [],
'result': {
'type': 'action',
'action': _event_tasks,
'state': 'end'
}
},
}
wizard_event_tasks("wizard_event_tasks")
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -1,67 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
#
# Order Point Method:
# - Order if the virtual stock of today is bellow the min of the defined order point
#
import wizard
import pooler
import time
parameter_form = '''<?xml version="1.0"?>
<form string="Event" colspan="4">
<field name="project_id"
/>
</form>'''
parameter_fields = {
'project_id': {'string':'Project', 'type':'many2one', 'required':True, 'relation':'project.project', 'domain': [('active','<>',False),('state','=','template')]},
}
def _create_duplicate(self, cr, uid, data, context):
event_obj=pooler.get_pool(cr.dbname).get('event.event')
project_obj = pooler.get_pool(cr.dbname).get('project.project')
duplicate_project_id= project_obj.copy(cr, uid, data['form']['project_id'], {'active': True})
project_obj.write(cr, uid, [duplicate_project_id], {'name': "copy of " + project_obj.browse(cr, uid, duplicate_project_id, context).name , 'date_start':time.strftime('%Y-%m-%d'),'date': event_obj.browse(cr, uid, [data['id']])[0].date_begin[0:10] })
event_obj.write(cr, uid, [data['id']], {'project_id': duplicate_project_id })
return {}
class wizard_event_project(wizard.interface):
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch':parameter_form, 'fields': parameter_fields, 'state':[('end','Cancel'),('done', 'Ok')]}
},
'done':{
'actions':[_create_duplicate],
'result' : {'type':'state', 'state':'end'}
}
}
wizard_event_project('event.project')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: