diff --git a/addons/hr_attendance/hr_attendance_view.xml b/addons/hr_attendance/hr_attendance_view.xml index bed3aaa9550..2b6b976b7e2 100644 --- a/addons/hr_attendance/hr_attendance_view.xml +++ b/addons/hr_attendance/hr_attendance_view.xml @@ -120,10 +120,6 @@ - - - - diff --git a/addons/hr_timesheet/__init__.py b/addons/hr_timesheet/__init__.py index 7eac6043115..ef86c22b5c9 100644 --- a/addons/hr_timesheet/__init__.py +++ b/addons/hr_timesheet/__init__.py @@ -2,4 +2,5 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import hr_timesheet +import project_timesheet import report diff --git a/addons/hr_timesheet/__openerp__.py b/addons/hr_timesheet/__openerp__.py index 0eb4c7dcf7a..1b105eb8463 100644 --- a/addons/hr_timesheet/__openerp__.py +++ b/addons/hr_timesheet/__openerp__.py @@ -12,8 +12,6 @@ This module implements a timesheet system. ========================================== Each employee can encode and track their time spent on the different projects. -A project is an analytic account and the time spent on a project generates costs on -the analytic account. Lots of reporting on time and employee tracking are provided. @@ -21,10 +19,11 @@ It is completely integrated with the cost accounting module. It allows you to se up a management by affair. """, 'website': 'https://www.odoo.com/page/employees', - 'depends': ['account', 'hr', 'base', 'hr_attendance'], + 'depends': ['account', 'hr', 'project'], 'data': [ 'security/ir.model.access.csv', 'hr_timesheet_view.xml', + 'project_timesheet_view.xml', 'report/hr_timesheet_report_view.xml', 'hr_timesheet_installer.xml', 'hr_dashboard.xml', @@ -35,6 +34,7 @@ up a management by affair. 'test': [ '../account/test/account_minimal_test.xml', 'test/hr_timesheet_users.yml', + 'test/worktask_entry_to_timesheetline_entry.yml', ], 'installable': True, 'auto_install': False, diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index b83d3c4bb74..a7cbaec65e3 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -1,15 +1,29 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from openerp import models, fields +from openerp import models, fields, api -class Company(models.Model): - _inherit = 'res.company' -class account_analytic_line(models.Model): +class AccountAnalyticLine(models.Model): _inherit = 'account.analytic.line' - is_timesheet = fields.Boolean(string="Is a Timesheet") -class account_analytic_account(models.Model): - _inherit = 'account.analytic.account' - use_timesheets = fields.Boolean('Timesheets', help="Check this field if this project manages timesheets", deprecated=True) + task_id = fields.Many2one('project.task', 'Task') + project_id = fields.Many2one('project.project', 'Project') + + @api.onchange('project_id') + def onchange_project_id(self): + self.task_id = False + + @api.model + def create(self, vals): + if vals.get('project_id'): + project = self.env['project.project'].browse(vals.get('project_id')) + vals['account_id'] = project.analytic_account_id.id + return super(AccountAnalyticLine, self).create(vals) + + @api.multi + def write(self, vals): + if vals.get('project_id'): + project = self.env['project.project'].browse(vals.get('project_id')) + vals['account_id'] = project.analytic_account_id.id + return super(AccountAnalyticLine, self).write(vals) diff --git a/addons/hr_timesheet/hr_timesheet_demo.yml b/addons/hr_timesheet/hr_timesheet_demo.yml index 05ec70a965a..a6e3276adb0 100644 --- a/addons/hr_timesheet/hr_timesheet_demo.yml +++ b/addons/hr_timesheet/hr_timesheet_demo.yml @@ -10,9 +10,8 @@ 'unit_amount': 2.00, 'product_id': ref('product.product_product_1'), 'product_uom_id': ref('product.product_uom_hour'), - 'account_id': ref('analytic.analytic_administratif'), + 'project_id': ref('project.project_project_2'), 'amount': -60.00, - 'is_timesheet': True, } self._update(cr, uid, 'account.analytic.line', 'hr_timesheet', vals, 'working_hours_requirements') vals = { @@ -22,9 +21,8 @@ 'unit_amount': 1.00, 'product_id': ref('product.product_product_1'), 'product_uom_id': ref('product.product_uom_hour'), - 'account_id': ref('analytic.analytic_administratif'), + 'project_id': ref('project.project_project_2'), 'amount': -30.00, - 'is_timesheet': True, } self._update(cr, uid, 'account.analytic.line', 'hr_timesheet', vals, 'working_hours_design') vals = { @@ -34,9 +32,8 @@ 'unit_amount': 3.00, 'product_id': ref('product.product_product_1'), 'product_uom_id': ref('product.product_uom_hour'), - 'account_id': ref('analytic.analytic_administratif'), + 'project_id': ref('project.project_project_2'), 'amount': -90.00, - 'is_timesheet': True, } self._update(cr, uid, 'account.analytic.line', 'hr_timesheet', vals, 'working_hours_coding') vals = { @@ -46,9 +43,8 @@ 'unit_amount': 1.00, 'product_id': ref('product.product_product_1'), 'product_uom_id': ref('product.product_uom_hour'), - 'account_id': ref('analytic.analytic_administratif'), + 'project_id': ref('project.project_project_2'), 'amount': -30.00, - 'is_timesheet': True, } self._update(cr, uid, 'account.analytic.line', 'hr_timesheet', vals, 'working_hours_testing') vals = { @@ -58,8 +54,7 @@ 'unit_amount': 1.00, 'product_id': ref('product.product_product_1'), 'product_uom_id': ref('product.product_uom_hour'), - 'account_id': ref('analytic.analytic_administratif'), + 'project_id': ref('project.project_project_2'), 'amount': -30.00, - 'is_timesheet': True, } self._update(cr, uid, 'account.analytic.line', 'hr_timesheet', vals, 'working_hours_maintenance') diff --git a/addons/hr_timesheet/hr_timesheet_view.xml b/addons/hr_timesheet/hr_timesheet_view.xml index a19c6070453..61f9918a445 100644 --- a/addons/hr_timesheet/hr_timesheet_view.xml +++ b/addons/hr_timesheet/hr_timesheet_view.xml @@ -1,57 +1,32 @@ - + + - account.analytic.line.tree + account.analytic.line.tree.hr_timesheet account.analytic.line - + + - - account.analytic.line.form + account.analytic.line.form.inherit.hr_timesheet account.analytic.line + + primary -
- - - - - - - - - - - - - - - - - - - - - - - - - -
+ + + +
@@ -61,10 +36,13 @@ - + + + - + + @@ -72,32 +50,20 @@ - - Timesheet Accounts - ir.actions.act_window - account.analytic.account - form - tree,form - - - - - + Activities account.analytic.line form - [('is_timesheet', '=', True)] - {"search_default_today":1, "default_is_timesheet":1} + [('project_id', '!=', False)] + {"search_default_today":1}

Click to record activities.

You can register and track your workings hours by project every - day. Every time spent on a project will become a cost in the - analytic accounting/contract and can be re-invoiced to + day. Every time spent on a project will become a cost and can be re-invoiced to customers if required.

@@ -107,12 +73,11 @@ tree - +
- -
diff --git a/addons/hr_timesheet/project_timesheet.py b/addons/hr_timesheet/project_timesheet.py index d628919cae5..83834341060 100644 --- a/addons/hr_timesheet/project_timesheet.py +++ b/addons/hr_timesheet/project_timesheet.py @@ -1,47 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -import time -import datetime -from dateutil.relativedelta import relativedelta -from openerp.addons.analytic.models import analytic from openerp.osv import fields, osv -from openerp import tools -from openerp.tools.translate import _ -from openerp.exceptions import UserError - -class project_project(osv.osv): - _inherit = 'project.project' - - def open_timesheets(self, cr, uid, ids, context=None): - """ open Timesheets view """ - mod_obj = self.pool.get('ir.model.data') - act_obj = self.pool.get('ir.actions.act_window') - - project = self.browse(cr, uid, ids[0], context) - view_context = { - 'search_default_account_id': [project.analytic_account_id.id], - 'default_account_id': project.analytic_account_id.id, - 'default_is_timesheet':True - } - help = _("""

