diff options
Diffstat (limited to 'addons/project')
| -rw-r--r-- | addons/project/project.py | 53 | ||||
| -rw-r--r-- | addons/project/project_demo.xml | 6 | ||||
| -rw-r--r-- | addons/project/project_view.xml | 71 |
3 files changed, 66 insertions, 64 deletions
diff --git a/addons/project/project.py b/addons/project/project.py index 28e4bd6e5d2..cadc4d8afb8 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -182,10 +182,10 @@ class project(osv.osv): _('You cannot delete a project containing tasks. You can either delete all the project\'s tasks and then delete the project or simply deactivate the project.')) elif proj.alias_id: alias_ids.append(proj.alias_id.id) - res = super(project, self).unlink(cr, uid, ids, context=context) + res = super(project, self).unlink(cr, uid, ids, context=context) mail_alias.unlink(cr, uid, alias_ids, context=context) return res - + def _get_attached_docs(self, cr, uid, ids, field_name, arg, context): res = {} attachment = self.pool.get('ir.attachment') @@ -196,7 +196,7 @@ class project(osv.osv): task_attachments = attachment.search(cr, uid, [('res_model', '=', 'project.task'), ('res_id', 'in', task_ids)], context=context, count=True) res[id] = (project_attachments or 0) + (task_attachments or 0) return res - + def _task_count(self, cr, uid, ids, field_name, arg, context=None): if context is None: context = {} @@ -209,22 +209,21 @@ class project(osv.osv): return res def _get_alias_models(self, cr, uid, context=None): - """Overriden in project_issue to offer more options""" + """ Overriden in project_issue to offer more options """ return [('project.task', "Tasks")] def _get_visibility_selection(self, cr, uid, context=None): """ Overriden in portal_project to offer more options """ - return [('public', 'Public'), - ('employees', 'Employees Only'), - ('followers', 'Followers Only')] + return [('public', 'Public project'), + ('employees', 'Internal project: all employees can access'), + ('followers', 'Private project: followers Only')] def attachment_tree_view(self, cr, uid, ids, context): task_ids = self.pool.get('project.task').search(cr, uid, [('project_id', 'in', ids)]) domain = [ - '|', + '|', '&', ('res_model', '=', 'project.project'), ('res_id', 'in', ids), - '&', ('res_model', '=', 'project.task'), ('res_id', 'in', task_ids) - ] + '&', ('res_model', '=', 'project.task'), ('res_id', 'in', task_ids)] res_id = ids and ids[0] or False return { 'name': _('Attachments'), @@ -237,6 +236,7 @@ class project(osv.osv): 'limit': 80, 'context': "{'default_res_model': '%s','default_res_id': %d}" % (self._name, res_id) } + # Lambda indirection method to avoid passing a copy of the overridable method when declaring the field _alias_models = lambda self, *args, **kwargs: self._get_alias_models(*args, **kwargs) _visibility_selection = lambda self, *args, **kwargs: self._get_visibility_selection(*args, **kwargs) @@ -370,13 +370,11 @@ class project(osv.osv): default['state'] = 'open' default['line_ids'] = [] default['tasks'] = [] - default.pop('alias_name', None) - default.pop('alias_id', None) proj = self.browse(cr, uid, id, context=context) if not default.get('name', False): default.update(name=_("%s (copy)") % (proj.name)) res = super(project, self).copy(cr, uid, id, default, context) - self.map_tasks(cr,uid,id,res,context) + self.map_tasks(cr, uid, id, res, context=context) return res def duplicate_template(self, cr, uid, ids, context=None): @@ -527,7 +525,7 @@ def Project(): for project in projects: project_gantt = getattr(projects_gantt, 'Project_%d' % (project.id,)) for task in project.tasks: - if task.state in ('done','cancelled'): + if task.state in ('done', 'cancelled'): continue p = getattr(project_gantt, 'Task_%d' % (task.id,)) @@ -547,23 +545,18 @@ def Project(): # ------------------------------------------------ def create(self, cr, uid, vals, context=None): - if context is None: context = {} - # Prevent double project creation when 'use_tasks' is checked! - context = dict(context, project_creation_in_progress=True) - mail_alias = self.pool.get('mail.alias') - if not vals.get('alias_id') and vals.get('name', False): - alias_name = vals.pop('alias_name', None) # prevent errors during copy() - alias_id = mail_alias.create_unique_alias(cr, uid, - # Using '+' allows using subaddressing for those who don't - # have a catchall domain setup. - {'alias_name': alias_name or "project+"+short_name(vals['name'])}, - model_name=vals.get('alias_model', 'project.task'), - context=context) - vals['alias_id'] = alias_id - if vals.get('type', False) not in ('template','contract'): + if context is None: + context = {} + # Prevent double project creation when 'use_tasks' is checked + alias management + create_context = dict(context, project_creation_in_progress=True, + alias_model_name=vals.get('alias_model', 'project.task'), alias_parent_model_name=self._name) + + if vals.get('type', False) not in ('template', 'contract'): vals['type'] = 'contract' - project_id = super(project, self).create(cr, uid, vals, context) - mail_alias.write(cr, uid, [vals['alias_id']], {'alias_defaults': {'project_id': project_id} }, context) + + 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) return project_id def write(self, cr, uid, ids, vals, context=None): diff --git a/addons/project/project_demo.xml b/addons/project/project_demo.xml index b7dcc2bdb83..b7e1524c2c8 100644 --- a/addons/project/project_demo.xml +++ b/addons/project/project_demo.xml @@ -46,9 +46,12 @@ <record id="project_project_2" model="project.project"> <field name="name">Research & Development</field> <field name="parent_id" ref="all_projects_account"/> - <field name="privacy_visibility">public</field> + <field name="privacy_visibility">followers</field> <field name="user_id" ref="base.user_demo"/> <field name="alias_model">project.task</field> + <field name="message_follower_ids" eval="[(6, 0, [ + ref('base.user_root'), + ref('base.user_demo')])]"/> </record> <!-- We assign after so that default values applies --> @@ -75,6 +78,7 @@ <field name="parent_id" ref="all_projects_account"/> <field name="name">Website Design Templates</field> <field name="user_id" ref="base.user_root"/> + <field name="privacy_visibility">followers</field> <field name="alias_model">project.task</field> <field name="privacy_visibility">employees</field> <field name="members" eval="[(4, ref('base.user_root')), (4,ref('base.user_demo'))]"/> diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index f6765b3462b..33842a9a19c 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -90,17 +90,6 @@ <h1> <field name="name" string="Project Name"/> </h1> - <div name="group_alias" - attrs="{'invisible': [('alias_domain', '=', False)]}"> - <label for="alias_id" string="Email Alias"/> - <field name="alias_id" class="oe_inline oe_read_only" required="0" nolabel="1"/> - <span name="edit_alias" class="oe_edit_only"> - <field name="alias_name" class="oe_inline" - attrs="{'required': [('alias_id', '!=', False)]}"/> - @ - <field name="alias_domain" class="oe_inline" readonly="1"/> - </span> - </div> <div name="options_active"> <field name="use_tasks" class="oe_inline"/> <label for="use_tasks"/> @@ -113,17 +102,31 @@ </div> <group> <group> - <field name="privacy_visibility"/> <field name="user_id" string="Project Manager" - attrs="{'readonly':[('state','in',['close', 'cancelled'])]}" - context="{'default_groups_ref': ['base.group_user', 'project.group_project_manager']}"/> - </group> - <group> + attrs="{'readonly':[('state','in',['close', 'cancelled'])]}" + context="{'default_groups_ref': ['base.group_user', 'project.group_project_manager']}"/> <field name="partner_id" on_change="onchange_partner_id(partner_id)"/> - <p colspan="2" attrs="{'invisible': [('analytic_account_id','=',False)]}"> - To invoice or setup invoicing and renewal options, go to the related contract: <field name="analytic_account_id" readonly="1" required="0" class="oe_inline"/>. + <span></span> + <p attrs="{'invisible': [('analytic_account_id','=',False)]}"> + To invoice or setup invoicing and renewal options, go to the related contract: + <field name="analytic_account_id" readonly="1" required="0" class="oe_inline" nolabel="1"/>. </p> </group> + <group name="group_alias" + attrs="{'invisible': [('alias_domain', '=', False)]}"> + <label for="alias_name" string="Email Alias"/> + <div name="alias_def"> + <field name="alias_id" class="oe_read_only oe_inline" + string="Email Alias" required="0"/> + <div class="oe_edit_only oe_inline" name="edit_alias" style="display: inline;" > + <field name="alias_name" class="oe_inline"/>@<field name="alias_domain" class="oe_inline" readonly="1"/> + </div> + </div> + <label for="alias_model" string="Incoming Emails create"/> + <field name="alias_model" class="oe_inline" nolabel="1"/> + <field name="alias_contact" class="oe_inline" + string="Accept Emails From"/> + </group> </group> <notebook> <page string="Team" name="team"> @@ -146,20 +149,22 @@ </field> </page> <page string="Other Info"> - <group> - <group string="Administration" groups="project.group_time_work_estimation_tasks"> - <field name="planned_hours" widget="float_time"/> - <field name="effective_hours" widget="float_time"/> - <field name="resource_calendar_id"/> - </group> - <group string="Miscellaneous" name="misc"> - <field name="date_start"/> - <field name="date" string="End Date"/> - <field name="priority" groups="base.group_no_one"/> - <field name="active" attrs="{'invisible':[('state','in',['open', 'pending', 'template'])]}"/> - <field name="currency_id" groups="base.group_multi_currency" required="1"/> - <field name="parent_id" string="Parent" help="Append this project to another one using analytic accounts hierarchy" domain="[('id','!=',analytic_account_id)]" context="{'current_model': 'project.project'}" /> - </group> + <group string="Administration"> + <field name="privacy_visibility" widget="radio"/> + <field name="planned_hours" widget="float_time" + groups="project.group_time_work_estimation_tasks"/> + <field name="effective_hours" widget="float_time" + groups="project.group_time_work_estimation_tasks"/> + <field name="resource_calendar_id" + groups="project.group_time_work_estimation_tasks"/> + </group> + <group string="Miscellaneous" name="misc"> + <field name="date_start"/> + <field name="date" string="End Date"/> + <field name="priority" groups="base.group_no_one"/> + <field name="active" attrs="{'invisible':[('state','in',['open', 'pending', 'template'])]}"/> + <field name="currency_id" groups="base.group_multi_currency" required="1"/> + <field name="parent_id" string="Parent" help="Append this project to another one using analytic accounts hierarchy" domain="[('id','!=',analytic_account_id)]" context="{'current_model': 'project.project'}" /> </group> </page> <page string="Project Stages" attrs="{'invisible': [('use_tasks', '=', False)]}" name="project_stages"> @@ -253,7 +258,7 @@ <div class="oe_kanban_content"> <h4><field name="name"/></h4> <div class="oe_kanban_alias" t-if="record.alias_id.value"> - <span class="oe_e">%%</span><small><field name="alias_id"/></small> + <span class="oe_e oe_e_alias">%%</span><small><field name="alias_id"/></small> </div> <div class="oe_kanban_project_list"> <a t-if="record.use_tasks.raw_value" name="%(act_project_project_2_project_task_all)d" type="action" style="margin-right: 10px"> |
