From c983859b9d5002f8242dfe4d759712ba51d466a7 Mon Sep 17 00:00:00 2001 From: "mra (Open ERP)" Date: Tue, 16 Mar 2010 11:23:22 +0530 Subject: [PATCH 1/8] [FIX] project_timesheet: Creating and writing timesheet line from project task work lp bug: https://launchpad.net/bugs/539065 fixed bzr revid: mra@tinyerp.com-20100316055322-go9qvmqw4ckv17ri --- addons/project_timesheet/project_timesheet.py | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index fbafdb4a60a..a6743b10330 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## from osv import fields, osv @@ -58,11 +58,12 @@ class project_work(osv.osv): res['general_account_id'] = a res['product_uom_id'] = emp.product_id.uom_id.id return res - + def create(self, cr, uid, vals, *args, **kwargs): - obj = self.pool.get('hr.analytic.timesheet') + obj_timesheet = self.pool.get('hr.analytic.timesheet') + task_obj = self.pool.get('project.task') vals_line = {} - obj_task = self.pool.get('project.task').browse(cr, uid, vals['task_id']) + obj_task = task_obj.browse(cr, uid, vals['task_id']) result = self.get_user_related_details(cr, uid, vals.get('user_id', uid)) vals_line['name'] = '%s: %s' % (tools.ustr(obj_task.name), tools.ustr(vals['name']) or '/') vals_line['user_id'] = vals['user_id'] @@ -71,33 +72,36 @@ class project_work(osv.osv): vals_line['unit_amount'] = vals['hours'] acc_id = obj_task.project_id.category_id.id vals_line['account_id'] = acc_id - res = obj.on_change_account_id(cr, uid, False, acc_id) + res = obj_timesheet.on_change_account_id(cr, uid, False, acc_id) if res.get('value'): vals_line.update(res['value']) vals_line['general_account_id'] = result['general_account_id'] vals_line['journal_id'] = result['journal_id'] vals_line['amount'] = 00.0 vals_line['product_uom_id'] = result['product_uom_id'] - timeline_id = obj.create(cr, uid, vals_line, {}) - + amount = vals_line['unit_amount'] + prod_id = vals_line['product_id'] + unit = False + timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=kwargs['context']) + # Compute based on pricetype - amount_unit=obj.on_change_unit_amount(cr, uid, line_id, - vals_line['product_id'], vals_line['unit_amount'], unit, context) - - vals_line['amount'] = (-1) * vals['hours']* (unit_amount or 0.0) - obj.write(cr, uid,[timeline_id], vals_line, {}) + amount_unit=obj_timesheet.on_change_unit_amount(cr, uid, timeline_id, + prod_id, amount, unit, context=kwargs['context']) + + vals_line['amount'] = (-1) * vals['hours']* (amount_unit['value']['amount'] or 0.0) + obj_timesheet.write(cr, uid,[timeline_id], vals_line, {}) vals['hr_analytic_timesheet_id'] = timeline_id return super(project_work,self).create(cr, uid, vals, *args, **kwargs) def write(self, cr, uid, ids, vals, context=None): vals_line = {} - - task = self.pool.get('project.task.work').browse(cr, uid, ids)[0] + obj = self.pool.get('hr.analytic.timesheet') + timesheet_obj = self.pool.get('hr.analytic.timesheet') + task = self.pool.get('project.task.work').browse(cr, uid, ids, context=context)[0] line_id = task.hr_analytic_timesheet_id # in case,if a record is deleted from timesheet,but we change it from tasks! - list_avail_ids = self.pool.get('hr.analytic.timesheet').search(cr, uid, []) + list_avail_ids = timesheet_obj.search(cr, uid, [], context=context) if line_id in list_avail_ids: - obj = self.pool.get('hr.analytic.timesheet') if 'name' in vals: vals_line['name'] = '%s: %s' % (tools.ustr(task.task_id.name), tools.ustr(vals['name']) or '/') if 'user_id' in vals: @@ -111,13 +115,13 @@ class project_work(osv.osv): vals_line['date'] = vals['date'][:10] if 'hours' in vals: vals_line['unit_amount'] = vals['hours'] - # Compute based on pricetype - amount_unit=obj.on_change_unit_amount(cr, uid, line_id, - vals_line['product_id'], vals_line['unit_amount'], unit, context) - - vals_line['amount'] = (-1) * vals['hours'] * (amount_unit or 0.0) - obj.write(cr, uid, [line_id], vals_line, {}) + unit = False + amount_unit=obj.on_change_unit_amount(cr, uid, line_id, + vals_line['product_id'], vals_line['unit_amount'], unit, context=context) + + vals_line['amount'] = (-1) * vals['hours'] * (amount_unit['value']['amount'] or 0.0) + obj.write(cr, uid, [line_id], vals_line, context=context) return super(project_work,self).write(cr, uid, ids, vals, context) @@ -147,9 +151,9 @@ class task(osv.osv): if task_obj.work_ids: work_ids = [x.id for x in task_obj.work_ids] self.pool.get('project.task.work').unlink(cr, uid, work_ids, *args, **kwargs) - + return super(task,self).unlink(cr, uid, ids, *args, **kwargs) - + def write(self, cr, uid, ids,vals,context={}): if (vals.has_key('project_id') and vals['project_id']) or (vals.has_key('name') and vals['name']): vals_line = {} From b1ccfa683de3875c62e044c71131b910d1851593 Mon Sep 17 00:00:00 2001 From: "mra (Open ERP)" Date: Tue, 16 Mar 2010 11:48:57 +0530 Subject: [PATCH 2/8] [FIX] project_caldev: onchange method on recurrency bzr revid: mra@tinyerp.com-20100316061857-duy0ud9tuxu1xevu --- addons/project_caldav/__terp__.py | 30 +++++++++---------- addons/project_caldav/project_caldav_view.xml | 18 ++++++----- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/addons/project_caldav/__terp__.py b/addons/project_caldav/__terp__.py index 0cd26f06334..1ac69933623 100644 --- a/addons/project_caldav/__terp__.py +++ b/addons/project_caldav/__terp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (). # @@ -15,22 +15,22 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . # ############################################################################## { - "name" : "Caldav task management", - "version" : "1.0", - "author" : "Tiny", - "category" : "Generic Modules/Others", - "description": """ Synchronize between Project task and Caldav Vtodo.""", - "depends" : ["project", "caldav"], - "init_xml" : ["project_caldav_data.xml"], - "demo_xml" : [], - "update_xml" : ["project_caldav_view.xml", - "project_caldav_wizard.xml"], - "active": False, - "website": "http://www.openerp.com", - "installable": True, + "name" : "Caldav task management", + "version" : "1.0", + "author" : "Tiny", + "category" : "Generic Modules/Others", + "description": """ Synchronize between Project task and Caldav Vtodo.""", + "depends" : ["project", "caldav", "base_calendar"], + "init_xml" : ["project_caldav_data.xml"], + "demo_xml" : [], + "update_xml" : ["project_caldav_view.xml", + "project_caldav_wizard.xml"], + "active": False, + "website": "http://www.openerp.com", + "installable": True, } diff --git a/addons/project_caldav/project_caldav_view.xml b/addons/project_caldav/project_caldav_view.xml index d4fc7115491..541cc3c396e 100644 --- a/addons/project_caldav/project_caldav_view.xml +++ b/addons/project_caldav/project_caldav_view.xml @@ -1,7 +1,7 @@ - + project.task.caldav.form project.task @@ -46,8 +46,8 @@ - - + + project.task.caldav.form1 project.task @@ -58,8 +58,8 @@ - - + + project.task.caldav.form2 project.task @@ -68,8 +68,10 @@ - +-->