[MERGE]: Merge with lp:~openerp-dev/openobject-addons/trunk-dev-addons1
authoratp (Open ERP) <atp@tinyerp.co.in>
Thu, 23 Dec 2010 10:57:05 +0000 (16:27 +0530)
committeratp (Open ERP) <atp@tinyerp.co.in>
Thu, 23 Dec 2010 10:57:05 +0000 (16:27 +0530)
bzr revid: atp@tinyerp.co.in-20101223105705-xyo4vu424j3lhqlt

14 files changed:
addons/caldav/caldav_view.xml
addons/caldav/calendar.py
addons/caldav/wizard/__init__.py
addons/crm_caldav/crm_caldav.py
addons/crm_caldav/crm_caldav_data.xml
addons/crm_caldav/crm_caldav_setup.xml
addons/crm_claim/report/crm_claim_report.py
addons/crm_claim/report/crm_claim_report_view.xml
addons/document/document.py
addons/document/document_data.xml
addons/document/nodes.py
addons/document/std_index.py
addons/document_ftp/wizard/ftp_configuration.py
addons/document_webdav/webdav_server.py

index 1081cb1..6ddcde0 100644 (file)
             <field name="res_model">basic.calendar</field>
             <field name="view_type">form</field>
             <field name="view_mode">tree,form</field>
+            <field name="help">"Calendars" allow you to Customize calendar event and todo attribute with any of OpenERP model.Caledars provide iCal Import/Export functionality.Webdav server that provides remote access to calendar.Help You to synchronize Meeting with Calendars client.You can access Calendars using CalDAV clients, like sunbird, Calendar Evaluation, Mobile.</field>
         </record>
 
         <record id="action_caldav_view1" model="ir.actions.act_window.view">
index 55d8fee..d2898fb 100644 (file)
@@ -148,6 +148,7 @@ def get_attribute_mapping(cr, uid, calname, context=None):
         @param calname: Get Calendar name
         @param context: A standard dictionary for contextual values """
 
+
     if context is None:
         context = {}
     pool = pooler.get_pool(cr.dbname)
@@ -164,6 +165,8 @@ def get_attribute_mapping(cr, uid, calname, context=None):
         res[attr] = {}
         res[attr]['field'] = field.field_id.name
         res[attr]['type'] = field.field_id.ttype
+        if field.fn == 'datetime_utc':
+            res[attr]['type'] = 'utc'
         if field.fn == 'hours':
             res[attr]['type'] = "timedelta"
         if res[attr]['type'] in ('one2many', 'many2many', 'many2one'):
@@ -227,6 +230,7 @@ def map_data(cr, uid, obj, context=None):
                     id = modobj.create(cr, uid, map_val, context=context)
                 vals[field] = id
                 continue
+            
             if field_type == 'timedelta':
                 if map_val:
                     vals[field] = (map_val.seconds/float(86400) + map_val.days)
@@ -254,7 +258,6 @@ class CalDAV(object):
          @param name: Get Attribute Name
          @param type: Get Attribute Type
         """
-
         if self.__attribute__.get(name):
             val = self.__attribute__.get(name).get(type, None)
             valtype =  self.__attribute__.get(name).get('type', None)
