[IMP] proj: optionalize default alias generation
authorRandhir Mayatra <rma@odoo.com>
Thu, 17 Jul 2014 05:56:33 +0000 (11:26 +0530)
committerRichard Mathot <rim@openerp.com>
Thu, 24 Jul 2014 14:25:50 +0000 (16:25 +0200)
addons/project/project.py
addons/project/res_config.py
addons/project/res_config_view.xml

index 5beb80f..e9a92a1 100644 (file)
@@ -531,7 +531,11 @@ def Project():
 
         project_id = super(project, self).create(cr, uid, vals, context=create_context)
         project_rec = self.browse(cr, uid, project_id, context=context)
-        self.pool.get('mail.alias').write(cr, uid, [project_rec.alias_id.id], {'alias_parent_thread_id': project_id, 'alias_defaults': {'project_id': project_id}}, context)
+        ir_values = self.pool.get('ir.values').get_default( cr, uid, 'project.config.settings', 'generate_project_alias' )
+        values = { 'alias_parent_thread_id': project_id, 'alias_defaults': {'project_id': project_id}}
+        if ir_values:
+            values = dict(values, alias_name=vals['name'])
+        self.pool.get('mail.alias').write(cr, uid, [project_rec.alias_id.id], values, context=context)
         return project_id
 
     def write(self, cr, uid, ids, vals, context=None):
index 187ad03..b7bcda2 100644 (file)
@@ -58,6 +58,8 @@ class project_configuration(osv.osv_memory):
         'group_manage_delegation_task': fields.boolean("Allow task delegation",
             implied_group='project.group_delegate_task',
             help="Allows you to delegate tasks to other users."),
+        'generate_project_alias': fields.boolean("Automatically generate an email alias at the project creation",
+            help="Odoo will generate an email alias at the project creation from project name."),
     }
 
     def get_default_time_unit(self, cr, uid, fields, context=None):
@@ -74,4 +76,8 @@ class project_configuration(osv.osv_memory):
             return {'value': {'group_tasks_work_on_tasks': True}}
         return {}
 
+    def set_default_generate_project_alias(self, cr, uid, ids, context=None):
+        config_value = self.browse(cr, uid, ids, context=context).generate_project_alias
+        self.pool.get('ir.values').set_default(cr, uid, 'project.config.settings', 'generate_project_alias', config_value)
+
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 16dce54..7db447c 100644 (file)
                             </div>
                         </div>
                     </group>
+                    <group>
+                        <label for="id" string="Communication"/>
+                        <div>
+                            <div>
+                                <field name="generate_project_alias" class="oe_inline"/>
+                                <label for="generate_project_alias" />
+                            </div>
+                        </div>
+                    </group>
                     <separator string="Helpdesk &amp; Support"/>
                     <group>
                         <label for="id" string="Support"/>