diff --git a/addons/project/project.py b/addons/project/project.py index cc7e226e59d..4cdd80a992e 100644 --- a/addons/project/project.py +++ b/addons/project/project.py @@ -163,6 +163,7 @@ class project(osv.osv): 'task_ids': fields.one2many('project.task', 'project_id', domain=[('stage_id.fold', '=', False)]), 'color': fields.integer('Color Index'), + 'user_id': fields.many2one('res.users', 'Project Manager'), 'alias_id': fields.many2one('mail.alias', 'Alias', ondelete="restrict", required=True, help="Internal email associated with this project. Incoming emails are automatically synchronized " "with Tasks (or optionally Issues if the Issue Tracker module is installed)."), @@ -185,7 +186,9 @@ class project(osv.osv): 'Status', required=True, copy=False), 'doc_count': fields.function( _get_attached_docs, string="Number of documents attached", type='integer' - ) + ), + 'date_start': fields.date('Start Date'), + 'date': fields.date('Expiration Date', select=True, track_visibility='onchange'), } def _get_type_common(self, cr, uid, context): @@ -201,6 +204,7 @@ class project(osv.osv): 'label_tasks': 'Tasks', 'state': 'open', 'sequence': 10, + 'user_id': lambda self,cr,uid,ctx: uid, 'type_ids': _get_type_common, 'alias_model': 'project.task', 'privacy_visibility': 'employees', @@ -257,7 +261,6 @@ class project(osv.osv): data_obj = self.pool.get('ir.model.data') result = [] for proj in self.browse(cr, uid, ids, context=context): - parent_id = context.get('parent_id', False) context.update({'analytic_project_copy': True}) new_date_start = time.strftime('%Y-%m-%d') new_date_end = False @@ -270,15 +273,9 @@ class project(osv.osv): 'name':_("%s (copy)") % (proj.name), 'state':'open', 'date_start':new_date_start, - 'date':new_date_end, - 'parent_id':parent_id}, context=context) + 'date':new_date_end}, context=context) result.append(new_id) - child_ids = self.search(cr, uid, [('parent_id','=', proj.analytic_account_id.id)], context=context) - parent_id = self.read(cr, uid, new_id, ['analytic_account_id'])['analytic_account_id'][0] - if child_ids: - self.duplicate_template(cr, uid, child_ids, context={'parent_id': parent_id}) - if result and len(result): res_id = result[0] form_view_id = data_obj._get_id(cr, uid, 'project', 'edit_project') @@ -308,9 +305,6 @@ class project(osv.osv): tasks_id = [x[0] for x in cr.fetchall()] if tasks_id: task_obj.write(cr, uid, tasks_id, {'active': value}, context=context) - child_ids = self.search(cr, uid, [('parent_id','=', proj.analytic_account_id.id)]) - if child_ids: - self.setActive(cr, uid, child_ids, value, context=None) return True def create(self, cr, uid, vals, context=None): @@ -322,9 +316,6 @@ class project(osv.osv): alias_parent_model_name=self._name, mail_create_nosubscribe=True) - if vals.get('type', False) not in ('template', 'contract'): - vals['type'] = 'contract' - ir_values = self.pool.get('ir.values').get_default(cr, uid, 'project.config.settings', 'generate_project_alias') if ir_values: vals['alias_name'] = vals.get('alias_name') or vals.get('name') @@ -870,8 +861,6 @@ class account_analytic_account(osv.osv): for account in self.browse(cr, uid, ids, context=context): if not vals.get('name'): vals_for_project['name'] = account.name - if not vals.get('type'): - vals_for_project['type'] = account.type self.project_create(cr, uid, account.id, vals_for_project, context=context) return super(account_analytic_account, self).write(cr, uid, ids, vals, context=context) diff --git a/addons/project/project_dashboard.xml b/addons/project/project_dashboard.xml index bcc07510d12..6d650bbd5bf 100644 --- a/addons/project/project_dashboard.xml +++ b/addons/project/project_dashboard.xml @@ -7,7 +7,6 @@ - @@ -68,4 +67,4 @@ - \ No newline at end of file + diff --git a/addons/project/project_data.xml b/addons/project/project_data.xml index b7f44bb3957..e3ea0e030a2 100644 --- a/addons/project/project_data.xml +++ b/addons/project/project_data.xml @@ -18,14 +18,6 @@ project.task - - - Projects - PP001 - view - - - @@ -109,7 +101,6 @@ Discover Odoo - followers project.task diff --git a/addons/project/project_demo.xml b/addons/project/project_demo.xml index 99239df0ee2..a0955435d1d 100644 --- a/addons/project/project_demo.xml +++ b/addons/project/project_demo.xml @@ -49,14 +49,11 @@ open - normal Website for Sales & WMS 3 - portal - Implement new website for Sale and Warehouse Management for a customer. project.task Research & Development - followers project.task @@ -75,7 +71,6 @@ 10 - E-Learning Integration Trainings @@ -85,7 +80,6 @@ 20 - Website Design Templates Designs @@ -96,7 +90,6 @@ 2 - Data Import/Export Plugin Databases diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index 28d6634c4d5..bf1d346344f 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -77,7 +77,7 @@
@@ -116,21 +116,12 @@ - - - @@ -179,7 +170,6 @@ - @@ -190,14 +180,12 @@ project.project child_ids - + - - diff --git a/addons/project/security/ir.model.access.csv b/addons/project/security/ir.model.access.csv index e1e9261d9da..84fea7b5ffe 100644 --- a/addons/project/security/ir.model.access.csv +++ b/addons/project/security/ir.model.access.csv @@ -4,8 +4,6 @@ access_project_project_manager,project.project,model_project_project,project.gro access_account_analytic_account_user,account.analytic.account,analytic.model_account_analytic_account,project.group_project_user,1,0,0,0 access_account_analytic_account_manager,account.analytic.account,analytic.model_account_analytic_account,project.group_project_manager,1,1,1,1 access_account_analytic_account_portal,account_analytic_account,analytic.model_account_analytic_account,base.group_portal,1,0,0,0 -access_account_analytic_journal_project_manager,account.analytic.journal.project.manager,analytic.model_account_analytic_journal,project.group_project_manager,1,1,1,1 -access_account_analytic_journal_project_user,account.analytic.journal.project.user,analytic.model_account_analytic_journal,project.group_project_user,1,1,1,0 access_project_task_type_user,project.task.type.user,model_project_task_type,base.group_user,1,0,0,0 access_project_task_type_project_user,project.task.type.project.user,model_project_task_type,project.group_project_user,1,0,0,0 access_project_task_type_manager,project.task.type manager,model_project_task_type,project.group_project_manager,1,1,1,1 diff --git a/addons/project_issue_sheet/project_issue_sheet.py b/addons/project_issue_sheet/project_issue_sheet.py index f70fd928c13..d55e737f12c 100644 --- a/addons/project_issue_sheet/project_issue_sheet.py +++ b/addons/project_issue_sheet/project_issue_sheet.py @@ -26,7 +26,6 @@ class project_issue(osv.osv): }), 'timesheet_ids': fields.one2many('account.analytic.line', 'issue_id', 'Timesheets'), 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'), - 'contract_state': fields.related('analytic_account_id', 'state', string='Contract Status', type='selection', selection=analytic.ANALYTIC_ACCOUNT_STATE), } def on_change_project(self, cr, uid, ids, project_id, context=None): @@ -42,7 +41,6 @@ class project_issue(osv.osv): account = project.analytic_account_id if account: result['value']['analytic_account_id'] = account.id - result['value']['contract_state'] = account.state return result diff --git a/addons/project_issue_sheet/project_issue_sheet_view.xml b/addons/project_issue_sheet/project_issue_sheet_view.xml index 6ef158b3e35..c137c9891f9 100644 --- a/addons/project_issue_sheet/project_issue_sheet_view.xml +++ b/addons/project_issue_sheet/project_issue_sheet_view.xml @@ -14,13 +14,9 @@ - - - - - - - - - - + diff --git a/addons/project_issue_sheet/security/ir.model.access.csv b/addons/project_issue_sheet/security/ir.model.access.csv index 0450d8fa2b7..4f339d41818 100644 --- a/addons/project_issue_sheet/security/ir.model.access.csv +++ b/addons/project_issue_sheet/security/ir.model.access.csv @@ -4,10 +4,6 @@ access_account_analytic_line_project_user,account_analytic_line user,hr_timeshee access_account_analytic_line_project_manager,account_analytic_line manager,hr_timesheet_sheet.model_account_analytic_line,project.group_project_manager,1,0,0,0 access_hr_timesheet_sheet_sheet_project_manager,hr_timesheet_sheet.sheet manager,hr_timesheet_sheet.model_hr_timesheet_sheet_sheet,project.group_project_manager,1,0,0,0 access_account_analytic_line_project_manager,account.analytic.line.timesheet.project.manager,account.model_account_analytic_line,project.group_project_manager,1,1,1,1 -access_account_analytic_journal_project_manager,account.analytic.journal.project.manager,analytic.model_account_analytic_journal,project.group_project_manager,1,1,1,1 -access_hr_timesheet_invoice_factor_project_manager,hr_timesheet_invoice.factor.project.manager,hr_timesheet_invoice.model_hr_timesheet_invoice_factor,project.group_project_manager,1,1,1,1 access_account_invoice_project_manager,account.invoice.project.manager,account.model_account_invoice,project.group_project_manager,1,1,1,1 access_analytic_account_line_project_user,analytic_account_line_timesheet user,analytic.model_account_analytic_line,project.group_project_user,1,1,1,0 -access_account_analytic_journal_project_user,account.analytic.journal.project.user,analytic.model_account_analytic_journal,project.group_project_user,1,1,1,0 -access_hr_timesheet_invoice_factor_project_user,hr_timesheet_invoice.factor.project.user,hr_timesheet_invoice.model_hr_timesheet_invoice_factor,project.group_project_user,1,1,1,0 access_account_invoice_project_user,account.invoice.project.user,account.model_account_invoice,project.group_project_user,1,1,1,0 diff --git a/addons/project_timesheet/__openerp__.py b/addons/project_timesheet/__openerp__.py index 7700b44dabf..73de0351a59 100644 --- a/addons/project_timesheet/__openerp__.py +++ b/addons/project_timesheet/__openerp__.py @@ -15,13 +15,12 @@ with the effect of creating, editing and deleting either ways. """, 'website': 'https://www.odoo.com/page/project-management', 'images': ['images/invoice_task_work.jpeg', 'images/my_timesheet.jpeg', 'images/working_hour.jpeg'], - 'depends': ['resource', 'project', 'sale_contract'], + 'depends': ['resource', 'project', 'sale_timesheet'], 'data': [ 'security/ir.model.access.csv', 'security/project_timesheet_security.xml', 'report/project_report_view.xml', 'project_timesheet_view.xml', - 'project_dashboard.xml', 'res_config_view.xml', ], 'demo': ['project_timesheet_demo.xml'], diff --git a/addons/project_timesheet/project_dashboard.xml b/addons/project_timesheet/project_dashboard.xml deleted file mode 100644 index aec13ff42c3..00000000000 --- a/addons/project_timesheet/project_dashboard.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - Analytic Account - account.analytic.account - form - form - [] - {} - - - - - project.project.kanban.inherit - project.project - - - - - - - - - - Hours - - - - - - \ No newline at end of file diff --git a/addons/project_timesheet/project_timesheet.py b/addons/project_timesheet/project_timesheet.py index 34c267d17b6..9cfa29bbf30 100644 --- a/addons/project_timesheet/project_timesheet.py +++ b/addons/project_timesheet/project_timesheet.py @@ -13,111 +13,6 @@ from openerp.exceptions import UserError class project_project(osv.osv): _inherit = 'project.project' - def _get_project_and_children(self, cr, uid, ids, context=None): - """ retrieve all children projects of project ids; - return a dictionary mapping each project to its parent project (or None) - """ - res = dict.fromkeys(ids, None) - while ids: - cr.execute(""" - SELECT project.id, parent.id - FROM project_project project, project_project parent, account_analytic_account account - WHERE project.analytic_account_id = account.id - AND parent.analytic_account_id = account.parent_id - AND parent.id IN %s - """, (tuple(ids),)) - dic = dict(cr.fetchall()) - res.update(dic) - ids = dic.keys() - return res - - def _progress_rate(self, cr, uid, ids, names, arg, context=None): - child_parent = self._get_project_and_children(cr, uid, ids, context) - # compute planned_hours, total_hours, effective_hours specific to each project - cr.execute(""" - SELECT project_id, COALESCE(SUM(planned_hours), 0.0), - COALESCE(SUM(total_hours), 0.0), COALESCE(SUM(effective_hours), 0.0) - FROM project_task - LEFT JOIN project_task_type ON project_task.stage_id = project_task_type.id - WHERE project_task.project_id IN %s AND project_task_type.fold = False - GROUP BY project_id - """, (tuple(child_parent.keys()),)) - # aggregate results into res - res = dict([(id, {'planned_hours': 0.0, 'total_hours': 0.0, 'effective_hours': 0.0}) for id in ids]) - for id, planned, total, effective in cr.fetchall(): - # add the values specific to id to all parent projects of id in the result - while id: - if id in ids: - res[id]['planned_hours'] += planned - res[id]['total_hours'] += total - res[id]['effective_hours'] += effective - id = child_parent[id] - # compute progress rates - for id in ids: - if res[id]['total_hours']: - res[id]['progress_rate'] = round(100.0 * res[id]['effective_hours'] / res[id]['total_hours'], 2) - else: - res[id]['progress_rate'] = 0.0 - return res - - def _get_projects_from_tasks(self, cr, uid, task_ids, context=None): - tasks = self.pool.get('project.task').browse(cr, uid, task_ids, context=context) - project_ids = [task.project_id.id for task in tasks if task.project_id] - return self.pool.get('project.project')._get_project_and_parents(cr, uid, project_ids, context) - - def _get_project_and_parents(self, cr, uid, ids, context=None): - """ return the project ids and all their parent projects """ - res = set(ids) - while ids: - cr.execute(""" - SELECT DISTINCT parent.id - FROM project_project project, project_project parent, account_analytic_account account - WHERE project.analytic_account_id = account.id - AND parent.analytic_account_id = account.parent_id - AND project.id IN %s - """, (tuple(ids),)) - ids = [t[0] for t in cr.fetchall()] - res.update(ids) - return list(res) - - def onchange_partner_id(self, cr, uid, ids, part=False, context=None): - res = super(project_project, self).onchange_partner_id(cr, uid, ids, part, context) - if part and res and ('value' in res): - # set Invoice Task Work to 100% - data_obj = self.pool.get('ir.model.data') - data_id = data_obj._get_id(cr, uid, 'hr_timesheet_invoice', 'timesheet_invoice_factor1') - if data_id: - factor_id = data_obj.browse(cr, uid, data_id).res_id - res['value'].update({'to_invoice': factor_id}) - return res - - _columns = { - 'planned_hours': fields.function(_progress_rate, multi="progress", string='Planned Time', help="Sum of planned hours of all tasks related to this project and its child projects.", - store = { - 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), - 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'timesheet_ids', 'stage_id'], 20), - }), - 'effective_hours': fields.function(_progress_rate, multi="progress", string='Time Spent', help="Sum of spent hours of all tasks related to this project and its child projects.", - store = { - 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), - 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'timesheet_ids', 'stage_id'], 20), - }), - 'total_hours': fields.function(_progress_rate, multi="progress", string='Total Time', help="Sum of total hours of all tasks related to this project and its child projects.", - store = { - 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), - 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'timesheet_ids', 'stage_id'], 20), - }), - 'progress_rate': fields.function(_progress_rate, multi="progress", string='Progress', type='float', group_operator="avg", help="Percent of tasks closed according to the total of tasks todo.", - store = { - 'project.project': (_get_project_and_parents, ['tasks', 'parent_id', 'child_ids'], 10), - 'project.task': (_get_projects_from_tasks, ['planned_hours', 'remaining_hours', 'timesheet_ids', 'stage_id'], 20), - }), - } - - _defaults = { - 'invoice_on_timesheets': True, - } - def open_timesheets(self, cr, uid, ids, context=None): """ open Timesheets view """ mod_obj = self.pool.get('ir.model.data') @@ -130,12 +25,6 @@ class project_project(osv.osv): 'default_is_timesheet':True } help = _("""