Record your timesheets for the project '%s'.

""") % (project.name,) - - res = mod_obj.get_object_reference(cr, uid, 'hr_timesheet', 'act_hr_timesheet_line_evry1_all_form') - id = res and res[1] or False - result = act_obj.read(cr, uid, [id], context=context)[0] - result['name'] = _('Timesheets') - result['context'] = view_context - result['help'] = help - return result - - def open_contract(self, cr, uid, ids, context=None): - """ open Contract view """ - - res = self.pool['ir.actions.act_window'].for_xml_id(cr, uid, 'project_timesheet', 'action_project_analytic_account', context=context) - contract_ids = self.browse(cr, uid, ids, context=context) - account_ids = [x.analytic_account_id.id for x in contract_ids] - res['res_id'] = account_ids and account_ids[0] or None - return res class task(osv.osv): @@ -102,42 +62,8 @@ class task(osv.osv): 'account.analytic.line': (_get_task, ['task_id', 'unit_amount'], 10), }), 'timesheet_ids': fields.one2many('account.analytic.line', 'task_id', 'Timesheets'), - 'analytic_account_id': fields.related('project_id', 'analytic_account_id', - type='many2one', relation='account.analytic.account', string='Analytic Account', store=True), } _defaults = { 'progress': 0, } - - def _prepare_delegate_values(self, cr, uid, ids, delegate_data, context=None): - vals = super(task, self)._prepare_delegate_values(cr, uid, ids, delegate_data, context) - for task in self.browse(cr, uid, ids, context=context): - vals[task.id]['planned_hours'] += task.effective_hours - return vals - - def onchange_project(self, cr, uid, ids, project_id, context=None): - result = super(task, self).onchange_project(cr, uid, ids, project_id, context=context) - if not project_id: - return result - if 'value' not in result: - result['value'] = {} - project = self.pool['project.project'].browse(cr, uid, project_id, context=context) - return result - - -class res_partner(osv.osv): - _inherit = 'res.partner' - - def unlink(self, cursor, user, ids, context=None): - parnter_id=self.pool.get('project.project').search(cursor, user, [('partner_id', 'in', ids)]) - if parnter_id: - raise UserError(_('You cannot delete a partner which is assigned to project, but you can uncheck the active box.')) - return super(res_partner,self).unlink(cursor, user, ids, - context=context) - -class account_analytic_line(osv.osv): - _inherit = "account.analytic.line" - _columns = { - 'task_id' : fields.many2one('project.task', 'Task'), - } diff --git a/addons/hr_timesheet/project_timesheet_demo.xml b/addons/hr_timesheet/project_timesheet_demo.xml index 577bab6101e..14dd8a9a679 100644 --- a/addons/hr_timesheet/project_timesheet_demo.xml +++ b/addons/hr_timesheet/project_timesheet_demo.xml @@ -9,7 +9,7 @@ Building 1, Second Floor +3282623500 - + @@ -31,7 +31,7 @@ alice@openerp.com - + diff --git a/addons/hr_timesheet/project_timesheet_view.xml b/addons/hr_timesheet/project_timesheet_view.xml index 17e0fd8e678..2118bb19432 100644 --- a/addons/hr_timesheet/project_timesheet_view.xml +++ b/addons/hr_timesheet/project_timesheet_view.xml @@ -1,84 +1,63 @@ - + + Activities + account.analytic.line + form + tree,form + + [('project_id', '!=', False)] + {"default_project_id": active_id, "search_default_project_id": [active_id]} + + +

+ Click to record activities. +

+ You can register and track your workings hours by project every + day. Every time spent on a project will become a cost and can be re-invoiced to + customers if required. +

+
+
Inherit project form : Invoicing Data project.project
-
- - account.analytic.line.search.account_id - account.analytic.line - - - - - - - - - - - - account.analytic.line.form.account_id - account.analytic.line - - - - Analytic Account/Project - - - - - account.analytic.line.tree.account_id - account.analytic.line - - - - Analytic account/project - - - - - - - project.task.form.inherited project.task + - - onchange_project(project_id) - - - + + + + - - + + - - + - - - + + + @@ -92,8 +71,9 @@ - - + + + @@ -110,7 +90,7 @@ diff --git a/addons/hr_timesheet/report/__init__.py b/addons/hr_timesheet/report/__init__.py index 8728fb520b6..87a38add022 100644 --- a/addons/hr_timesheet/report/__init__.py +++ b/addons/hr_timesheet/report/__init__.py @@ -1 +1,2 @@ import hr_timesheet_report +import project_report diff --git a/addons/hr_timesheet/report/hr_timesheet_report.py b/addons/hr_timesheet/report/hr_timesheet_report.py index d453f6420c0..957fa42cc56 100644 --- a/addons/hr_timesheet/report/hr_timesheet_report.py +++ b/addons/hr_timesheet/report/hr_timesheet_report.py @@ -12,7 +12,7 @@ class hr_timesheet_report(models.Model): date = fields.Date('Date', readonly=True) product_id = fields.Many2one('product.product', 'Product', readonly=True) user_id = fields.Many2one('res.users', 'User', readonly=True) - account_id = fields.Many2one('account.analytic.account', 'Analytic Account', readonly=True) + project_id = fields.Many2one('project.project', 'Project', readonly=True) company_id = fields.Many2one('res.company', 'Company', readonly=True) cost = fields.Float('Cost', readonly=True, digits=dp.get_precision('Account')) quantity = fields.Float('Time', readonly=True) @@ -23,7 +23,7 @@ class hr_timesheet_report(models.Model): aal.date as date, sum(aal.amount) as cost, sum(aal.unit_amount) as quantity, - aal.account_id as account_id, + aal.project_id as project_id, aal.product_id as product_id, aal.user_id as user_id, aal.company_id as company_id, @@ -40,8 +40,8 @@ class hr_timesheet_report(models.Model): def _group_by(self): group_by_str = """ GROUP BY aal.date, - aal.account_id, aal.product_id, + aal.project_id, aal.user_id, aal.company_id, aal.currency_id @@ -50,7 +50,7 @@ class hr_timesheet_report(models.Model): def _where(self): where_str = """ - WHERE aal.is_timesheet IS TRUE + WHERE aal.project_id IS NOT NULL """ return where_str diff --git a/addons/hr_timesheet/report/hr_timesheet_report_view.xml b/addons/hr_timesheet/report/hr_timesheet_report_view.xml index e6807b0a596..302c4a9b4e1 100644 --- a/addons/hr_timesheet/report/hr_timesheet_report_view.xml +++ b/addons/hr_timesheet/report/hr_timesheet_report_view.xml @@ -31,7 +31,7 @@ hr.timesheet.report - + @@ -69,7 +69,7 @@ + parent="timesheet_menu_root" sequence="99" groups="base.group_hr_manager"/> diff --git a/addons/hr_timesheet/security/ir.model.access.csv b/addons/hr_timesheet/security/ir.model.access.csv index 692ecbe0a7f..b23b1c28ce4 100644 --- a/addons/hr_timesheet/security/ir.model.access.csv +++ b/addons/hr_timesheet/security/ir.model.access.csv @@ -5,4 +5,4 @@ access_product_product_user,product.product user,product.model_product_product,b access_product_template_hr_timesheet,product.template.hr.timesheet,product.model_product_template,base.group_hr_user,1,1,1,1 access_product_uom_hr_timesheet,product.uom.hr.timesheet,product.model_product_uom,base.group_hr_user,1,1,1,1 access_account_analytic_line_user,account.analytic.line.user,model_account_analytic_line,base.group_user,1,1,1,0 -access_hr_timesheet_report,hr.timesheet.report,model_hr_timesheet_report,base.group_hr_manager,1,1,0,0 +access_hr_timesheet_report,hr.timesheet.report,model_hr_timesheet_report,base.group_hr_manager,1,1,0,0 diff --git a/addons/hr_attendance/static/description/icon_timesheet.png b/addons/hr_timesheet/static/description/icon_timesheet.png similarity index 100% rename from addons/hr_attendance/static/description/icon_timesheet.png rename to addons/hr_timesheet/static/description/icon_timesheet.png diff --git a/addons/hr_timesheet_sheet/__openerp__.py b/addons/hr_timesheet_sheet/__openerp__.py index fb5f9e42edd..7e3dd877a3d 100644 --- a/addons/hr_timesheet_sheet/__openerp__.py +++ b/addons/hr_timesheet_sheet/__openerp__.py @@ -26,14 +26,13 @@ The validation can be configured in the company: * Maximal difference between timesheet and attendances """, 'website': 'https://www.odoo.com/page/employees', - 'depends': ['hr_timesheet'], + 'depends': ['hr_timesheet', 'hr_attendance'], 'data': [ 'security/ir.model.access.csv', 'security/hr_timesheet_sheet_security.xml', 'hr_timesheet_sheet_view.xml', 'hr_timesheet_workflow.xml', 'report/hr_timesheet_report_view.xml', - 'wizard/hr_timesheet_current_view.xml', 'hr_timesheet_sheet_data.xml', 'views/hr_timesheet_sheet.xml', 'hr_dashboard.xml', diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 2fd148e4232..a1461705454 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -297,7 +297,7 @@ class account_analytic_line(osv.osv): sheet_obj = self.pool.get('hr_timesheet_sheet.sheet') res = {}.fromkeys(ids, False) for ts_line in self.browse(cursor, user, ids, context=context): - if not ts_line.is_timesheet: + if not ts_line.project_id: continue sheet_ids = sheet_obj.search(cursor, user, [('date_to', '>=', ts_line.date), ('date_from', '<=', ts_line.date), @@ -318,7 +318,7 @@ class account_analytic_line(osv.osv): WHERE %(date_to)s >= l.date AND %(date_from)s <= l.date AND %(user_id)s = l.user_id - AND l.is_timesheet = True + AND l.project_id IS NOT NULL GROUP BY l.id""", {'date_from': ts.date_from, 'date_to': ts.date_to, 'user_id': ts.employee_id.user_id.id,}) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml index fc392bdbc6a..14d86a73d25 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml @@ -21,7 +21,7 @@ My Timesheet
- + diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml index 1d425d84a96..4001a4a212c 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml @@ -39,10 +39,13 @@ - {'search_default_sheet_id': [active_id], 'default_is_timesheet' : 1} + {'search_default_sheet_id': [active_id]} Timesheet Activities account.analytic.line hr_timesheet_sheet.sheet + @@ -120,25 +123,21 @@ - + - + - - +
- - - - - - + + +
@@ -217,7 +216,7 @@
- @@ -226,7 +225,7 @@ hr_timesheet_sheet.sheet form - {'search_default_to_approve':1, 'default_is_timesheet':1} + {'search_default_to_approve':1}

