[IMP]: base_calendar: Converted wizard into osv_memory wizard
bzr revid: rpa@tinyerp.com-20100311052302-0eqro8knu4mpjs12
This commit is contained in:
parent
d98d3acc46
commit
52f667cbf8
|
@ -40,7 +40,8 @@
|
|||
],
|
||||
"demo_xml" : [],
|
||||
"update_xml" : [
|
||||
'security/ir.model.access.csv',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/calendar_event_edit_all_view.xml',
|
||||
'base_calendar_view.xml'
|
||||
],
|
||||
"installable" : True,
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import wizard_cal_edit_event
|
||||
|
||||
import calendar_event_edit_all
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
import netsvc
|
||||
import pooler
|
||||
import time
|
||||
import tools
|
||||
import wizard
|
||||
|
||||
class calendar_event_edit_all(osv.osv_memory):
|
||||
|
||||
def _default_values(self, cr, uid, context={}):
|
||||
"""
|
||||
@Return : Get Default value for Start Date
|
||||
"""
|
||||
if context.get('date'):
|
||||
return context.get('date')
|
||||
else:
|
||||
model = context.get('model')
|
||||
model_obj = self.pool.get(model)
|
||||
event = model_obj.read(cr, uid, context['active_id'], ['name', 'location', 'alarm_id'])
|
||||
return event['date']
|
||||
|
||||
def _default_deadline(self, cr, uid, context={}):
|
||||
"""
|
||||
@return : Get Default value for End Date
|
||||
"""
|
||||
if context.get('date_deadline'):
|
||||
return context.get('date_deadline')
|
||||
else:
|
||||
model = context.get('model')
|
||||
model_obj = self.pool.get(model)
|
||||
event = model_obj.read(cr, uid, context['active_id'], ['name', 'location', 'alarm_id'])
|
||||
return event['date_deadline']
|
||||
|
||||
def _modify_this(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
Modify All event for Crm Meeting.
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of calendar event edit all’s IDs
|
||||
"""
|
||||
for datas in self.read(cr, uid, ids):
|
||||
model = context.get('model')
|
||||
model_obj = self.pool.get(model)
|
||||
model_obj.modify_all(cr, uid, [context['active_id']], datas, context)
|
||||
return {}
|
||||
|
||||
_name = "calendar.event.edit.all"
|
||||
_description = "Calendar Edit all event"
|
||||
_columns ={
|
||||
'name':fields.char('Title', size=64, required=True),
|
||||
'date':fields.datetime('Start Date', required=True),
|
||||
'date_deadline':fields.datetime('End Date', required=True),
|
||||
'location':fields.char('Location', size=124),
|
||||
'alarm_id':fields.many2one('res.alarm', 'Reminder'),
|
||||
}
|
||||
_defaults = {
|
||||
'date':_default_values,
|
||||
'date_deadline':_default_deadline
|
||||
}
|
||||
|
||||
calendar_event_edit_all()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_calendar_event_edit_all" model="ir.ui.view">
|
||||
<field name="name">calendar.event.edit.all.form</field>
|
||||
<field name="model">calendar.event.edit.all</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Edit all Occurrences">
|
||||
<group colspan="4" >
|
||||
<separator string="" colspan="4" />
|
||||
<newline/>
|
||||
<field name='name' colspan="4" />
|
||||
<newline />
|
||||
<field name='location' colspan="4" />
|
||||
<newline />
|
||||
<field name='date' />
|
||||
<field name='date_deadline' />
|
||||
<newline />
|
||||
<field name='alarm_id'/>
|
||||
</group>
|
||||
<separator string="" colspan="4" />
|
||||
<group colspan="4" col="6">
|
||||
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
|
||||
<button icon="gtk-save" string="_Save" name="_modify_this" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_calendar_event_edit_all" model="ir.actions.act_window">
|
||||
<field name="name">Edit all events</field>
|
||||
<field name="res_model">calendar.event.edit.all</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_calendar_event_edit_all"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,78 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 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
|
||||
|
||||
class event_edit_all(wizard.interface):
|
||||
event_form = """<?xml version="1.0"?>
|
||||
<form string="Edit all Occurrences">
|
||||
<separator string="" colspan="4" />
|
||||
<newline />
|
||||
<field name='name' colspan="4" />
|
||||
<newline />
|
||||
<field name='location' colspan="4" />
|
||||
<newline />
|
||||
<field name='date' />
|
||||
<field name='date_deadline' />
|
||||
<newline />
|
||||
<field name='alarm_id'/>
|
||||
</form>"""
|
||||
|
||||
event_fields = {
|
||||
'name': {'string': 'Title', 'type': 'char', 'size': 64, 'required': True},
|
||||
'date': {'string': 'Start Date', 'type': 'datetime', 'required': True},
|
||||
'date_deadline': {'string': 'End Date', 'type': 'datetime', 'required': True},
|
||||
'location': {'string': 'Location', 'type': 'char', 'size': 124},
|
||||
'alarm_id': {'string': 'Reminder', 'type': 'many2one', 'relation': 'res.alarm'},
|
||||
}
|
||||
|
||||
def _default_values(self, cr, uid, data, context=None):
|
||||
model = data.get('model')
|
||||
model_obj = pooler.get_pool(cr.dbname).get(model)
|
||||
event = model_obj.read(cr, uid, data['id'], ['name', 'location', 'alarm_id'])
|
||||
event.update({
|
||||
'date': context.get('date'),
|
||||
'date_deadline': context.get('date_deadline')
|
||||
})
|
||||
return event
|
||||
|
||||
def _modify_this(self, cr, uid, datas, context=None):
|
||||
model = datas.get('model')
|
||||
model_obj = pooler.get_pool(cr.dbname).get(model)
|
||||
model_obj.modify_all(cr, uid, [datas['id']], datas['form'], context)
|
||||
return {}
|
||||
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [_default_values],
|
||||
'result': {'type': 'form', 'arch': event_form, 'fields': event_fields,
|
||||
'state': [('end', 'Cancel', 'gtk-cancel'), ('edit', '_Save', 'gtk-save')]}
|
||||
},
|
||||
'edit': {
|
||||
'actions': [],
|
||||
'result': {'type': 'action', 'action': _modify_this, 'state': 'end'}
|
||||
}
|
||||
}
|
||||
|
||||
event_edit_all('calendar.event.edit.all')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
Loading…
Reference in New Issue