@@ -273,7 +276,6 @@ class CalDAV(object):
          @param self: The object pointer,
          @param type: Get Attribute Type
         """
-
         for name in self.__attribute__:
             if self.__attribute__[name]:
                 self.__attribute__[name][type] = None
@@ -446,6 +448,21 @@ class CalDAV(object):
                                 dtfield.value = self.format_date_tz(parser.parse(data[map_field]), tzval.title())
                             else:
                                 dtfield.value = parser.parse(data[map_field])
+                                
+                        elif map_type == 'utc'and data[map_field]:
+                            if tzval:
+                                local = pytz.timezone (tzval.title())
+                                naive = datetime.strptime (data[map_field], "%Y-%m-%d %H:%M:%S")
+                                local_dt = naive.replace (tzinfo = local)
+                                utc_dt = local_dt.astimezone (pytz.utc)
+                                vevent.add(field).value = utc_dt
+                            else:
+                               utc_timezone = pytz.timezone ('UTC')
+                               naive = datetime.strptime (data[map_field], "%Y-%m-%d %H:%M:%S")
+                               local_dt = naive.replace (tzinfo = utc_timezone)
+                               utc_dt = local_dt.astimezone (pytz.utc)
+                               vevent.add(field).value = utc_dt
+
                         elif map_type == "timedelta":
                             vevent.add(field).value = timedelta(hours=data[map_field])
                         elif map_type == "many2one":
@@ -829,6 +846,7 @@ class basic_calendar_fields(osv.osv):
         'fn': fields.selection([('field', 'Use the field'),
                         ('const', 'Expression as constant'),
                         ('hours', 'Interval in hours'),
+                        ('datetime_utc', 'Datetime In UTC'),
                         ], 'Function'),
         'mapping': fields.text('Mapping'),
     }
@@ -886,7 +904,6 @@ class basic_calendar_fields(osv.osv):
             @param vals: Get Values
             @param context: A standard dictionary for contextual values
         """
-
         if not vals:
             return
         for id in ids:
@@ -1279,4 +1296,5 @@ class Attendee(CalDAV, osv.osv_memory):
 
 Attendee()
 
+
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 1c45cb2..08b2982 100644 (file)
@@ -22,5 +22,4 @@
 import calendar_event_export
 import calendar_event_import
 import calendar_event_subscribe
-
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 8ba5990..d9709f2 100644 (file)
@@ -44,6 +44,7 @@ class crm_meeting(osv.osv):
         ical = event_obj.export_cal(cr, uid, event_data, context=context)
         return ical.serialize()
 