@@ -249,7 +248,9 @@ - + + @@ -386,7 +387,7 @@ form Timesheets tree,form - {'search_default_employee_id': [active_id], 'default_employee_id': active_id , 'default_is_timesheet' : 1} + {'search_default_employee_id': [active_id], 'default_employee_id': active_id} diff --git a/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml b/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml index 40f505e3d0d..ddba8d32f00 100644 --- a/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml +++ b/addons/hr_timesheet_sheet/report/hr_timesheet_report_view.xml @@ -35,7 +35,7 @@ hr.timesheet.report - + diff --git a/addons/hr_timesheet_sheet/static/src/js/timesheet.js b/addons/hr_timesheet_sheet/static/src/js/timesheet.js index 51008cc3082..067fcc233eb 100644 --- a/addons/hr_timesheet_sheet/static/src/js/timesheet.js +++ b/addons/hr_timesheet_sheet/static/src/js/timesheet.js @@ -46,7 +46,7 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg var id = JSON.parse($(event.target).data("id")); this.do_action({ type: 'ir.actions.act_window', - res_model: "account.analytic.account", + res_model: "project.project", res_id: id, views: [[false, 'form']], }); @@ -55,13 +55,12 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg if (this.updating) { return; } - + this.querying = true; var commands = this.field_manager.get_field_value("timesheet_ids"); var self = this; this.res_o2m_drop.add(new Model(this.view.model).call("resolve_2many_commands", ["timesheet_ids", commands, [], new data.CompoundContext()])) .done(function(result) { - self.querying = true; self.set({sheets: result}); self.querying = false; }); @@ -107,13 +106,13 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg // it's important to use those vars to avoid race conditions var dates; - var accounts; - var account_names; + var projects; + var project_names; var default_get; var self = this; return this.render_drop.add(new Model("account.analytic.line").call("default_get", [ - ['account_id','general_account_id','journal_id','date','name','user_id','product_id','product_uom_id','amount','unit_amount','is_timesheet'], - new data.CompoundContext({'user_id': self.get('user_id'), 'default_is_timesheet': true}) + ['account_id','general_account_id','journal_id','date','name','user_id','product_id','product_uom_id','amount','unit_amount','project_id'], + new data.CompoundContext({'user_id': self.get('user_id')}) ]).then(function(result) { default_get = result; // calculating dates @@ -125,23 +124,23 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg var m_start = moment(start).add(1, 'days'); start = m_start.toDate(); } - // group by account - accounts = _.chain(self.get("sheets")) + // group by project + projects = _.chain(self.get("sheets")) .map(_.clone) .each(function(el) { // much simpler to use only the id in all cases - if (typeof(el.account_id) === "object") { - el.account_id = el.account_id[0]; + if (typeof(el.project_id) === "object") { + el.project_id = el.project_id[0]; } }) - .groupBy("account_id").value(); + .groupBy("project_id").value(); - var account_ids = _.map(_.keys(accounts), function(el) { return el === "false" ? false : Number(el); }); + var project_ids = _.map(_.keys(projects), function(el) { return el === "false" ? false : Number(el); }); - accounts = _(accounts).chain().map(function(lines, account_id) { - var account_defaults = _.extend({}, default_get, (accounts[account_id] || {}).value || {}); + projects = _(projects).chain().map(function(lines, project_id) { + var projects_defaults = _.extend({}, default_get, (projects[project_id] || {}).value || {}); // group by days - account_id = (account_id === "false")? false : Number(account_id); + project_id = (project_id === "false")? false : Number(project_id); var index = _.groupBy(lines, "date"); var days = _.map(dates, function(date) { var day = {day: date, lines: index[time.date_to_str(date)] || []}; @@ -151,34 +150,34 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg day.lines = _.without(day.lines, to_add); day.lines.unshift(to_add); } else { - day.lines.unshift(_.extend(_.clone(account_defaults), { + day.lines.unshift(_.extend(_.clone(projects_defaults), { name: self.description_line, unit_amount: 0, date: time.date_to_str(date), - account_id: account_id, + project_id: project_id, })); } return day; }); - return {account: account_id, days: days, account_defaults: account_defaults}; + return {project: project_id, days: days, projects_defaults: projects_defaults}; }).value(); - // we need the name_get of the analytic accounts - return new Model("account.analytic.account").call("name_get", [_.pluck(accounts, "account"), + // we need the name_get of the projects + return new Model("project.project").call("name_get", [_.pluck(projects, "project"), new data.CompoundContext()]).then(function(result) { - account_names = {}; + project_names = {}; _.each(result, function(el) { - account_names[el[0]] = el[1]; + project_names[el[0]] = el[1]; }); - accounts = _.sortBy(accounts, function(el) { - return account_names[el.account]; + projects = _.sortBy(projects, function(el) { + return project_names[el.project]; }); }); })).then(function(result) { // we put all the gathered data in self, then we render self.dates = dates; - self.accounts = accounts; - self.account_names = account_names; + self.projects = projects; + self.project_names = project_names; self.default_get = default_get; //real rendering self.display_data(); @@ -206,23 +205,23 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg display_data: function() { var self = this; self.$el.html(QWeb.render("hr_timesheet_sheet.WeeklyTimesheet", {widget: self})); - _.each(self.accounts, function(account) { - _.each(_.range(account.days.length), function(day_count) { + _.each(self.projects, function(project) { + _.each(_.range(project.days.length), function(day_count) { if (!self.get('effective_readonly')) { - self.get_box(account, day_count).val(self.sum_box(account, day_count, true)).change(function() { + self.get_box(project, day_count).val(self.sum_box(project, day_count, true)).change(function() { var num = $(this).val(); if (self.is_valid_value(num) && num !== 0) { num = Number(self.parse_client(num)); } if (isNaN(num)) { - $(this).val(self.sum_box(account, day_count, true)); + $(this).val(self.sum_box(project, day_count, true)); } else { - account.days[day_count].lines[0].unit_amount += num - self.sum_box(account, day_count); - var product = (account.days[day_count].lines[0].product_id instanceof Array) ? account.days[day_count].lines[0].product_id[0] : account.days[day_count].lines[0].product_id; - var journal = (account.days[day_count].lines[0].journal_id instanceof Array) ? account.days[day_count].lines[0].journal_id[0] : account.days[day_count].lines[0].journal_id; + project.days[day_count].lines[0].unit_amount += num - self.sum_box(project, day_count); + var product = (project.days[day_count].lines[0].product_id instanceof Array) ? project.days[day_count].lines[0].product_id[0] : project.days[day_count].lines[0].product_id; + var journal = (project.days[day_count].lines[0].journal_id instanceof Array) ? project.days[day_count].lines[0].journal_id[0] : project.days[day_count].lines[0].journal_id; if(!isNaN($(this).val())){ - $(this).val(self.sum_box(account, day_count, true)); + $(this).val(self.sum_box(project, day_count, true)); } self.display_totals(); @@ -230,16 +229,16 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg } }); } else { - self.get_box(account, day_count).html(self.sum_box(account, day_count, true)); + self.get_box(project, day_count).html(self.sum_box(project, day_count, true)); } }); }); self.display_totals(); if(!this.get('effective_readonly')) { - this.init_add_account(); + this.init_add_project(); } }, - init_add_account: function() { + init_add_project: function() { if (this.dfm) { this.dfm.destroy(); } @@ -248,26 +247,26 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg this.$(".oe_timesheet_weekly_add_row").show(); this.dfm = new form_common.DefaultFieldManager(this); this.dfm.extend_field_desc({ - account: { - relation: "account.analytic.account", + project: { + relation: "project.project", }, }); var FieldMany2One = core.form_widget_registry.get('many2one'); - this.account_m2o = new FieldMany2One(this.dfm, { + this.project_m2o = new FieldMany2One(this.dfm, { attrs: { - name: "account", + name: "project", type: "many2one", domain: [ - ['id', 'not in', _.pluck(this.accounts, "account")], + ['id', 'not in', _.pluck(this.projects, "project")], ], modifiers: '{"required": true}', }, }); - this.account_m2o.prependTo(this.$(".o_add_timesheet_line > div")).then(function() { - self.account_m2o.$el.addClass('oe_edit_only'); + this.project_m2o.prependTo(this.$(".o_add_timesheet_line > div")).then(function() { + self.project_m2o.$el.addClass('oe_edit_only'); }); this.$(".oe_timesheet_button_add").click(function() { - var id = self.account_m2o.get_value(); + var id = self.project_m2o.get_value(); if (id === false) { self.dfm.set({display_invalid_fields: true}); return; @@ -278,19 +277,19 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg name: self.description_line, unit_amount: 0, date: time.date_to_str(self.dates[0]), - account_id: id, + project_id: id, })); self.set({sheets: ops}); self.destroy_content(); }); }, - get_box: function(account, day_count) { - return this.$('[data-account="' + account.account + '"][data-day-count="' + day_count + '"]'); + get_box: function(project, day_count) { + return this.$('[data-project="' + project.project + '"][data-day-count="' + day_count + '"]'); }, - sum_box: function(account, day_count, show_value_in_hour) { + sum_box: function(project, day_count, show_value_in_hour) { var line_total = 0; - _.each(account.days[day_count].lines, function(line) { + _.each(project.days[day_count].lines, function(line) { line_total += line.unit_amount; }); return (show_value_in_hour && line_total !== 0)?this.format_client(line_total):line_total; @@ -299,15 +298,15 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg var self = this; var day_tots = _.map(_.range(self.dates.length), function() { return 0; }); var super_tot = 0; - _.each(self.accounts, function(account) { + _.each(self.projects, function(project) { var acc_tot = 0; _.each(_.range(self.dates.length), function(day_count) { - var sum = self.sum_box(account, day_count); + var sum = self.sum_box(project, day_count); acc_tot += sum; day_tots[day_count] += sum; super_tot += sum; }); - self.$('[data-account-total="' + account.account + '"]').html(self.format_client(acc_tot)); + self.$('[data-project-total="' + project.project + '"]').html(self.format_client(acc_tot)); }); _.each(_.range(self.dates.length), function(day_count) { self.$('[data-day-total="' + day_count + '"]').html(self.format_client(day_tots[day_count])); @@ -330,8 +329,8 @@ var WeeklyTimesheet = form_common.FormWidget.extend(form_common.ReinitializeWidg generate_o2m_value: function() { var ops = []; var ignored_fields = this.ignore_fields(); - _.each(this.accounts, function(account) { - _.each(account.days, function(day) { + _.each(this.projects, function(project) { + _.each(project.days, function(day) { _.each(day.lines, function(line) { if (line.unit_amount !== 0) { var tmp = _.clone(line); diff --git a/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml b/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml index f75bd094cad..d58a477cba0 100644 --- a/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml +++ b/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml @@ -13,19 +13,19 @@ Total - - + + - + - - - + @@ -46,7 +46,7 @@ -

