diff options
| author | Mustufa Rangwala <mra@mra-laptop> | 2010-07-02 20:15:03 +0530 |
|---|---|---|
| committer | Mustufa Rangwala <mra@mra-laptop> | 2010-07-02 20:15:03 +0530 |
| commit | 2d63bd763496a9b7399d02ca2a4e1e9790442fcb (patch) | |
| tree | a8f1655a658bed949f044c723e43b952d812222b /addons/project_issue/project_issue.py | |
| parent | 8c8a9c4b92b7901d2871e3a50decca9689c0c96e (diff) | |
| parent | db470305838faecdf26e5535b890b86f7aab2931 (diff) | |
[MERGE] Merge Team3 work from addons3 branch
bzr revid: mra@mra-laptop-20100702144503-0yynbrlkxn0v76lt
Diffstat (limited to 'addons/project_issue/project_issue.py')
| -rw-r--r-- | addons/project_issue/project_issue.py | 84 |
1 files changed, 39 insertions, 45 deletions
diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index aebb7356405..f13f816b4ca 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -25,14 +25,14 @@ import re import time import mx.DateTime from datetime import datetime, timedelta +import binascii +import collections import tools from crm import crm from osv import fields,osv,orm from osv.orm import except_orm from tools.translate import _ -import collections -import binascii import tools class project_issue(osv.osv, crm.crm_case): @@ -54,7 +54,9 @@ class project_issue(osv.osv, crm.crm_case): self.write(cr, uid, ids, {'date_open': time.strftime('%Y-%m-%d %H:%M:%S')}) return res - def _compute_day(self, cr, uid, ids, fields, args, context={}): + def _compute_day(self, cr, uid, ids, fields, args, context=None): + if context is None: + context = {} """ @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks, @@ -66,7 +68,7 @@ class project_issue(osv.osv, crm.crm_case): res_obj = self.pool.get('resource.resource') res = {} - for issue in self.browse(cr, uid, ids, context): + for issue in self.browse(cr, uid, ids, context=context): for field in fields: res[issue.id] = {} duration = 0 @@ -102,13 +104,7 @@ class project_issue(osv.osv, crm.crm_case): duration = float(ans.days) if issue.project_id and issue.project_id.resource_calendar_id: duration = float(ans.days) * 24 - new_dates = cal_obj.interval_min_get(cr, - uid, - issue.project_id.resource_calendar_id.id, - mx.DateTime.strptime(issue.create_date, '%Y-%m-%d %H:%M:%S'), - duration, - resource=resource_id - ) + new_dates = cal_obj.interval_min_get(cr, uid, issue.project_id.resource_calendar_id.id, mx.DateTime.strptime(issue.create_date, '%Y-%m-%d %H:%M:%S'), duration, resource=resource_id) no_days = [] date_until = mx.DateTime.strptime(date_until, '%Y-%m-%d %H:%M:%S') for in_time, out_time in new_dates: @@ -127,8 +123,8 @@ class project_issue(osv.osv, crm.crm_case): 'id': fields.integer('ID'), '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), + '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', \ @@ -140,28 +136,22 @@ class project_issue(osv.osv, crm.crm_case): domain="[('partner_id','=',partner_id)]"), 'company_id': fields.many2one('res.company', 'Company'), 'description': fields.text('Description'), - 'state': fields.selection([ - ('draft', 'Draft'), - ('open', 'Todo'), - ('cancel', 'Cancelled'), - ('done', 'Closed'), - ('pending', 'Pending'), - ], 'State', size=16, readonly=True, + 'state': fields.selection([('draft', 'Draft'), ('open', 'Todo'), ('cancel', 'Cancelled'), ('done', 'Closed'),('pending', 'Pending'), ], 'State', size=16, readonly=True, help='The state is set to \'Draft\', when a case is created.\ \nIf the case is in progress the state is set to \'Open\'.\ \nWhen the case is over, the state is set to \'Done\'.\ \nIf the case needs to be reviewed then the state is set to \'Pending\'.'), 'email_from': fields.char('Email', size=128, help="These people will receive email."), - 'email_cc': fields.text('Watchers Emails', size=252 , help="These people\ + 'email_cc': fields.text('Watchers Emails', size=252, help="These people\ will receive a copy of the future" \ " communication between partner and users by email"), 'date_open': fields.datetime('Opened', readonly=True), # Project Issue fields 'date_closed': fields.datetime('Closed', readonly=True), 'date': fields.datetime('Date'), - 'canal_id': fields.many2one('res.partner.canal', 'Channel',help="The channels represent the different communication modes available with the customer." \ + 'canal_id': fields.many2one('res.partner.canal', 'Channel', help="The channels represent the different communication modes available with the customer." \ " With each commercial opportunity, you can indicate the canall which is this opportunity source."), - 'categ_id': fields.many2one('crm.case.categ','Category', domain="[('object_id.model', '=', 'crm.project.bug')]"), + 'categ_id': fields.many2one('crm.case.categ', 'Category', domain="[('object_id.model', '=', 'crm.project.bug')]"), 'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Severity'), 'type_id': fields.many2one('crm.case.resource.type', 'Version', domain="[('object_id.model', '=', 'project.issue')]"), 'partner_name': fields.char("Employee's Name", size=64), @@ -176,7 +166,7 @@ class project_issue(osv.osv, crm.crm_case): method=True, multi='day_open', type="float", store=True), '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'), + 'assigned_to': fields.many2one('res.users', 'Assigned to'), 'working_hours_open': fields.function(_compute_day, string='Working Hours to Open the Issue', \ method=True, multi='working_days_open', type="float", store=True), 'working_hours_close': fields.function(_compute_day, string='Working Hours to Close the Issue', \ @@ -194,15 +184,15 @@ class project_issue(osv.osv, crm.crm_case): return False _defaults = { - 'active': lambda *a: 1, + 'active': 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, 'email_from': crm.crm_case. _get_default_email, - 'state': lambda *a: 'draft', + 'state': 'draft', 'section_id': crm.crm_case. _get_section, 'company_id': lambda s, cr, uid, c: s.pool.get('res.company')._company_default_get(cr, uid, 'crm.helpdesk', context=c), - 'priority': lambda *a: crm.AVAILABLE_PRIORITIES[2][0], + 'priority': crm.AVAILABLE_PRIORITIES[2][0], 'project_id':_get_project, } @@ -229,9 +219,9 @@ class project_issue(osv.osv, crm.crm_case): 'partner_id': bug.partner_id.id, 'description':bug.description, 'date': bug.date, - 'project_id':bug.project_id.id, - 'priority':bug.priority, - 'user_id':bug.assigned_to.id, + 'project_id': bug.project_id.id, + 'priority': bug.priority, + 'user_id': bug.assigned_to.id, 'planned_hours': 0.0, }) @@ -269,7 +259,9 @@ class project_issue(osv.osv, crm.crm_case): def convert_to_bug(self, cr, uid, ids, context=None): return self._convert(cr, uid, ids, 'bug_categ', context=context) - def onchange_stage_id(self, cr, uid, ids, stage_id, context={}): + def onchange_stage_id(self, cr, uid, ids, stage_id, context=None): + if context is None: + context = {} if not stage_id: return {'value':{}} stage = self.pool.get('crm.case.stage').browse(cr, uid, stage_id, context) @@ -300,7 +292,7 @@ class project_issue(osv.osv, crm.crm_case): def message_new(self, cr, uid, msg, context): """ Automatically calls when new email message arrives - + @param self: The object pointer @param cr: the current row, from the database cursor, @param uid: the current user’s ID for security checks @@ -312,7 +304,7 @@ class project_issue(osv.osv, crm.crm_case): body = msg.get('body') msg_from = msg.get('from') priority = msg.get('priority') - + vals = { 'name': subject, 'email_from': msg_from, @@ -322,18 +314,18 @@ class project_issue(osv.osv, crm.crm_case): } if msg.get('priority', False): vals['priority'] = priority - + res = mailgate_pool.get_partner(cr, uid, msg.get('from')) if res: vals.update(res) res = self.create(cr, uid, vals, context) self.convert_to_bug(cr, uid, [res], context=context) - + attachents = msg.get('attachments', []) for attactment in attachents or []: data_attach = { 'name': attactment, - 'datas':binascii.b2a_base64(str(attachents.get(attactment))), + 'datas': binascii.b2a_base64(str(attachents.get(attactment))), 'datas_fname': attactment, 'description': 'Mail attachment', 'res_model': self._name, @@ -343,17 +335,19 @@ class project_issue(osv.osv, crm.crm_case): return res - def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context={}): - """ + def message_update(self, cr, uid, ids, vals={}, msg="", default_act='pending', context=None): + if context is None: + context = {} + """ @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 update mail’s IDs + @param ids: List of update mail’s IDs """ - + if isinstance(ids, (str, int, long)): ids = [ids] - + vals.update({ 'description': msg['body'] }) @@ -361,9 +355,9 @@ class project_issue(osv.osv, crm.crm_case): vals['priority'] = msg.get('priority') maps = { - 'cost':'planned_cost', + 'cost': 'planned_cost', 'revenue': 'planned_revenue', - 'probability':'probability' + 'probability': 'probability' } vls = { } for line in msg['body'].split('\n'): @@ -372,7 +366,7 @@ class project_issue(osv.osv, crm.crm_case): if res and maps.get(res.group(1).lower(), False): key = maps.get(res.group(1).lower()) vls[key] = res.group(2).lower() - + vals.update(vls) res = self.write(cr, uid, ids, vals) return res @@ -399,4 +393,4 @@ class project(osv.osv): } project() - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