+
     def import_cal(self, cr, uid, data, data_id=None, context=None):
         """
             @param self: The object pointer
@@ -88,6 +89,7 @@ class crm_meeting(osv.osv):
                     val.update({'recurrent_uid': exists})
                     model_obj.write(cr, uid, [r_id], val)
                     ids.append(r_id)
+                    
                 elif exists:
                     model_obj.write(cr, uid, [exists], val)
                     ids.append(exists)
index 0e28af5..ac05344 100644 (file)
         <record model="basic.calendar.fields" id="map_event_13">
             <field name="name" ref="caldav.field_event_dtstamp"/>
             <field name="type_id" ref="base_calendar.calendar_lines_event" />
-            <field name="field_id" search="[('name','=','date'),('model_id.model','=','calendar.event')]" />
-            <field name="fn">field</field>
+            <field name="field_id" search="[('name','=','write_date'),('model_id.model','=','crm.meeting')]" />
+            <field name="fn">datetime_utc</field>
         </record>
 
         <record model="basic.calendar.fields" id="map_event_14">
index 1a103f6..7e20a31 100644 (file)
     <record id="basic_calendar_fields_24" model="basic.calendar.fields">
         <field name="name" ref="caldav.field_event_dtstamp"/>
         <field name="type_id" ref="basic_calendar_lines_vevent0"/>
-        <field name="field_id" ref="base_calendar.field_calendar_event_date"/>
-        <field name="fn">field</field>
+        <field name="field_id" ref="crm.field_crm_meeting_write_date"/>
+        <field name="fn">datetime_utc</field>
     </record>
     <record id="basic_calendar_fields_25" model="basic.calendar.fields">
         <field name="name" ref="caldav.field_event_description"/>
index ffb5634..52bd5f2 100644 (file)
@@ -60,12 +60,14 @@ class crm_claim_report(osv.osv):
                                   ('11', 'November'), ('12', 'December')], 'Month', readonly=True),
         'company_id': fields.many2one('res.company', 'Company', readonly=True),
         'create_date': fields.datetime('Create Date', readonly=True),
+        'email': fields.integer('# Emails', size=128, readonly=True),
         'day': fields.char('Day', size=128, readonly=True), 
         'delay_close': fields.float('Delay to close', digits=(16,2),readonly=True, group_operator="avg",help="Number of Days to close the case"),
         'stage_id': fields.many2one ('crm.case.stage', 'Stage', readonly=True, domain="[('type','=','claim')]"),
         'categ_id': fields.many2one('crm.case.categ', 'Category',\
                          domain="[('section_id','=',section_id),\
                         ('object_id.model', '=', 'crm.claim')]", readonly=True),
+        'probability': fields.float('Probability',digits=(16,2),readonly=True, group_operator="avg"),
         'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
         'company_id': fields.many2one('res.company', 'Company', readonly=True),
         'priority': fields.selection(AVAILABLE_PRIORITIES, 'Priority'),
@@ -101,6 +103,7 @@ class crm_claim_report(osv.osv):
                     count(*) as nbr,
                     c.priority as priority,
                     c.type_action as type_action,
+                    (SELECT count(id) FROM mailgate_message WHERE model='crm.claim' AND res_id=id AND history=True) AS email,
                     date_trunc('day',c.create_date) as create_date,
                     avg(extract('epoch' from (c.date_closed-c.create_date)))/(3600*24) as  delay_close,
                     extract('epoch' from (c.date_deadline - c.date_closed))/(3600*24) as  delay_expected
index ca1c03a..2dd4375 100644 (file)
@@ -18,6 +18,7 @@
                     <field name="partner_id" invisible="1"/>
                     <field name="day" invisible="1"/>
                     <field name="nbr" string="#Claim" sum="#Claim"/>
+                    <field name="email" sum="# Mails"/>
                     <field name="delay_close" avg="Avg Closing Delay"/>
                     <field name="delay_expected"/>
                     <field name="state" invisible="1"/>
index 7e575f3..5e6fb46 100644 (file)
@@ -35,6 +35,17 @@ DMS_ROOT_PATH = tools.config.get('document_path', os.path.join(tools.config['roo
 class document_file(osv.osv):
     _inherit = 'ir.attachment'
     _rec_name = 'datas_fname'
+
+    def attach_parent_id(self, cr, uid, ids=[], context=None):
+        """Attach Parent id For document"""
+        
+        parent_id = self.pool.get('document.directory')._get_root_directory(cr,uid)
+        ids = self.search(cr, uid, [('parent_id', '=', False)])
+        attach_doc = self.browse(cr, uid, ids, context=context)
+        for attach in attach_doc:
+            cr.execute("UPDATE ir_attachment SET parent_id = %s,db_datas = decode(encode(%s,'escape'), 'base64') WHERE id = %s", (parent_id, attach.db_datas, attach.id))
+        return True
+        
     def _get_filestore(self, cr):
         return os.path.join(DMS_ROOT_PATH, cr.dbname)
 
@@ -42,7 +53,8 @@ class document_file(osv.osv):
         if context is None:
             context = {}
         fbrl = self.browse(cr, uid, ids, context=context)
-        nctx = nodes.get_node_context(cr, uid, context={})
+        
+        nctx = nodes.get_node_context(cr, uid, context=context)
         # nctx will /not/ inherit the caller's context. Most of
         # it would be useless, anyway (like active_id, active_model,
         # bin_size etc.)
@@ -55,9 +67,7 @@ class document_file(osv.osv):
                     result[fbro.id] = base64.encodestring(data or '')
             else:
                     result[fbro.id] = fnode.get_data_len(cr, fbro)
-
         return result
-
     #
     # This code can be improved
     #
@@ -168,7 +178,7 @@ class document_file(osv.osv):
             ids2 = []
             for fbro in self.browse(cr, uid, ids, context=context):
                 if ('parent_id' not in vals or fbro.parent_id.id == vals['parent_id']) \
-                    and ('name' not in vals or fbro.name == vals['name']) :
+                    and ('name' not in vals or fbro.name == vals['name']) or not fbro.parent_id:
                         ids2.append(fbro.id)
                         continue
                 fnode = nctx.get_file_node(cr, fbro)
index a4f546c..911e25b 100644 (file)
         <field name="user_id" eval="False"/>
         <field name="parent_id" ref="dir_root"/>
         <field name="ressource_id">0</field>
-
     </record>
-
+       
+    <function model="ir.attachment" name="attach_parent_id"/>   
+   
+       
 </data>
 </openerp>
index 1b7aebc..5222c0e 100644 (file)
@@ -525,6 +525,9 @@ class node_dir(node_database):
         # TODO: the write date should be MAX(file.write)..
         self.write_date = dirr and (dirr.write_date or dirr.create_date) or False
         self.content_length = 0
+
+        self.unixperms = 040750
+
         try:
             self.uuser = (dirr.user_id and dirr.user_id.login) or 'nobody'
         except Exception:
@@ -764,6 +767,7 @@ class node_res_dir(node_class):
         # TODO: the write date should be MAX(file.write)..
         self.write_date = dirr.write_date or dirr.create_date
         self.content_length = 0
+        self.unixperms = 040750
         try:
             self.uuser = (dirr.user_id and dirr.user_id.login) or 'nobody'
         except Exception:
@@ -1556,4 +1560,4 @@ class nodefd_static(StringIO, node_descriptor):
             cr.close()
         StringIO.close(self)
 
-#eof
\ No newline at end of file
+#eof
index 7cfcd36..ca5b02e 100644 (file)
@@ -96,12 +96,7 @@ class DocIndex(indexer):
 
     def _doIndexFile(self,fname):
         fp = Popen(['antiword', fname], shell=False, stdout=PIPE).stdout
-        try:
-            file_data = _to_unicode(fp.read())
-        finally:
-            fp.close()
-            
-        return file_data
+        return _to_unicode(fp.read())
     
 cntIndex.register(DocIndex())
 
@@ -163,12 +158,7 @@ class PdfIndex(indexer):
 
     def _doIndexFile(self,fname):
         fp = Popen(['pdftotext', '-enc', 'UTF-8', '-nopgbrk', fname, '-'], shell=False, stdout=PIPE).stdout
-        try:
-           file_data = _to_unicode( fp.read())
-        finally:
-            fp.close()
-                 
-        return file_data
+        return _to_unicode( fp.read())
 
 cntIndex.register(PdfIndex())
 
index 17dc99d..0ae133b 100644 (file)
@@ -44,6 +44,7 @@ class document_ftp_configuration(osv.osv_memory):
         # Update the action for FTP browse.
         aid = data_pool._get_id(cr, uid, 'document_ftp', 'action_document_browse')
         aid = data_pool.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')+'/'})
+        self.pool.get('ir.actions.url').write(cr, uid, [aid], 
+                {'url': 'ftp://'+(conf.host or 'localhost:8021')+'/' + cr.dbname+'/'})
 
 document_ftp_configuration()
index 5b0b418..82268ef 100644 (file)
@@ -92,14 +92,13 @@ class DAVHandler(HttpOptions, FixSendError, DAVRequestHandler):
     def setup(self):
         self.davpath = '/'+config.get_misc('webdav','vdir','webdav')
         addr, port = self.server.server_name, self.server.server_port
-        server_proto = getattr(self.server,'proto', 'http').lower()
         try:
-            if hasattr(self.request, 'getsockname'):
-                addr, port = self.request.getsockname()
+            addr, port = self.request.getsockname()
         except Exception, e:
-            self.log_error("Cannot calculate own address: %s" , e)
-        # Too early here to use self.headers
-        self.baseuri = "%s://%s:%d/"% (server_proto, addr, port)
+
+            self.log_error("Cannot calculate own address:" , e)
+        self.baseuri = "http://%s:%d/"% (addr, port)
+
         self.IFACE_CLASS  = openerp_dav_handler(self, self.verbose)
 
     def copymove(self, CLASS):