From 270c4732f4f5017a25e327bcc5f273dfd818493f Mon Sep 17 00:00:00 2001 From: Kartik Chavda Date: Fri, 31 Mar 2023 06:58:06 +0000 Subject: [PATCH] [REF] {hr,sale}_timesheet: refactor timesheet form view Before this commit timesheet community and enterprise form view where different from each other because of that if we want to change something in timesheet form we have to do change in both view and sometimes it is hard to keep track of both view. This commit use single form view in both community and enterprise so it'll easier to change something in timesheet form view and it'll remove some technical debt. task-3255754 closes odoo/odoo#117748 Related: odoo/enterprise#39343 Related: odoo/upgrade#4520 Signed-off-by: Xavier Bol (xbo) --- .../hr_timesheet/views/hr_timesheet_views.xml | 17 ++++++++------ addons/sale_timesheet/models/account.py | 22 +++++++++++++++++++ .../views/hr_timesheet_views.xml | 18 +++++++++++++++ 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/addons/hr_timesheet/views/hr_timesheet_views.xml b/addons/hr_timesheet/views/hr_timesheet_views.xml index 5419a14179a..9d6a1d296ff 100644 --- a/addons/hr_timesheet/views/hr_timesheet_views.xml +++ b/addons/hr_timesheet/views/hr_timesheet_views.xml @@ -9,8 +9,9 @@ - - + + @@ -123,10 +124,10 @@ - - - + @@ -138,6 +139,7 @@ + @@ -151,8 +153,9 @@ 10 - - + + diff --git a/addons/sale_timesheet/models/account.py b/addons/sale_timesheet/models/account.py index 4b0cae00927..6b14da6a153 100644 --- a/addons/sale_timesheet/models/account.py +++ b/addons/sale_timesheet/models/account.py @@ -168,3 +168,25 @@ class AccountAnalyticLine(models.Model): if mapping_entry: return mapping_entry.cost return super()._hourly_cost() + + def action_sale_order_from_timesheet(self): + self.ensure_one() + return { + 'type': 'ir.actions.act_window', + 'name': _('Sale Order'), + 'res_model': 'sale.order', + 'views': [[False, 'form']], + 'context': {'create': False, 'show_sale': True}, + 'res_id': self.order_id.id, + } + + def action_invoice_from_timesheet(self): + self.ensure_one() + return { + 'type': 'ir.actions.act_window', + 'name': _('Invoice'), + 'res_model': 'account.move', + 'views': [[False, 'form']], + 'context': {'create': False}, + 'res_id': self.timesheet_invoice_id.id, + } diff --git a/addons/sale_timesheet/views/hr_timesheet_views.xml b/addons/sale_timesheet/views/hr_timesheet_views.xml index b9b5beb31fe..3cef8f3d2b1 100644 --- a/addons/sale_timesheet/views/hr_timesheet_views.xml +++ b/addons/sale_timesheet/views/hr_timesheet_views.xml @@ -61,6 +61,24 @@ + + + + +
+ + +
+
+