[IMP]rename all fields which r required in project and another module and improve code and

bzr revid: sgo@tinyerp.com-20120507072049-u00lsqra9x34nf73
This commit is contained in:
Sanjay Gohel (Open ERP) 2012-05-07 12:50:49 +05:30
parent c43e5dfe7e
commit bfd96de42b
11 changed files with 50 additions and 61 deletions

View File

@ -155,7 +155,7 @@ class project(osv.osv):
raise osv.except_osv(_('Operation Not Permitted !'), _('You cannot delete a project containing tasks. I suggest you to desactivate it.'))
return super(project, self).unlink(cr, uid, ids, *args, **kwargs)
def _open_task(self, cr, uid, ids, field_name, arg, context=None):
def _task_count(self, cr, uid, ids, field_name, arg, context=None):
open_task={}
task_pool=self.pool.get('project.task')
for id in ids:
@ -163,14 +163,6 @@ class project(osv.osv):
open_task[id] = len(task_ids)
return open_task
def company_uom_id(self, cr, uid, ids, field_name, arg, context=None):
uom_company = {}
for project in self.browse(cr,uid,ids):
user_browse = self.pool.get('res.users').browse(cr,uid,project.user_id.id)
uom_company[project.id] = project.company_id.project_time_mode_id.name or user_browse.company_id.project_time_mode_id.name
return uom_company
_columns = {
'complete_name': fields.function(_complete_name, string="Project Name", type='char', size=250),
'active': fields.boolean('Active', help="If the active field is set to False, it will allow you to hide the project without removing it."),
@ -207,10 +199,10 @@ class project(osv.osv):
'warn_header': fields.text('Mail Header', help="Header added at the beginning of the email for the warning message sent to the customer when a task is closed.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
'warn_footer': fields.text('Mail Footer', help="Footer added at the beginning of the email for the warning message sent to the customer when a task is closed.", states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
'task': fields.boolean('Task',help = "If you check this field tasks appears in kanban view"),
'open_task': fields.function(_open_task , type='integer',string="Open Tasks"),
'use_tasks': fields.boolean('Task',help = "If you check this field tasks appears in kanban view"),
'task_count': fields.function(_task_count , type='integer',string="Open Tasks"),
'color': fields.integer('Color Index'),
'company_uom_id': fields.function(company_uom_id,type="char"),
'company_uom_id': fields.related('company_id', 'project_time_mode_id', type='many2one', relation='product.uom'),
}
def dummy(self, cr, uid, ids, context=None):
return False
@ -247,7 +239,7 @@ class project(osv.osv):
'priority': 1,
'sequence': 10,
'type_ids': _get_type_common,
'task' : True,
'use_tasks' : True,
}
# TODO: Why not using a SQL contraints ?

View File

@ -45,7 +45,7 @@
<page string="Administration">
<group col="2" colspan="2" name="kanban">
<separator colspan="2" string="Project Management"/>
<field name="task"/>
<field name="use_tasks"/>
</group>
<group col="2" colspan="2">
<separator colspan="4" string="Performance"/>
@ -172,11 +172,11 @@
<field name="date"/>
<field name="name"/>
<field name="members"/>
<field name="task"/>
<field name="use_tasks"/>
<field name="user_id"/>
<field name="date"/>
<field name="color"/>
<field name="open_task"/>
<field name="task_count"/>
<templates>
<t t-name="kanban-box">
<div class="project_vignettes">
@ -198,8 +198,8 @@
</ul>
<h4><t t-esc="record.name.value.substr(0,33)"/><t t-if="record.name.value.length > 33">...</t></h4>
<div id="list">
<t t-if="record.task.raw_value">
<a id="1" name="open_tasks" class="oe_project_buttons" type="object"><t t-if="record.open_task.value &lt;= 1"> Task</t><t t-if="record.open_task.value &gt; 1"> Tasks</t>(<t t-esc="record.open_task.value"/>)</a>
<t t-if="record.use_tasks.raw_value">
<a id="1" name="open_tasks" class="oe_project_buttons" type="object"><t t-if="record.task_count.value &lt;= 1"> Task</t><t t-if="record.task_count.value &gt; 1"> Tasks</t>(<t t-esc="record.task_count.value"/>)</a>
</t>
</div>
<br/>
@ -216,7 +216,7 @@
<tr>
<th align="left" width="70px">Progress</th>
<td align="left">
<t t-esc="Math.round(record.effective_hours.raw_value)"/> / <t t-esc="Math.round(record.planned_hours.raw_value)"/> <field name="company_uom_id"/>s
<t t-esc="Math.round(record.effective_hours.raw_value)"/> / <t t-esc="Math.round(record.planned_hours.raw_value)"/> <field name="company_uom_id"/>
</td>
</tr>
</table>

View File

@ -17,8 +17,8 @@ openerp.project = function(openerp) {
});
//if task is true , then open the task when click on the anywhere in the box.
if(this.record.task.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks');
if(!this.record.task.raw_value)$(this.$element).find('.click_button').attr('data-name','dummy');
if(this.record.use_tasks.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks');
if(!this.record.use_tasks.raw_value)$(this.$element).find('.click_button').attr('data-name','dummy');
// set sequence like Tasks,Issues,Timesheets and Phases
my_list = $("#list a")

View File

@ -517,7 +517,7 @@ project_issue()
class project(osv.osv):
_inherit = "project.project"
def _compute_issue(self, cr, uid, ids, field_name, arg, context=None):
def _issue_count(self, cr, uid, ids, field_name, arg, context=None):
res={}
issue_pool=self.pool.get('project.issue')
for project in self.browse(cr, uid, ids, context=context):
@ -528,12 +528,12 @@ class project(osv.osv):
_columns = {
'project_escalation_id' : fields.many2one('project.project','Project Escalation', help='If any issue is escalated from the current Project, it will be listed under the project selected here.', states={'close':[('readonly',True)], 'cancelled':[('readonly',True)]}),
'reply_to' : fields.char('Reply-To Email Address', size=256),
'issues' : fields.boolean('Issues',help = "If you check this field issues are appears in kanban view"),
'total_issues': fields.function(_compute_issue , type='integer',string="Issue"),
'use_issues' : fields.boolean('Issues',help = "If you check this field issues are appears in kanban view"),
'issue_count': fields.function(_issue_count , type='integer'),
}
_defaults = {
'issues' : True,
'use_issues' : True,
}
def open_issues(self, cr, uid, ids, context=None):

View File

@ -345,8 +345,8 @@
<field name="type">form</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='task']" position="after">
<field name="issues"/>
<xpath expr="//field[@name='use_tasks']" position="after">
<field name="use_issues"/>
</xpath>
<field name="priority" position="before">
<field name="project_escalation_id"/>
@ -361,19 +361,16 @@
<field name="type">kanban</field>
<field name="inherit_id" ref="project.view_project_kanban"/>
<field name="arch" type="xml">
<field name="task" position="after">
<field name="issues"/>
<field name="total_issues" invisible="1"/>
<field name="use_tasks" position="after">
<field name="use_issues"/>
<field name="issue_count" invisible="1"/>
</field>
<xpath expr="//div[@id='list']" position="inside">
<t t-if="record.issues.raw_value">
<a id="2" name="open_issues" class="oe_project_buttons" type="object"><t t-if="record.total_issues.value &lt;= 1">Issue</t><t t-if="record.total_issues.value > 1">Issues</t>(<t t-esc="record.total_issues.value"/>)</a>
<t t-if="record.use_issues.raw_value">
<a id="2" name="open_issues" class="oe_project_buttons" type="object"><t t-if="record.issue_count.value &lt;= 1">Issue</t><t t-if="record.issue_count.value > 1">Issues</t>(<t t-esc="record.issue_count.value"/>)</a>
</t>
</xpath>
</field>
</record>
</data>
</openerp>

View File

@ -4,8 +4,8 @@ openerp.project_issue = function(openerp) {
self = this;
self._super();
if(this.view.dataset.model == 'project.project') {
if(this.record.task.raw_value && this.record.issues.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks');
if(!this.record.task.raw_value && this.record.issues.raw_value)$(this.$element).find('.click_button').attr('data-name','open_issues');
if(this.record.use_tasks.raw_value && this.record.use_issues.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks');
if(!this.record.use_tasks.raw_value && this.record.use_issues.raw_value)$(this.$element).find('.click_button').attr('data-name','open_issues');
};
}

View File

@ -217,7 +217,7 @@ project_user_allocation()
class project(osv.osv):
_inherit = "project.project"
def _open_phase(self, cr, uid, ids, field_name, arg, context=None):
def _phase_count(self, cr, uid, ids, field_name, arg, context=None):
open_phase={}
phase_pool=self.pool.get('project.phase')
for id in ids:
@ -227,12 +227,12 @@ class project(osv.osv):
_columns = {
'phase_ids': fields.one2many('project.phase', 'project_id', "Project Phases"),
'phases' : fields.boolean('Phase',help = "If you check this field Phases are appears in kanban view"),
'open_phases' : fields.function(_open_phase , type='integer',string="Open Phases"),
'use_phases' : fields.boolean('Phase',help = "If you check this field Phases are appears in kanban view"),
'phase_count' : fields.function(_phase_count , type='integer',string="Open Phases"),
}
_defaults = {
'phases' : True,
'use_phases' : True,
}
def open_phase(self, cr, uid, ids, context=None):
#Open the View for the Tasks for the project

View File

@ -104,8 +104,8 @@
<field name="type">form</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='task']" position="after">
<field name="phases"/>
<xpath expr="//field[@name='use_tasks']" position="after">
<field name="use_phases"/>
</xpath>
</field>
</record>
@ -116,13 +116,13 @@
<field name="type">kanban</field>
<field name="inherit_id" ref="project.view_project_kanban"/>
<field name="arch" type="xml">
<field name="task" position="after">
<field name="phases"/>
<field name="open_phases"/>
<field name="use_tasks" position="after">
<field name="use_phases"/>
<field name="phase_count"/>
</field>
<xpath expr="//div[@id='list']" position="inside">
<t t-if="record.phases.raw_value">
<a id="4" name="open_phase" class="oe_project_buttons" type="object"><t t-if="record.open_phases.value &lt;= 1">Phase</t><t t-if="record.open_phases.value > 1">Phases</t>(<t t-esc="record.open_phases.value"/>)</a>
<t t-if="record.use_phases.raw_value">
<a id="4" name="open_phase" class="oe_project_buttons" type="object"><t t-if="record.phase_count.value &lt;= 1">Phase</t><t t-if="record.phase_count.value > 1">Phases</t>(<t t-esc="record.phase_count.value"/>)</a>
</t>
</xpath>
</field>

View File

@ -48,7 +48,7 @@ class project_project(osv.osv):
return res
def _compute_timesheet(self, cr, uid, ids, field_name, arg, context=None):
def _timesheet_count(self, cr, uid, ids, field_name, arg, context=None):
res={}
aal_pool=self.pool.get('account.analytic.line')
for project in self.browse(cr, uid, ids, context=context):
@ -57,13 +57,13 @@ class project_project(osv.osv):
return res
_columns = {
'timesheets' : fields.boolean('Timesheets',help = "If you check this field timesheets appears in kanban view"),
'use_timesheets' : fields.boolean('Timesheets',help = "If you check this field timesheets appears in kanban view"),
'amt_to_invoice': fields.function(_to_invoice,string="Amount to Invoice",multi="sums"),
'hrs_to_invoice': fields.function(_to_invoice,string="Hours to Invoice",multi="sums"),
'total_timesheet': fields.function(_compute_timesheet , type='integer',string="Issue"),
'timesheet_count': fields.function(_timesheet_count , type='integer',string="Issue"),
}
_defaults = {
'timesheets' : True,
'use_timesheets' : True,
}
def onchange_partner_id(self, cr, uid, ids, part=False, context=None):

View File

@ -7,8 +7,8 @@
<field name="type">form</field>
<field name="inherit_id" ref="project.edit_project"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='task']" position='after'>
<field name="timesheets"/>
<xpath expr="//field[@name='use_tasks']" position='after'>
<field name="use_timesheets"/>
<field name="amt_to_invoice" invisible="True"/>
<field name="hrs_to_invoice" invisible="True"/>
</xpath>
@ -31,14 +31,14 @@
<field name="type">kanban</field>
<field name="inherit_id" ref="project.view_project_kanban"/>
<field name="arch" type="xml">
<field name="task" position="after">
<field name="timesheets" context="{'search_default_account_id': project_id, 'default_account_id': project_id}"/>
<field name="total_timesheet"/>
<field name="use_tasks" position="after">
<field name="use_timesheets" context="{'search_default_account_id': project_id, 'default_account_id': project_id}"/>
<field name="timesheet_count"/>
<field name="currency_id"/>
</field>
<xpath expr="//div[@id='list']" position="inside">
<t t-if="record.timesheets.raw_value">
<a id="3" name="open_timesheets" class="oe_project_buttons" type="object"><t t-if="record.total_timesheet.value &lt;= 1">Timesheet</t><t t-if="record.total_timesheet.value &gt; 1">Timesheets</t>(<t t-esc="record.total_timesheet.value"/>)</a>
<t t-if="record.use_timesheets.raw_value">
<a id="3" name="open_timesheets" class="oe_project_buttons" type="object"><t t-if="record.timesheet_count.value &lt;= 1">Timesheet</t><t t-if="record.timesheet_count.value &gt; 1">Timesheets</t>(<t t-esc="record.timesheet_count.value"/>)</a>
</t>
</xpath>

View File

@ -11,9 +11,9 @@ openerp.project_timesheet = function(openerp) {
}
if(include(this.view.fields_keys,"issues"))
{
if(!this.record.task.raw_value && !this.record.issues.raw_value && this.record.timesheets.raw_value)$(this.$element).find('.click_button').attr('data-name','open_timesheets');
if(!this.record.use_tasks.raw_value && !this.record.use_issues.raw_value && this.record.use_timesheets.raw_value)$(this.$element).find('.click_button').attr('data-name','open_timesheets');
};
if(this.record.task.raw_value && this.record.timesheets.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks');
if(this.record.use_tasks.raw_value && this.record.use_timesheets.raw_value)$(this.$element).find('.click_button').attr('data-name','open_tasks');
};
}
});