diff --git a/addons/account/report/account_tax_report.py b/addons/account/report/account_tax_report.py index 35abda75dba..4361448790c 100644 --- a/addons/account/report/account_tax_report.py +++ b/addons/account/report/account_tax_report.py @@ -36,7 +36,7 @@ class tax_report(rml_parse.rml_parse, common_report_header): res['periods'] = '' res['fiscalyear'] = data['form'].get('fiscalyear_id', False) - if data['form']['period_from'] and data['form']['period_to']: + if data['form'].get('period_from', False) and data['form'].get('period_to', False): self.period_ids = period_obj.build_ctx_periods(self.cr, self.uid, data['form']['period_from'], data['form']['period_to']) periods_l = period_obj.read(self.cr, self.uid, self.period_ids, ['name']) for period in periods_l: diff --git a/addons/project/test/test_project.yml b/addons/project/test/test_project.yml index d417debac8c..bca3bcbff41 100644 --- a/addons/project/test/test_project.yml +++ b/addons/project/test/test_project.yml @@ -134,7 +134,7 @@ - Make a work task entry 'Training on OpenERP modules, models and classes' of 10 hours - - !record {model: project.task, id: project_task_technicaltraining0}: + !record {model: project.task, id: project_task_technicaltraining0, context:{'no_analytic_entry':True}}: work_ids: - date: '2010-05-31 15:04:22' hours: 10.0 @@ -149,7 +149,7 @@ - Make a work task entry 'Training on OpenERP xml views' of 10 hours - - !record {model: project.task, id: project_task_technicaltraining0}: + !record {model: project.task, id: project_task_technicaltraining0, context:{'no_analytic_entry':True}}: work_ids: - date: '2010-06-01 15:04:46' hours: 10.0 @@ -164,7 +164,7 @@ - Make a work task entry 'Training on workflows' of 10 hours - - !record {model: project.task, id: project_task_technicaltraining0}: + !record {model: project.task, id: project_task_technicaltraining0, context:{'no_analytic_entry':True}}: work_ids: - date: '2010-06-02 15:05:24' hours: 10.0 @@ -200,7 +200,7 @@ - Make a work task entry 'Training on reports and wizards' of 10 hours - - !record {model: project.task, id: project_task_technicaltraining0}: + !record {model: project.task, id: project_task_technicaltraining0, context:{'no_analytic_entry':True}}: work_ids: - date: '2010-05-31 15:08:40' hours: 10.0 @@ -251,7 +251,7 @@ - Make a work task entry 'Training on yml' of 5 hours - - !record {model: project.task, id: project_task_technicaltraining0}: + !record {model: project.task, id: project_task_technicaltraining0, context:{'no_analytic_entry':True}}: work_ids: - date: '2010-05-31 16:55:27' hours: 5.0 diff --git a/addons/project_caldav/project_caldav.py b/addons/project_caldav/project_caldav.py index ea6c02bc2cb..fb2d62a9684 100644 --- a/addons/project_caldav/project_caldav.py +++ b/addons/project_caldav/project_caldav.py @@ -32,6 +32,7 @@ class project_task(osv.osv): # force inherit from project.project_task so that # calendar.todo.active is masked oute 'active': base_project_task._columns['active'], + 'date_deadline': base_project_task._columns['date_deadline'], 'write_date': fields.datetime('Write Date'), 'create_date': fields.datetime('Create Date', readonly=True), 'attendee_ids': fields.many2many('calendar.attendee', \ diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index 601fbfa578b..42104fcddc1 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -80,42 +80,42 @@ class project_work(osv.osv): vals_line = {} context = kwargs.get('context', {}) + if not context.get('no_analytic_entry',False): + 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'] + vals_line['product_id'] = result['product_id'] + vals_line['date'] = vals['date'][:10] + + #calculate quantity based on employee's product's uom + vals_line['unit_amount'] = vals['hours'] - 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'] - vals_line['product_id'] = result['product_id'] - vals_line['date'] = vals['date'][:10] - - #calculate quantity based on employee's product's uom - vals_line['unit_amount'] = vals['hours'] + default_uom = self.pool.get('res.users').browse(cr, uid, uid).company_id.project_time_mode_id.id + if result['product_uom_id'] != default_uom: + vals_line['unit_amount'] = uom_obj._compute_qty(cr, uid, default_uom, vals['hours'], result['product_uom_id']) + acc_id = obj_task.project_id and obj_task.project_id.analytic_account_id.id or False + if acc_id: + vals_line['account_id'] = 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'] = 0.0 + vals_line['product_uom_id'] = result['product_uom_id'] + amount = vals_line['unit_amount'] + prod_id = vals_line['product_id'] + unit = False + timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=context) - default_uom = self.pool.get('res.users').browse(cr, uid, uid).company_id.project_time_mode_id.id - if result['product_uom_id'] != default_uom: - vals_line['unit_amount'] = uom_obj._compute_qty(cr, uid, default_uom, vals['hours'], result['product_uom_id']) - acc_id = obj_task.project_id and obj_task.project_id.analytic_account_id.id or False - if acc_id: - vals_line['account_id'] = 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'] = 0.0 - vals_line['product_uom_id'] = result['product_uom_id'] - amount = vals_line['unit_amount'] - prod_id = vals_line['product_id'] - unit = False - timeline_id = obj_timesheet.create(cr, uid, vals=vals_line, context=context) - - # Compute based on pricetype - amount_unit = obj_timesheet.on_change_unit_amount(cr, uid, timeline_id, - prod_id, amount, False, unit, context=context) - if amount_unit and 'amount' in amount_unit.get('value',{}): - updv = { 'amount': amount_unit['value']['amount'] } - obj_timesheet.write(cr, uid, [timeline_id], updv, context=context) - vals['hr_analytic_timesheet_id'] = timeline_id + # Compute based on pricetype + amount_unit = obj_timesheet.on_change_unit_amount(cr, uid, timeline_id, + prod_id, amount, False, unit, context=context) + if amount_unit and 'amount' in amount_unit.get('value',{}): + updv = { 'amount': amount_unit['value']['amount'] } + obj_timesheet.write(cr, uid, [timeline_id], updv, context=context) + 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):