diff --git a/addons/project/project.py b/addons/project/project.py index bdf7e30837e..61720675f49 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -135,6 +135,7 @@ 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."), '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."), 'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages'), + '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.'), } _order = "sequence" _defaults = { @@ -149,11 +150,18 @@ class project(osv.osv): if leave['date_start'] > leave['date']: return False return True - + + def _check_escalation(self, cr, uid, ids): + project_obj = self.browse(cr, uid, ids[0]) + if project_obj.project_escalation_id: + if project_obj.project_escalation_id.id == project_obj.id: + return False + return True + _constraints = [ - (_check_dates, 'Error! project start-date must be lower then project end-date.', ['date_start', 'date']) + (_check_dates, 'Error! project start-date must be lower then project end-date.', ['date_start', 'date']), + (_check_escalation, 'Error! You cannot assign escalation to the same project!', ['project_escalation_id']) ] - def set_template(self, cr, uid, ids, context={}): res = self.setActive(cr, uid, ids, value=False, context=context) return res diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 2228aa7aa11..fccf13c7a21 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -36,6 +36,7 @@ + diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index b67ef6a849a..795c9883eca 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -112,16 +112,17 @@ class project_issue(osv.osv, crm.crm_case): _columns = { 'thread_id': fields.many2one('mailgate.thread', 'Thread', required=False), 'id': fields.integer('ID'), - 'name': fields.char('Name', size=128, required=True), - 'create_date': fields.datetime('Creation Date' , readonly=True), - 'write_date': fields.datetime('Update Date' , readonly=True), - 'date_deadline': fields.date('Deadline'), - 'date_closed': fields.datetime('Closed', readonly=True), + 'name': fields.char('Name', size=128, required=True), + 'active': fields.boolean('Active', required=False), + 'create_date': fields.datetime('Creation Date' , readonly=True), + 'write_date': fields.datetime('Update Date' , readonly=True), + 'date_deadline': fields.date('Deadline'), + 'date_closed': fields.datetime('Closed', readonly=True), 'section_id': fields.many2one('crm.case.section', 'Sales Team', \ select=True, help='Sales team to which Case belongs to.\ Define Responsible user and Email account for mail gateway.'), - 'user_id': fields.many2one('res.users', 'Responsible'), - 'partner_id': fields.many2one('res.partner', 'Partner'), + 'user_id': fields.many2one('res.users', 'Responsible'), + 'partner_id': fields.many2one('res.partner', 'Partner'), 'partner_address_id': fields.many2one('res.partner.address', 'Partner Contact', \ domain="[('partner_id','=',partner_id)]"), 'company_id': fields.many2one('res.company', 'Company'), @@ -163,6 +164,8 @@ class project_issue(osv.osv, crm.crm_case): 'day_close': fields.function(_compute_day, string='Days to Close', \ method=True, multi='day_close', type="float", store=True), 'assigned_to' : fields.many2one('res.users', 'Assigned to'), + 'working_hours_open': fields.float('Working Hours to Open the Issue'), + 'working_hours_close': fields.float('Working Hours to Close the Issue'), } def _get_project(self, cr, uid, context): @@ -172,6 +175,7 @@ class project_issue(osv.osv, crm.crm_case): return False _defaults = { + 'active': lambda *a: 1, 'user_id': crm.crm_case._get_default_user, 'partner_id': crm.crm_case._get_default_partner, 'partner_address_id': crm.crm_case._get_default_partner_address, @@ -260,6 +264,25 @@ class project_issue(osv.osv, crm.crm_case): if not stage.on_change: return {'value':{}} return {'value':{}} + + def case_escalate(self, cr, uid, ids, *args): + """Escalates case to top level + @param self: The object pointer + @param cr: the current row, from the database cursor, + @param uid: the current user’s ID for security checks, + @param ids: List of case Ids + @param *args: Tuple Value for additional Params + """ + res = super(project_issue, self).case_escalate(cr, uid, ids, args) + cases = self.browse(cr, uid, ids) + for case in cases: + data = {} + if case.project_id.project_escalation_id: + data['project_id'] = case.project_id.project_escalation_id.id + else: + raise osv.except_osv(_('Warning !'), _('You cannot escalate this case.\nThe relevant Project has not configured the Escalation Project!')) + self.write(cr, uid, [case.id], data) + return res project_issue() diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index 27b72e459ef..9362e858b1e 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -82,8 +82,13 @@ + + + + +