Record your timesheets for the project '%s'.

""") % (project.name,) - try: - if project.to_invoice and project.partner_id: - help+= _("""

Timesheets on this project may be invoiced to %s, according to the terms defined in the contract.

""" ) % (project.partner_id.name,) - except: - # if the user do not have access rights on the partner - pass res = mod_obj.get_object_reference(cr, uid, 'hr_timesheet', 'act_hr_timesheet_line_evry1_all_form') id = res and res[1] or False @@ -213,7 +102,6 @@ class task(osv.osv): '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), - 'contract_state': fields.related('project_id', 'analytic_account_id', 'state', relation="account.analytic.account", string='Contract Status', type='selection', selection=analytic.ANALYTIC_ACCOUNT_STATE), } _defaults = { @@ -233,7 +121,6 @@ class task(osv.osv): if 'value' not in result: result['value'] = {} project = self.pool['project.project'].browse(cr, uid, project_id, context=context) - result['value']['contract_state'] = project.analytic_account_id.state return result diff --git a/addons/project_timesheet/project_timesheet_demo.xml b/addons/project_timesheet/project_timesheet_demo.xml index 78aade68999..577bab6101e 100644 --- a/addons/project_timesheet/project_timesheet_demo.xml +++ b/addons/project_timesheet/project_timesheet_demo.xml @@ -2,20 +2,11 @@ - - - - - - - - Lisa Jongejans - Building 1, Second Floor +3282623500 @@ -25,20 +16,16 @@ Martin Lawrence - - Jimmy Kosikin - Alice Englert - Building 1, Second Floor +3282823500 alice@openerp.com @@ -48,7 +35,6 @@ - diff --git a/addons/project_timesheet/project_timesheet_view.xml b/addons/project_timesheet/project_timesheet_view.xml index eba621401fc..b63032805a6 100644 --- a/addons/project_timesheet/project_timesheet_view.xml +++ b/addons/project_timesheet/project_timesheet_view.xml @@ -2,62 +2,14 @@ - - project.project.tree.inherited - project.project - - - - - - - - - - - Inherit project form : Invoicing Data project.project - - 0 - - - - - -

- To invoice or setup invoicing and renewal options, go to the related contract: - . -

-
- - - -
-
- - - -
-
- - - Inherit project search view : Invoicing Data - project.project - - - - - @@ -98,45 +50,6 @@
- - - Invoice Tasks - account.analytic.line - form - tree,form,pivot - [] - {'search_default_to_invoice': 1} - - -

- You will find here timesheets and purchases you did for contracts that can be reinvoiced to the customer. - If you want to record new jobs to invoice, you should use the timesheet menu instead. -

-
-
- - - - - Customer Projects - account.analytic.account - form - tree,form,graph - {} - [('type','=','normal')] - - -

- Click to add a customer contract. -

- You will find here the contracts related to your customer - projects in order to track the invoicing progress. -

-
-
- project.task.form.inherited project.task @@ -145,10 +58,6 @@ onchange_project(project_id) - - - - - - - - - - - + + diff --git a/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml b/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml index c677ebc5310..861b91ee458 100644 --- a/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml +++ b/addons/project_timesheet/test/worktask_entry_to_timesheetline_entry.yml @@ -12,7 +12,6 @@ - !record {model: product.product, id: product_product_hrmanger0}: categ_id: product.product_category_5 - mes_type: fixed name: HR Manager standard_price: 1.0 type: service @@ -21,13 +20,6 @@ volume: 0.0 warranty: 0.0 weight: 0.0 -- - Create an analytic journal for employees timesheet -- - !record {model: account.analytic.journal, id: account_analytic_journal_hrtimesheet0}: - company_id: base.main_company - name: HR Timesheet - type: general - Create a financial account - @@ -41,8 +33,6 @@ !record {model: hr.employee, id: hr_employee_hrmanager0}: name: HR Manager user_id: res_users_hrmanager0 - product_id: product_product_hrmanger0 - journal_id: account_analytic_journal_hrtimesheet0 - Create a project 'Timesheet Management' - @@ -69,5 +59,5 @@ name: Get work calendar of all employees user_id: res_users_hrmanager0 account_id: analytic.analytic_administratif - journal_id: account_analytic_journal_hrtimesheet0 general_account_id: financial_account0 + product_id: product_product_hrmanger0