[IMP]Made changes as per the review of RPA on 19th march
authorDharti Ratani (Open ERP) <dhr@tinyerp.com>
Wed, 20 Mar 2013 05:39:10 +0000 (11:09 +0530)
committerDharti Ratani (Open ERP) <dhr@tinyerp.com>
Wed, 20 Mar 2013 05:39:10 +0000 (11:09 +0530)
bzr revid: dhr@tinyerp.com-20130320053910-ywjxwwqvxjgrygia

addons/google_docs/google_docs.py
addons/google_docs/google_docs_demo.xml
addons/google_docs/res_config_user_view.xml

index 020e78a..2eabcb1 100644 (file)
@@ -172,7 +172,8 @@ class google_docs_ir_attachment(osv.osv):
         """ filter the list record_ids that satisfy the action filter """
         records = {}
         if record_ids and action_filter:
-            assert action.model_id.model == action_filter.model_id, "Filter model different from action rule model"
+            if not action.model_id.model == action_filter.model_id:
+                raise osv.except_osv(_('Warning!'), _("Something went wrong with the configuration of attachments with google drive.Please contact your Administrator to fix the problem."))
             model = self.pool.get(action_filter.model_id)
             domain = [('id', 'in', [record_ids])] + eval(action_filter.domain)
             ctx = dict(context or {})
@@ -183,7 +184,7 @@ class google_docs_ir_attachment(osv.osv):
     def get_attachment(self, cr, uid, res_model, rec_name, ids, context=None):
         res_id = ids[0]
         pool_gdoc_config = self.pool.get('google.docs.config')
-        config_ids = pool_gdoc_config.search(cr, uid, [('model_id', '=', res_model)], context=context)[0]
+        config_ids = pool_gdoc_config.search(cr, uid, [('model_id', '=', res_model),('name','=',rec_name['label'])], context=context)[0]
         action = pool_gdoc_config.browse(cr, uid, config_ids, context=context)
         attachment = {}
         model_fields_dic = self.pool.get(res_model).read(cr, uid, res_id, [], context=context)
@@ -219,15 +220,18 @@ class config(osv.osv):
         result = {}
         for data in self.browse(cr, uid, ids, context):
             template_url = data.gdocs_template_url
-            url = urlparse(template_url)
-            res = url.path.split('/')
-            resource = res[1]
-            if res[1]== "spreadsheet":
-                key = url.query.split('=')[1]
-            else:
-                key = res[3]
-            res_id = resource + ":" + key
-            result[data.id] = str(res_id)
+            try:
+                url = urlparse(template_url)
+                res = url.path.split('/')
+                resource = res[1]
+                if res[1]== "spreadsheet":
+                    key = url.query.split('=')[1]
+                else:
+                    key = res[3]
+                res_id = resource + ":" + key
+                result[data.id] = str(res_id)
+            except:
+                raise osv.except_osv(_('Incorrect URL!'), _("Please enter a valid URL."))
         return result
 
     _columns = {
@@ -239,7 +243,8 @@ class config(osv.osv):
         'name_template': fields.char('Google Drive Name Pattern', size=64, help='Choose how the new google drive will be named, on google side. Eg. gdoc_%(field_name)s', required=True),
     }
 
-    def onchange_model_id(self, cr, uid, ids, model_id):
+    def onchange_model_id(self, cr, uid, ids, model_id,filter_id):
+         print 'fffffffff',filter_id
          res = {'domain':{'filter_id':[]}}
          if model_id:
              model_name = self.pool.get('ir.model').read(cr, uid, model_id, ['model'])
@@ -248,6 +253,7 @@ class config(osv.osv):
                  res['domain'] = {'filter_id': [('model_id', '=', mod_name)]}
          else:
              res['value'] = {'filter_id': False}
+         print 'rrrrrrr',res
          return res
 
     _defaults = {
index a5288dc..4f63aa0 100644 (file)
@@ -16,7 +16,7 @@
           <field name="model_id" ref="crm.model_crm_lead"/>
           <field name="filter_id" ref="filter_crm"/>
           <field name="gdocs_template_url">https://docs.google.com/spreadsheet/ccc?key=0Ah2qnrLAoZmUdGRvdVdmS1VoSDctWk1kd18taGZ4ckE#gid=0</field>
-          <field name="name_template">lead_sales-department_%%(name)s_review</field>
+          <field name="name_template">lead_sales-department_%(name)s_review</field>
       </record>
       
     </data>
index 0350e6b..c801f83 100644 (file)
             <field name='view_id' ref='view_google_docs_config_tree'/>
             <field name="help" type="html">
               <p>
-               "Link your first Google document to openERP documents
-                You use to control the quality of your product in a spreadheet ?
-                You review the delivery checklist for each delivery order in a  foreign country ? ...
-                Link your own templates on any documents of OpenERP
+                Link your first Google document to OpenERP documents.
+                You can use it to control the quality of your product in a spreadsheet or
+                review the delivery checklist for each delivery order in a foreign country
+                and in many more ways. Link your own templates on any documents of OpenERP.
               </p>
             </field>
         </record>