[IMP] project: improved code.
bzr revid: tpa@tinyerp.com-20120704093343-3q7a6flz5qbrsza1
This commit is contained in:
@@ -165,7 +165,7 @@ class project(osv.osv):
|
||||
res[task.project_id.id] += 1
|
||||
return res
|
||||
def _get_alias_model(self, cr, uid, context=None):
|
||||
return [('model_project_task', "Tasks")]
|
||||
return [('project.task', "Tasks")]
|
||||
|
||||
def _get_followers(self, cr, uid, ids, name, arg, context=None):
|
||||
'''
|
||||
@@ -239,7 +239,7 @@ class project(osv.osv):
|
||||
'priority': 1,
|
||||
'sequence': 10,
|
||||
'type_ids': _get_type_common,
|
||||
'alias_model':'model_project_task',
|
||||
'alias_model':'project.task',
|
||||
}
|
||||
|
||||
# TODO: Why not using a SQL contraints ?
|
||||
@@ -523,7 +523,7 @@ def Project():
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
alias_pool = self.pool.get('mail.alias')
|
||||
if not vals.get('alias_id'):
|
||||
alias_id = alias_pool.create_unique_alias(cr, uid, {'alias_name': "project."+vals['name'], 'alias_model_id': self._name}, context=context)
|
||||
alias_id = alias_pool.create_unique_alias(cr, uid, {'alias_name': "project."+vals['name'], 'alias_model_id': vals.get('alias_model','project.task')}, context=context)
|
||||
vals.update({'alias_id': alias_id})
|
||||
res = super( project, self).create(cr, uid, vals, context)
|
||||
record = self.read(cr, uid, res, context)
|
||||
@@ -551,16 +551,15 @@ def Project():
|
||||
return self.message_append_note(cr, uid, ids, body=message, context=context)
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
model_pool = self.pool.get('ir.model.data')
|
||||
model_pool = self.pool.get('ir.model')
|
||||
alias_pool = self.pool.get('mail.alias')
|
||||
# if alias_model have been changed then change alias_model_id of alias also.
|
||||
if vals.get('alias_model'):
|
||||
model, res_id = model_pool.get_object_reference( cr, uid, "project", vals.get('alias_model','model_project_task'))
|
||||
model_ids = model_pool.search(cr, uid, [('model', '=', vals.get('alias_model','project.task'))])
|
||||
alias_id = self.browse(cr, uid, ids[0], context).alias_id
|
||||
alias_pool.write(cr, uid, [alias_id.id], {'alias_model_id': res_id}, context=context)
|
||||
alias_pool.write(cr, uid, [alias_id.id], {'alias_model_id': model_ids[0]}, context=context)
|
||||
return super(project, self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
|
||||
class task(base_stage, osv.osv):
|
||||
_name = "project.task"
|
||||
_description = "Task"
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
ref('base.user_vad')])]" name="members"/>
|
||||
<field name="user_id" ref="base.user_al"/>
|
||||
<field name="name">Integrate a Sale and Warehouse Management.</field>
|
||||
<field name="alias_model">model_project_task</field>
|
||||
<field name="alias_model">project.task</field>
|
||||
</record>
|
||||
|
||||
<!-- Tasks -->
|
||||
@@ -291,7 +291,7 @@
|
||||
<field name="parent_id" ref="all_projects_account"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="[(6, 0, [ref('project_tt_specification'),ref('project_tt_development'),ref('project_tt_testing'),ref('project_tt_merge')])]" name="type_ids"/>
|
||||
<field name="alias_model">model_project_task</field>
|
||||
<field name="alias_model">project.task</field>
|
||||
</record>
|
||||
<record id="project_project_21" model="project.project">
|
||||
<field name="priority">10</field>
|
||||
@@ -300,7 +300,7 @@
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="[(6, 0, [ref('project_tt_specification'),ref('project_tt_development')])]" name="type_ids"/>
|
||||
<field eval="[(6, 0, [ref('base.user_root'),ref('base.user_demo')])]" name="members"/>
|
||||
<field name="alias_model">model_project_task</field>
|
||||
<field name="alias_model">project.task</field>
|
||||
</record>
|
||||
<record id="project_project_22" model="project.project">
|
||||
<field name="priority">20</field>
|
||||
@@ -309,7 +309,7 @@
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="[(6, 0, [ref('project_tt_specification'), ref('project_tt_development')])]" name="type_ids"/>
|
||||
<field eval="[(6, 0, [ref('base.user_root'),ref('base.user_demo')])]" name="members"/>
|
||||
<field name="alias_model">model_project_task</field>
|
||||
<field name="alias_model">project.task</field>
|
||||
</record>
|
||||
<record id="project_project_23" model="project.project">
|
||||
<field name="priority">30</field>
|
||||
@@ -317,7 +317,7 @@
|
||||
<field name="name">Install, data import, configuration</field>
|
||||
<field eval="[(6, 0, [ref('project_tt_development')])]" name="type_ids"/>
|
||||
<field eval="[(6, 0, [ref('base.user_root'),ref('base.user_demo')])]" name="members"/>
|
||||
<field name="alias_model">model_project_task</field>
|
||||
<field name="alias_model">project.task</field>
|
||||
</record>
|
||||
|
||||
<!-- Tasks -->
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
<field name="parent_id" invisible="1" string="Parent" domain="[('id','!=',analytic_account_id)]" context="{'current_model': 'project.project'}"/>
|
||||
<field name="privacy_visibility"/>
|
||||
<field name="alias_id" required="0" domain="[('alias_model_id','in',('project.task','project.issue'))]"/>
|
||||
<field name="alias_model"/>
|
||||
<field name="alias_model" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<table>
|
||||
|
||||
@@ -582,7 +582,7 @@ class project(osv.osv):
|
||||
_inherit = "project.project"
|
||||
|
||||
def _get_alias_model(self, cr, uid, context=None):
|
||||
return [('model_project_task', "Tasks"),("model_project_issue", "Issue")]
|
||||
return [('project.task', "Tasks"),("project.issue", "Issue")]
|
||||
|
||||
def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = dict.fromkeys(ids, 0)
|
||||
@@ -608,6 +608,7 @@ class project(osv.osv):
|
||||
_constraints = [
|
||||
(_check_escalation, 'Error! You cannot assign escalation to the same project!', ['project_escalation_id'])
|
||||
]
|
||||
|
||||
project()
|
||||
|
||||
class account_analytic_account(osv.osv):
|
||||
|
||||
@@ -352,6 +352,9 @@
|
||||
<field name="project_escalation_id"/>
|
||||
<field name="reply_to"/>
|
||||
</field>
|
||||
<field name="alias_model" position="replace">
|
||||
<field name="alias_model"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user