[MERGE]: Merged with parent branch

bzr revid: uco@tinyerp.co.in-20091230124840-8xdp0355s0pmlkby
This commit is contained in:
uco (OpenERP)
2009-12-30 18:18:40 +05:30
15 changed files with 174 additions and 186 deletions
+15 -5
View File
@@ -38,13 +38,18 @@ def map_data(cr, uid, obj):
map_val = obj.ical_get(map_dict, 'value')
field = obj.ical_get(map_dict, 'field')
field_type = obj.ical_get(map_dict, 'type')
if field and map_val:
if field:
if field_type == 'selection':
if not map_val:
continue
mapping =obj.__attribute__[map_dict].get('mapping', False)
if mapping:
map_val = mapping[map_val]
if field_type == 'many2many':
ids = []
if not map_val:
vals[field] = ids
continue
model = obj.__attribute__[map_dict].get('object', False)
modobj = obj.pool.get(model)
for map_vall in map_val:
@@ -54,12 +59,16 @@ def map_data(cr, uid, obj):
continue
if field_type == 'many2one':
id = None
if not map_val:
vals[field] = id
continue
model = obj.__attribute__[map_dict].get('object', False)
modobj = obj.pool.get(model)
id = modobj.create(cr, uid, map_val)
vals[field] = id
continue
vals[field] = map_val
if map_val:
vals[field] = map_val
return vals
class CalDAV(object):
@@ -75,6 +84,7 @@ class CalDAV(object):
else:
startdate = todate(startdate)
rset1 = rrulestr(rrulestring, dtstart=startdate, forceset=True)
for date in exdate:
datetime_obj = todate(date)
rset1._exdate.append(datetime_obj)
@@ -162,9 +172,9 @@ class CalDAV(object):
continue
if cal_data.name.lower() in self.__attribute__:
self.ical_set(cal_data.name.lower(), cal_data.value, 'value')
vals = map_data(cr, uid, self)
if vals: res.append(vals)
self.ical_reset('value')
vals = map_data(cr, uid, self)
if vals: res.append(vals)
self.ical_reset('value')
return res
+7 -10
View File
@@ -172,15 +172,12 @@ class ir_attachment(osv.osv):
def search(self, cr, uid, args, offset=0, limit=None, order=None,
context=None, count=False):
new_args = []
if len(args) > 1:
new_args = [args[0]]
if args[1][0] == 'res_id':
new_args.append((args[1][0], args[1][1], caldevIDs2readIDs(args[1][2])))
if new_args:
args = new_args
return super(ir_attachment, self).search(cr, uid, args, offset=offset,
limit=limit, order=order,
new_args = args
for i, arg in enumerate(new_args):
if arg[0] == 'res_id':
new_args[i] = (arg[0], arg[1], caldevIDs2readIDs(arg[2]))
return super(ir_attachment, self).search(cr, uid, new_args, offset=offset,
limit=limit, order=order,
context=context, count=False)
ir_attachment()
@@ -319,7 +316,7 @@ class set_rrule_wizard(osv.osv_memory):
freq = datas.get('freq')
if freq == 'None':
obj.write(cr, uid, [res_obj.id], {'rrule' : '', 'rdates': ''})
obj.write(cr, uid, [res_obj.id], {'rrule' : ''})
return {}
if datas.get('interval') <= 0:
raise osv.except_osv(_('Error!'), ("Please select proper Interval"))
+29 -47
View File
@@ -70,17 +70,6 @@ class crm_meeting(osv.osv):
'valarm' : {'field':'alarm_id', 'type':'many2one', 'object' : 'crm.caldav.alarm'},
}
def _get_rdates(self, cr, uid, ids, name, arg, context=None):
res = {}
context.update({'read':True})
for case in self.read(cr, uid, ids, ['date', 'rrule', 'exdate', 'exrule'], context=context):
if case['rrule']:
rule = case['rrule']
exdate = case['exdate'] and case['exdate'].split(',') or []
event_obj = self.pool.get('caldav.event')
res[case['id']] = str(event_obj.get_recurrent_dates(str(rule), exdate, case['date']))
return res
_columns = {
'inherit_case_id': fields.many2one('crm.case','Case',ondelete='cascade'),
'class' : fields.selection([('PUBLIC', 'PUBLIC'), ('PRIVATE', 'PRIVATE'), \
@@ -95,8 +84,6 @@ class crm_meeting(osv.osv):
'exrule' : fields.char('Exception Rule', size=352, help="defines a rule or repeating pattern\
for anexception to a recurrence set"),
'rrule' : fields.char('Recurrent Rule', size=352),
'rdates' : fields.function(_get_rdates, method=True, string='Recurrent Dates', \
store=True, type='text'),
'attendees': fields.many2many('crm.caldav.attendee', 'crm_attendee_rel', 'case_id', \
'attendee_id', 'Attendees'),
'alarm_id' : fields.many2one('crm.caldav.alarm', 'Alarm'),
@@ -184,6 +171,9 @@ class crm_meeting(osv.osv):
alarm_obj.__attribute__.update(crm_alarm.__attribute__)
vals = event_obj.import_ical(cr, uid, file_content)
for val in vals:
section_id = self.pool.get('crm.case.section').search(cr, uid, \
[('name', 'like', 'Meeting%')])[0]
val.update({'section_id' : section_id})
is_exists = common.uid2openobjectid(cr, val['id'], self._name )
val.pop('id')
if val.has_key('create_date'): val.pop('create_date')
@@ -241,40 +231,33 @@ class crm_meeting(osv.osv):
if fields and 'date' not in fields:
fields.append('date')
res = super(crm_meeting, self).read(cr, uid, ids, fields=fields, context=context, load=load)
read_ids = ",".join([str(x) for x in ids])
if not read_ids:
if not ids:
return []
cr.execute('select id,rrule,rdates from crm_meeting where id in (%s)' % read_ids)
rrules = filter(lambda x: not x['rrule']==None, cr.dictfetchall())
rdates = []
if not rrules:
for ress in res:
strdate = ''.join((re.compile('\d')).findall(ress['date']))
idval = str(common.caldevIDs2readIDs(ress['id'])) + '-' + strdate
ress['id'] = idval
return res
result = res + []
for data in rrules:
if data['rrule'] and data['rdates']:
rdates = eval(data['rdates'])
for res_temp in res:
if res_temp['id'] == data['id']:
val = res_temp
if rdates:
result.remove(val)
else:
strdate = ''.join((re.compile('\d')).findall(res_temp['date']))
idval = str(common.caldevIDs2readIDs(res_temp['id'])) + '-' + strdate
res_temp['id'] = idval
for rdate in rdates:
idval = (re.compile('\d')).findall(rdate)
val['date'] = rdate
id = str(val['id']).split('-')[0]
val['id'] = id + '-' + ''.join(idval)
val1 = val.copy()
result += [val1]
result = []
for read_id in ids:
res = super(crm_meeting, self).read(cr, uid, read_id, fields=fields, context=context, load=load)
cr.execute("""select m.id, m.rrule, c.date, m.exdate from crm_meeting m\
join crm_case c on (c.id=m.inherit_case_id) \
where m.id = %s""" % read_id)
data = cr.dictfetchall()[0]
if not data['rrule']:
strdate = ''.join((re.compile('\d')).findall(data['date']))
idval = str(common.caldevIDs2readIDs(data['id'])) + '-' + strdate
data['id'] = idval
res.update(data)
result.append(res)
else:
exdate = data['exdate'] and data['exdate'].split(',') or []
event_obj = self.pool.get('caldav.event')
rdates = event_obj.get_recurrent_dates(str(data['rrule']), exdate, data['date'])[:10]
for rdate in rdates:
val = res.copy()
idval = (re.compile('\d')).findall(rdate)
val['date'] = rdate
id = str(res['id']).split('-')[0]
val['id'] = id + '-' + ''.join(idval)
val1 = val.copy()
result.append(val1)
return result
def copy(self, cr, uid, id, default=None, context={}):
@@ -375,5 +358,4 @@ class crm_meeting_generic_wizard(osv.osv_memory):
crm_meeting_generic_wizard()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-3
View File
@@ -87,9 +87,6 @@
<page string="Other Info">
<field name="caldav_url" widget="url" readonly="True"/>
<newline/>
<separator string="Recurrenet Dates" colspan="4"/>
<field name="rdates" colspan="4" nolabel="1" readonly="True"/>
<newline/>
<field name="exrule" string="Exception Rules" colspan="4"/>
<separator string="Exception Dates" colspan="4"/>
<field name="exdate" nolabel="1" colspan="4" />
+9 -5
View File
@@ -19,10 +19,11 @@
#
##############################################################################
import wizard
from tools.translate import _
import base64
import pooler
import urllib
import base64
import wizard
class crm_cal_subscribe_wizard(wizard.interface):
form1 = '''<?xml version="1.0"?>
@@ -55,9 +56,12 @@ class crm_cal_subscribe_wizard(wizard.interface):
def _process_imp_ics(self, cr, uid, data, context=None):
global cnt
cnt = 0
f = urllib.urlopen(data['form']['url_path'])
caldata= f.fp.read()
f.close()
try:
f = urllib.urlopen(data['form']['url_path'])
caldata= f.fp.read()
f.close()
except Exception,e:
raise wizard.except_wizard(_('Error!'), _('Please provide Proper URL !'))
case_obj = pooler.get_pool(cr.dbname).get('crm.meeting')
context.update({'url': data['form']['url_path']})
vals = case_obj.import_cal(cr, uid, base64.encodestring(caldata), context)
+1 -1
View File
@@ -149,7 +149,7 @@ class document_configuration_wizard(osv.osv_memory):
})
# Update the action for FTP browse.
aid = objid._get_id(cr, uid, 'document', 'action_document_browse')
aid = objid._get_id(cr, uid, 'document_ftp', 'action_document_browse')
aid = objid.browse(cr, uid, aid, context=context).res_id
self.pool.get('ir.actions.url').write(cr, uid, [aid], {'url': 'ftp://'+(conf.host or 'localhost')+':8021/'})
+2 -2
View File
@@ -17,8 +17,8 @@
<field name="directory_id" ref="dir_calendars"/>
<field name="extension">.ics</field>
<field name="include_name" eval="False"/>
<field name="ics_object_id" ref="crm.model_crm_case"/>
<field name="ics_domain" eval="'[(\'section_id\',\'=\','+str(ref('section_meeting'))+')]'"/>
<field name="object_id" ref="crm.model_crm_meeting"/>
<field name="ics_domain" eval="'[]'"/>
</record>
<record model="document.directory.ics.fields" id="dir_field1">
+2 -2
View File
@@ -80,7 +80,7 @@ class document_directory_content(osv.osv):
'obj_iterate': fields.boolean('Iterate object',help="If set, a separate instance will be created for each record of Object"),
'fname_field': fields.char("Filename field",size=16,help="The field of the object used in the filename. Has to be a unique identifier."),
'ics_domain': fields.char('Domain', size=64),
'ics_field_ids': fields.one2many('document.directory.ics.fields', 'content_id', 'Fields Mapping')
#'ics_field_ids': fields.one2many('document.directory.ics.fields', 'content_id', 'Fields Mapping')
}
_defaults = {
'ics_domain': lambda *args: '[]'
@@ -140,7 +140,7 @@ class document_directory_content(osv.osv):
idomain[d[0]]=d[2]
fobj = self.pool.get(content.object_id.model)
fobj.import_cal(cr, uid, base64.encodestring(data), context=context)
fobj.import_cal(cr, uid, base64.encodestring(data), context=context)
return True
def process_read(self, cr, uid, node, context=None):
+4 -3
View File
@@ -21,17 +21,18 @@
<field name="type">form</field>
<field name="inherit_id" ref="view_document_directory_form_1"/>
<field name="arch" type="xml">
<field name="report_id" position="after">
<field name="report_id" position="replace">
<field name="report_id" domain="[('model_id','=',parent.ressource_type_id)]"/>
<separator string="ICS Calendar" colspan="4"/>
<field name="ics_domain"/>
<field name="ics_field_ids" colspan="4">
<!-- <field name="ics_field_ids" colspan="4">
<tree string="ICS Mapping" editable="bottom">
<field name="name"/>
<field name="fn" />
<field name="field_id" domain="[('model_id','=?',parent.object_id)]"/>
<field name="expr" />
</tree>
</field>
</field> -->
</field>
</field>
</record>
@@ -9,6 +9,10 @@
multi="True"
/>
<wizard string="Subscribe to a Remote calendar" model="project.task"
name="caldav.project.subscribe" id="wizard_project_cal_subscribe" multi="True"
/>
<wizard string="Set RRULE" model="crm.case"
name="caldav.set.rrule" id="wizard_crm_set_rrule" menu="False"
/>
@@ -21,5 +21,6 @@
import wizard_cal_export
import wizard_cal_import
import wizard_cal_subscribe
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@ -0,0 +1,95 @@
# -*- 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 tools.translate import _
import base64
import pooler
import urllib
import wizard
class project_cal_subscribe_wizard(wizard.interface):
form1 = '''<?xml version="1.0"?>
<form string="Subscribe to Remote ICS">
<separator string="Provide path for Remote Calendar"/>
<field name="url_path" colspan="4" width="300" nolabel="1" widget="url"/>
</form>'''
form1_fields = {
'url_path': {
'string': 'Provide path for remote calendar',
'type': 'char',
'required': True,
'size': 124
}
}
display = '''<?xml version="1.0"?>
<form string="Message...">
<field name="msg" colspan="4" width="300" nolabel="1"/>
</form>'''
display_fields = {
'msg': {
'string': '',
'type': 'text',
'readonly': True,
}
}
def _process_imp_ics(self, cr, uid, data, context=None):
global cnt
cnt = 0
try:
f = urllib.urlopen(data['form']['url_path'])
caldata= f.fp.read()
f.close()
except Exception,e:
raise wizard.except_wizard(_('Error!'), _('Please provide Proper URL !'))
task_obj = pooler.get_pool(cr.dbname).get('project.task')
context.update({'url': data['form']['url_path']})
vals = task_obj.import_cal(cr, uid, base64.encodestring(caldata), context)
if vals:
cnt = vals['count']
return {}
def _result_set(self, cr, uid, data, context=None):
return {'msg': 'Subscribed %s Task(s)' % cnt}
states = {
'init': {
'actions': [],
'result': {'type': 'form', 'arch': form1, 'fields': form1_fields, \
'state': [('end', '_Cancel', 'gtk-cancel'), ('open', '_Subscribe', 'gtk-ok')]}
},
'open': {
'actions': [],
'result': {'type': 'action', 'action': _process_imp_ics, 'state': 'display'}
},
'display': {
'actions': [_result_set],
'result': {'type': 'form', 'arch': display, 'fields': display_fields, \
'state': [('end', 'Ok', 'gtk-ok')]}
},
}
project_cal_subscribe_wizard('caldav.project.subscribe')
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+2 -2
View File
@@ -776,8 +776,8 @@ class sale_order_line(osv.osv):
'notes': fields.text('Notes'),
'th_weight': fields.float('Weight'),
'state': fields.selection([('draft', 'Draft'),('confirmed', 'Confirmed'),('done', 'Done'),('cancel', 'Cancelled'),('exception', 'Exception')], 'State', required=True, readonly=True,
help=' * The \'Draft\' state is set automatically when sale order in draft state.. \
\n* The \'Confirmed\' state is set automatically as confirm when sale order in confirm state. \
help=' * The \'Draft\' state is set automatically when sale order in draft state. \
\n* The \'Confirmed\' state is set automatically when sale order in confirm state. \
\n* The \'Exception\' state is set automatically when sale order is set as exception. \
\n* The \'Done\' state is set automatically when sale order is set as done. \
\n* The \'Cancelled\' state is set automatically when user cancel sale order.'),
-65
View File
@@ -901,71 +901,6 @@ class stock_production_lot(osv.osv):
stock_production_lot()
class stock_split_production_lots(osv.osv_memory):
_name = "stock.split.production.lots"
_description = "Split Production Lots"
def _quantity_default_get(self, cr, uid, object=False, field=False, context=None):
cr.execute("select %s from %s where id=%s" %(field,object,context.get('active_id')))
res = cr.fetchone()[0]
return res
_columns = {
'name': fields.char('Lot Number/Prefix', size=64, required=True),
'qty': fields.float('Total Quantity'),
'action': fields.selection([('split','Split'),('keepinone','Keep in one lot')],'Action'),
}
_defaults = {
'qty': lambda self,cr,uid,c: self.pool.get('stock.split.production.lots')._quantity_default_get(cr, uid, 'stock_move', 'product_qty',context=c) or 1,
}
def split_lines(self, cr, uid, ids, context={}):
data = self.read(cr, uid, ids[0])
prodlot_obj = self.pool.get('stock.production.lot')
move_obj = self.pool.get('stock.move')
move_browse = move_obj.browse(cr, uid, context['active_id'])
quantity = data['qty']
if quantity <= 0 or move_browse.product_qty == 0:
return {}
uos_qty = quantity/move_browse.product_qty*move_browse.product_uos_qty
quantity_rest = move_browse.product_qty%quantity
uos_qty_rest = quantity_rest/move_browse.product_qty*move_browse.product_uos_qty
update_val = {
'product_qty': quantity,
'product_uos_qty': uos_qty,
}
new_move = []
for idx in range(int(move_browse.product_qty//quantity)):
if idx:
current_move = move_obj.copy(cr, uid, move_browse.id, {'state': move_browse.state})
new_move.append(current_move)
else:
current_move = move_browse.id
new_prodlot = prodlot_obj.create(cr, uid, {'name': data['name'], 'ref': '%d'%idx}, {'product_id': move_browse.product_id.id})
update_val['prodlot_id'] = new_prodlot
move_obj.write(cr, uid, [current_move], update_val)
if quantity_rest > 0:
idx = int(move_browse.product_qty//quantity)
update_val['product_qty'] = quantity_rest
update_val['product_uos_qty'] = uos_qty_rest
if idx:
current_move = move_obj.copy(cr, uid, move_browse.id, {'state': move_browse.state})
new_move.append(current_move)
else:
current_move = move_browse.id
new_prodlot = prodlot_obj.create(cr, uid, {'name': data['name'], 'ref': '%d'%idx}, {'product_id': move_browse.product_id.id})
update_val['prodlot_id'] = new_prodlot
move_obj.write(cr, uid, [current_move], update_val)
return {}
stock_split_production_lots()
class stock_production_lot_revision(osv.osv):
_name = 'stock.production.lot.revision'
+3 -41
View File
@@ -481,32 +481,6 @@
=============================
Picking
=============================
<record id="view_stock_split_production_lots" model="ir.ui.view">
<field name="name">Split Production Lots</field>
<field name="model">stock.split.production.lots</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Split Production Lots">
<group col="4" colspan="4">
<field name="name"/>
<field name="qty" attrs="{'readonly':[('action','!=','split')]}"/>
<field name="action" colspan="4"/>
</group>
<newline/>
<button name="split_lines" string="Ok" type="object" icon="gtk-go-forward"/>
</form>
</field>
</record>
<record id="action_view_stock_split_production_lots" model="ir.actions.act_window">
<field name="name">Split Production Lots</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.split.production.lots</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<record model="ir.ui.view" id="stock_picking_calendar">
<field name="name">stock.picking.calendar</field>
<field name="model">stock.picking</field>
@@ -575,11 +549,7 @@
<field groups="base.group_extended" name="tracking_id" select="2"/>
<newline/>
<label/>
<!--button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/-->
<button
string="Split in Production Lots"
name="%(stock.action_view_stock_split_production_lots)d"
icon="gtk-stock" type="action"/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/>
<separator colspan="4" string="Move State"/>
<field name="state" select="1"/>
<group>
@@ -854,11 +824,7 @@
on_change="onchange_lot_id(prodlot_id,product_qty, location_id, product_id)"/>
<field groups="base.group_extended" name="tracking_id" select="1"/>
<label/>
<!--button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/-->
<button
string="Split in Production Lots"
name="%(stock.action_view_stock_split_production_lots)d"
icon="gtk-stock" type="action"/>
<button name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/>
<separator colspan="4" string="Move State"/>
<field name="state" select="1"/>
<group>
@@ -1014,11 +980,7 @@
<field groups="base.group_extended" name="tracking_id" select="1"/>
<newline/>
<label/>
<!--button groups="base.group_extended" name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/-->
<button
string="Split in Production Lots"
name="%(stock.action_view_stock_split_production_lots)d"
icon="gtk-stock" type="action"/>
<button groups="base.group_extended" name="%(track_line)d" string="Split in production lots" type="action" icon="gtk-justify-fill"/>
<separator colspan="4" string="Move State"/>
<field name="state" select="1"/>
<group>