+

Click to add projects, contracts or analytic accounts.

You will be able to register your working hours and activities.

diff --git a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml index ffe000bacf1..e53a8e44549 100644 --- a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml +++ b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml @@ -39,7 +39,7 @@ - !record {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}: timesheet_ids: - - account_id: analytic.analytic_agrolait + - project_id: project.project_project_2 date: !eval time.strftime('%Y-%m-%d') name: 'Develop yaml for hr module' user_id: base.user_demo @@ -47,7 +47,6 @@ amount: -90.00 product_id: product.product_product_1 general_account_id: a_expense - is_timesheet: !eval True - I confirm my Timesheet at end of period by click on "Confirm" button, if the difference between Timesheet hour and attendance hour is more than 1 hour it will give message. @@ -68,7 +67,7 @@ - !record {model: hr_timesheet_sheet.sheet, id: hr_timesheet_sheet_sheet_deddk0}: timesheet_ids: - - account_id: analytic.analytic_agrolait + - project_id: project.project_project_2 date: !eval time.strftime('%Y-%m-%d') name: 'Develop yaml for hr module' unit_amount: 2.00 @@ -76,7 +75,6 @@ amount: -90.00 product_id: product.product_product_1 general_account_id: a_expense - is_timesheet: !eval True - I set an allowed difference of 1 hour - diff --git a/addons/hr_timesheet_sheet/wizard/hr_timesheet_current_view.xml b/addons/hr_timesheet_sheet/wizard/hr_timesheet_current_view.xml deleted file mode 100644 index 403b8a3a26e..00000000000 --- a/addons/hr_timesheet_sheet/wizard/hr_timesheet_current_view.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - hr_timesheet_current_open.form - hr.timesheet.current.open - -
- - - -
-
-
-
-
- - - My Timesheet - hr.timesheet.current.open - form - tree,form - - new - My Timesheet opens your timesheet so that you can book your activities into the system. From the same form, you can register your attendances (Sign In/Out) and describe the working hours made on the different projects. At the end of the period defined in the company, the timesheet is confirmed by the user and can be validated by his manager. If required, as defined on the project, you can generate the invoices based on the timesheet. - - - - -
-
diff --git a/addons/project/company.py b/addons/project/company.py index 5dfb3e0d574..7a08da8071f 100644 --- a/addons/project/company.py +++ b/addons/project/company.py @@ -9,7 +9,7 @@ class res_company(osv.osv): _columns = { 'project_time_mode_id': fields.many2one('product.uom', 'Project Time Unit', help='This will set the unit of measure used in projects and tasks.\n' \ -"If you use the timesheet linked to projects (project_timesheet module), don't " \ +"If you use the timesheet linked to projects, don't " \ "forget to setup the right unit of measure in your employees.", ), } diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 48876926d19..52b8e9f0680 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -265,9 +265,6 @@ - @@ -391,7 +388,6 @@ - diff --git a/addons/project/res_config.py b/addons/project/res_config.py index b5f2b40a27a..657746c7c1b 100644 --- a/addons/project/res_config.py +++ b/addons/project/res_config.py @@ -24,14 +24,6 @@ class project_configuration(osv.osv_memory): help='Lets the company customize which Pad installation should be used to link to new pads ' '(for example: http://ietherpad.com/).\n' '-This installs the module pad.'), - 'module_project_timesheet': fields.selection([ - (0, "Do not record timesheets on tasks"), - (1, "Record timesheet lines per tasks") - ], "Timesheets on Project", - help='This allows you to transfer the entries under tasks defined for Project Management to ' - 'the timesheet line entries for particular date and user, with the effect of creating, ' - 'editing and deleting either ways.\n' - '-This installs the module project_timesheet.'), 'module_rating_project': fields.selection([ (0, "No customer rating"), (1, 'Allow activating customer rating on projects, at issue completion') @@ -58,11 +50,6 @@ class project_configuration(osv.osv_memory): 'module_project_forecast': fields.boolean("Forecasts, planning and Gantt charts"), } - def onchange_time_estimation_project_timesheet(self, cr, uid, ids, group_time_work_estimation_tasks): - if group_time_work_estimation_tasks: - return {'value': {'group_tasks_work_on_tasks': True}} - return {} - def set_default_generate_project_alias(self, cr, uid, ids, context=None): config_value = self.browse(cr, uid, ids, context=context).generate_project_alias self.pool.get('ir.values').set_default(cr, uid, 'project.config.settings', 'generate_project_alias', config_value) diff --git a/addons/project/res_config_view.xml b/addons/project/res_config_view.xml index 470f0cdff60..e860f0b8326 100644 --- a/addons/project/res_config_view.xml +++ b/addons/project/res_config_view.xml @@ -14,7 +14,7 @@ - +