[IMP] Project: Clean code and improvements on project related modules
bzr revid: mra@mra-laptop-20100810103259-a12ooa602rpzw9nd
This commit is contained in:
parent
1b74bafee6
commit
2dc0a4c5f1
|
@ -42,7 +42,6 @@ work done on tasks, eso. It is able to render planning, order tasks, eso.
|
|||
"security/ir.model.access.csv",
|
||||
"project_data.xml",
|
||||
"project_view.xml",
|
||||
"project_report.xml",
|
||||
"process/task_process.xml",
|
||||
"project_installer.xml",
|
||||
"res_partner_view.xml",
|
||||
|
|
|
@ -76,11 +76,11 @@ class project(osv.osv):
|
|||
|
||||
def get_all_child_projects(self, cr, uid, ids, context=None):
|
||||
# Calculate child project for Given project id => For progress rate + planned time + Time spent
|
||||
cr.execute('''select prpc.id as id from account_analytic_account as p
|
||||
join account_analytic_account as c on p.id = c.parent_id
|
||||
join project_project as prp on prp.analytic_account_id = p.id
|
||||
join project_project as prpc on prpc.analytic_account_id = c.id
|
||||
where prp.id in %s''',(tuple(ids),))
|
||||
cr.execute('''SELECT prpc.id AS id from account_analytic_account AS p
|
||||
JOIN account_analytic_account AS c ON p.id = c.parent_id
|
||||
JOIN project_project AS prp ON prp.analytic_account_id = p.id
|
||||
JOIN project_project AS prpc ON prpc.analytic_account_id = c.id
|
||||
WHERE prp.id IN %s''',(tuple(ids),))
|
||||
|
||||
child_ids = cr.fetchall()
|
||||
if child_ids:
|
||||
|
@ -247,21 +247,6 @@ class project(osv.osv):
|
|||
default['name'] = proj.name+_(' (copy)')
|
||||
res = super(project, self).copy(cr, uid, id, default, context)
|
||||
|
||||
# task_ids = task_obj.search(cr, uid, [('project_id','=', res), ('active','=',True)])
|
||||
# tasks = task_obj.browse(cr, uid, task_ids)
|
||||
# for task in tasks:
|
||||
# date_deadline = None
|
||||
# if task.date_start:
|
||||
# ds = date(*time.strptime(task.date_start,'%Y-%m-%d %H:%M:%S')[:3])
|
||||
# if task.date_deadline:
|
||||
# dd = date(*time.strptime(task.date_deadline,'%Y-%m-%d')[:3])
|
||||
# diff = dd-ds
|
||||
# date_deadline = (datetime.now()+diff).strftime('%Y-%m-%d %H:%M:%S')
|
||||
# task_obj.write(cr, uid, task.id, {'date_start': False,
|
||||
# 'date_end': False,
|
||||
# 'date_deadline':date_deadline,
|
||||
# })
|
||||
|
||||
return res
|
||||
|
||||
def duplicate_template(self, cr, uid, ids, context=None):
|
||||
|
@ -386,8 +371,9 @@ class task(osv.osv):
|
|||
|
||||
def copy_data(self, cr, uid, id, default={}, context=None):
|
||||
default = default or {}
|
||||
default['work_ids'] = []
|
||||
default['remaining_hours'] = float(self.read(cr, uid, id, ['planned_hours'])['planned_hours'])
|
||||
default.update({'work_ids':[], 'date_start': False, 'date_end': False, 'date_deadline': False})
|
||||
if not default.get('remaining_hours', False):
|
||||
default['remaining_hours'] = float(self.read(cr, uid, id, ['planned_hours'])['planned_hours'])
|
||||
default['active'] = True
|
||||
return super(task, self).copy_data(cr, uid, id, default, context)
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -639,7 +639,7 @@ Issues like bugs in a system, client complain, materials breakdown are collected
|
|||
</record>
|
||||
|
||||
<record id="action_view_project_messages_tree" model="ir.actions.act_window">
|
||||
<field name="name">Messages</field>
|
||||
<field name="name">Project Messages</field>
|
||||
<field name="res_model">project.message</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
|
|
|
@ -55,7 +55,7 @@ class report_project_task_user(osv.osv):
|
|||
'state': fields.selection([('draft', 'Draft'), ('open', 'In Progress'), ('pending', 'Pending'), ('cancelled', 'Cancelled'), ('done', 'Done')],'State', readonly=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', readonly=True, groups="base.group_multi_company"),
|
||||
'partner_id': fields.many2one('res.partner', 'Partner', readonly=True),
|
||||
'type': fields.many2one('project.task.type', 'Stage', readonly=True),
|
||||
'type_id': fields.many2one('project.task.type', 'Stage', readonly=True),
|
||||
}
|
||||
_order = 'name desc, project_id'
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<field name="date_end" invisible="1"/>
|
||||
<field name="company_id" invisible="1" groups="base.group_multi_company"/>
|
||||
<field name="partner_id" invisible="1"/>
|
||||
<field name="type" invisible="1"/>
|
||||
<field name="type_id" invisible="1"/>
|
||||
<field name="day" invisible="1"/>
|
||||
<field name="month" invisible="1"/>
|
||||
<field name="year" invisible="1"/>
|
||||
|
@ -116,7 +116,7 @@
|
|||
<separator orientation="vertical"/>
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
|
||||
<filter string="Company" icon="terp-go-home" context="{'group_by':'company_id'}" groups="base.group_multi_company"/>
|
||||
<filter string="Stage" icon="terp-stage" context="{'group_by':'type'}" />
|
||||
<filter string="Stage" icon="terp-stage" context="{'group_by':'type_id'}" />
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Day" icon="terp-go-today" context="{'group_by':'day'}"/>
|
||||
<filter string="Month" icon="terp-go-month" context="{'group_by':'month'}"/>
|
||||
|
@ -124,7 +124,7 @@
|
|||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended Filters..." colspan="10" col="12" groups="base.group_extended">
|
||||
<field name="type" widget="selection"/>
|
||||
<field name="type_id" widget="selection"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="date_start"/>
|
||||
<field name="date_deadline"/>
|
||||
|
|
|
@ -90,7 +90,7 @@ class project_close_task(osv.osv_memory):
|
|||
|
||||
if 'task_id' in context:
|
||||
if context.get('send_manager', False) and not close_task.get('manager_email', False):
|
||||
raise osv.except_osv(_('Error'), _("Please specify the email address of Manager."))
|
||||
raise osv.except_osv(_('Error'), _("Please specify the email address of Project Manager."))
|
||||
|
||||
elif context.get('send_partner', False) and not close_task.get('partner_email', False):
|
||||
raise osv.except_osv(_('Error'), _("Please specify the email address of partner."))
|
||||
|
|
|
@ -43,7 +43,7 @@ class project_task_delegate(osv.osv_memory):
|
|||
if 'active_id' in context:
|
||||
task = self.pool.get('project.task').browse(cr, uid, context['active_id'])
|
||||
if task.name.startswith(_('CHECK: ')):
|
||||
newname = task.name.strip(_('CHECK: '))
|
||||
newname = str(task.name).replace(_('CHECK: '), '')
|
||||
else:
|
||||
newname = task.name or ''
|
||||
return newname
|
||||
|
@ -63,10 +63,10 @@ class project_task_delegate(osv.osv_memory):
|
|||
if 'active_id' in context:
|
||||
task = self.pool.get('project.task').browse(cr, uid, context['active_id'])
|
||||
if task.name.startswith(_('CHECK: ')):
|
||||
newname = task.name.strip(_('CHECK: '))
|
||||
newname = str(task.name).replace(_('CHECK: '), '')
|
||||
else:
|
||||
newname = task.name or ''
|
||||
return _('CHECK: ')+ newname
|
||||
return _('CHECK: ') + newname
|
||||
return ''
|
||||
|
||||
def _get_new_desc(self, cr, uid, context=None):
|
||||
|
@ -129,7 +129,7 @@ class project_task_delegate(osv.osv_memory):
|
|||
'planned_hours': delegate_data['planned_hours'],
|
||||
'remaining_hours': delegate_data['planned_hours'],
|
||||
'parent_ids': [(6, 0, [task.id])],
|
||||
'state': 'open',
|
||||
'state': 'draft',
|
||||
'description': delegate_data['new_task_description'] or '',
|
||||
'child_ids': [],
|
||||
'work_ids': []
|
||||
|
|
|
@ -127,13 +127,14 @@
|
|||
<field name="name"/>
|
||||
<field name="user_id"/>
|
||||
<field name="planned_hours" widget="float_time"/>
|
||||
<field name="project_id" invisible="1"/>
|
||||
</tree>
|
||||
<form string="Project's Tasks">
|
||||
<notebook colspan="4">
|
||||
<page string="Task Detail">
|
||||
<group colspan="4" col="4">
|
||||
<field name="name"/>
|
||||
<field name="project_id" required="1"/>
|
||||
<field name="project_id"/>
|
||||
<field name="user_id"/>
|
||||
</group>
|
||||
<group colspan="2" col="2">
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
""",
|
||||
'website': 'http://www.openerp.com',
|
||||
'init_xml': [],
|
||||
'update_xml': [],
|
||||
'update_xml': ['project_messages_view.xml'],
|
||||
'demo_xml': [],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
|
|
|
@ -30,44 +30,35 @@ class messages(osv.osv):
|
|||
logger = netsvc.Logger()
|
||||
|
||||
_columns = {
|
||||
'from_id': fields.many2one('res.users', 'From', ondelete="CASCADE"),
|
||||
'to_id': fields.many2one('res.users', 'To', ondelete="CASCADE"),
|
||||
'from_id': fields.many2one('res.users', 'From', required=True, ondelete="CASCADE"),
|
||||
'to_id': fields.many2one('res.users', 'To', ondelete="CASCADE", help="Keep this empty to broadcast the message."),
|
||||
'project_id': fields.many2one('project.project', 'Project',
|
||||
required=True, ondelete="CASCADE"),
|
||||
'message': fields.text('Message', required=True),
|
||||
}
|
||||
|
||||
def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False):
|
||||
# return messages by current user, for current user or for all users
|
||||
# return all messages if current user is administrator
|
||||
if uid != 1:
|
||||
args.extend(['|',('from_id', 'in', [uid,]),('to_id', 'in', [uid, False])])
|
||||
return super(messages, self).search(cr, uid, args, offset, limit,
|
||||
order, context=context, count=count)
|
||||
|
||||
_defaults = {
|
||||
'from_id': lambda self, cr, uid, context: uid,
|
||||
'to_id': None,
|
||||
}
|
||||
|
||||
def broadcast(self, cr, uid, project_id, message, context=None):
|
||||
""" Send a message to all the users of a project.
|
||||
The sender of the message is the current user.
|
||||
|
||||
The method returns the new message's id.
|
||||
|
||||
Arguments:
|
||||
- `project_id`: the id of the project to broadcast to
|
||||
- `message`: the message to broadcast
|
||||
"""
|
||||
return self.create(cr, uid, {
|
||||
'to_id':None,
|
||||
'project_id':project_id,
|
||||
'message':message
|
||||
}, context=context)
|
||||
|
||||
messages()
|
||||
|
||||
class project_with_message(osv.osv):
|
||||
_inherit = 'project.project'
|
||||
|
||||
|
||||
_columns = {
|
||||
'message_ids':fields.one2many(
|
||||
'project.messages', 'project_id', 'Messages',
|
||||
domain="[('to_id','in',[uid,False])]"),
|
||||
),
|
||||
}
|
||||
|
||||
project_with_message()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_phase_project_form1" model="ir.ui.view">
|
||||
<field name="name">phase.project.form1</field>
|
||||
<field name="model">project.project</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit_id" ref="project.edit_project"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@string='Tasks Stages']" position="after">
|
||||
<page string="Messages" groups="base.group_extended">
|
||||
<field name="message_ids" nolabel="1" colspan="4">
|
||||
<tree editable="1">
|
||||
<field name="message" attrs="{'readonly':[('from_id', '!=', uid)]}"/>
|
||||
<field name="from_id"/>
|
||||
<field name="to_id" attrs="{'readonly':[('from_id', '!=', uid)]}"/>
|
||||
</tree>
|
||||
<form>
|
||||
<group attrs="{'readonly':[('from_id', '!=', uid)]}">
|
||||
<field name="from_id"/>
|
||||
<field name="to_id"/>
|
||||
<newline/>
|
||||
<separator colspan="4" string="Message"/>
|
||||
<field nolabel="1" name="message" colspan="4"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_project_message_form" model="ir.ui.view">
|
||||
<field name="name">project.messages.form</field>
|
||||
<field name="model">project.messages</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Messages">
|
||||
<group attrs="{'readonly':[('from_id', '!=', uid)]}">
|
||||
<field name="project_id" select="1" domain="[('user_id','=',uid)]"/>
|
||||
<newline/>
|
||||
<field name="from_id" select="1"/>
|
||||
<field name="to_id" select="1"/>
|
||||
<newline/>
|
||||
<separator colspan="4" string="Message"/>
|
||||
<field name="message" colspan="4" nolabel="1"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_project_message_tree" model="ir.ui.view">
|
||||
<field name="name">project.messages.tree</field>
|
||||
<field name="model">project.messages</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Messages">
|
||||
<field name="project_id"/>
|
||||
<field name="from_id"/>
|
||||
<field name="to_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_project_messages_search" model="ir.ui.view">
|
||||
<field name="name">project.messages.search</field>
|
||||
<field name="model">project.messages</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Communication Messages">
|
||||
<group>
|
||||
<field name="project_id"/>
|
||||
<field name="from_id"/>
|
||||
<field name="to_id"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." colspan="4" col="20">
|
||||
<filter string="Project" icon="terp-folder-blue" domain="[]" context="{'group_by':'project_id'}"/>
|
||||
<filter string="Message To" icon="terp-personal" domain="[]" context="{'group_by':'to_id'}"/>
|
||||
<filter string="Message From" icon="terp-personal" domain="[]" context="{'group_by':'from_id'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="messages_form" model="ir.actions.act_window">
|
||||
<field name="name">Communication Messages</field>
|
||||
<field name="res_model">project.messages</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="search_view_id" ref="view_project_messages_search"/>
|
||||
<field name="context">{"search_default_to_id":uid}</field>
|
||||
<field name="view_id" ref="view_project_message_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem action="messages_form" id="menu_messages_form" parent="project.menu_project_management"/>
|
||||
</data>
|
||||
</openerp>
|
|
@ -86,7 +86,7 @@ class procurement_order(osv.osv):
|
|||
name_task = (procurement.origin, proc_name or '')
|
||||
else:
|
||||
name_task = (procurement.product_id.name or procurement.origin, procurement.name or '')
|
||||
planned_hours= procurement.product_id.sale_delay +procurement.product_id. produce_delay
|
||||
planned_hours= procurement.product_id.sale_delay + procurement.product_id. produce_delay
|
||||
task_id = self.pool.get('project.task').create(cr, uid, {
|
||||
'name': '%s:%s' % name_task,
|
||||
'date_deadline': procurement.date_planned,
|
||||
|
|
|
@ -51,7 +51,6 @@ At the end of the month, the planning manager can also check if the encoded time
|
|||
'board_project_planning_view.xml',
|
||||
],
|
||||
'demo_xml': [
|
||||
#'report_account_analytic.planning.csv',
|
||||
'project_planning_demo.xml',
|
||||
],
|
||||
'test': [
|
||||
|
|
|
@ -78,14 +78,14 @@
|
|||
</tree>
|
||||
<form string="Planning Lines">
|
||||
<field name="user_id" domain="[('id','child_of',[parent.user_id])]"/>
|
||||
<field name="account_id" />
|
||||
<field name="account_id"/>
|
||||
<field name="amount" />
|
||||
<field name="amount_unit" />
|
||||
<!-- WIDGET MANY2MANY GIVES ERROR-->
|
||||
<!-- <field name="task_ids" colspan="4" nolabel="1" widget="many2many"/>-->
|
||||
<field name="task_ids" colspan="4" nolabel="1" mode="tree,form">
|
||||
<form string="Tasks">
|
||||
<group colspan="4" col="2">
|
||||
<group colspan="4" col="2">
|
||||
<field name="name" select="1"/>
|
||||
<field name="project_id" required="1" select="1" domain="[('analytic_account_id','=',parent.account_id)]"/>
|
||||
</group>
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
name,line_ids/amount,line_ids/amount_unit,line_ids/user_id,line_ids/task,line_ids/account_id,user_id
|
||||
Planning 2007,5.0,Day,admin,1,Seagate P1,admin
|
||||
,7.0,Day,admin,0,Seagate P2,
|
||||
,2.0,Day,admin,1,Sednacom,
|
||||
,3.0,Day,admin,0,Administratif,
|
||||
,4.0,Day,admin,0,Commercial & Marketing,
|
||||
,6.0,Day,demo,1,Seagate P1,
|
||||
,7.0,Day,demo,1,Seagate P2,
|
||||
,1.0,Day,demo,0,CampToCamp,
|
||||
,7.0,Day,demo,0,Agrolait,
|
|
|
@ -209,6 +209,8 @@ class project_project(osv.osv):
|
|||
if context is None:
|
||||
context = {}
|
||||
result = []
|
||||
if ids and not isinstance(ids, list):
|
||||
ids = [ids]
|
||||
for project in self.browse(cr, user, ids, context):
|
||||
name = "[%s] %s" % (project.analytic_account_id and project.analytic_account_id.code or '?', project.name)
|
||||
result.append((project.id, name))
|
||||
|
|
|
@ -118,7 +118,7 @@ class report_timesheet_task_user(osv.osv):
|
|||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name',size=64),
|
||||
'name': fields.char('Date',size=64),
|
||||
'year': fields.char('Year',size=64,required=False, readonly=True),
|
||||
'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), ('05','May'), ('06','June'),
|
||||
('07','July'), ('08','August'), ('09','September'), ('10','October'), ('11','November'), ('12','December')],'Month',readonly=True),
|
||||
|
|
Loading…
Reference in New Issue