From fa88c5fd04e7d7e86c7a4fb182ba8bcf4ebf8ad9 Mon Sep 17 00:00:00 2001 From: "Cedric Prieels (cpr)" Date: Thu, 2 Sep 2021 12:55:43 +0200 Subject: [PATCH] [ADD] account_sale_timesheet: extends project form and panel This commit adds a bridge module in order to extend the project form and panel. PR : #72736 See odoo/upgrade#2706 task-2545084 --- addons/account_sale_timesheet/__init__.py | 4 +++ addons/account_sale_timesheet/__manifest__.py | 19 ++++++++++++++ .../account_sale_timesheet/models/__init__.py | 4 +++ .../account_sale_timesheet/models/project.py | 26 +++++++++++++++++++ .../views/project_project_views.xml | 26 +++++++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 addons/account_sale_timesheet/__init__.py create mode 100644 addons/account_sale_timesheet/__manifest__.py create mode 100644 addons/account_sale_timesheet/models/__init__.py create mode 100644 addons/account_sale_timesheet/models/project.py create mode 100644 addons/account_sale_timesheet/views/project_project_views.xml diff --git a/addons/account_sale_timesheet/__init__.py b/addons/account_sale_timesheet/__init__.py new file mode 100644 index 00000000000..dc5e6b693d1 --- /dev/null +++ b/addons/account_sale_timesheet/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models diff --git a/addons/account_sale_timesheet/__manifest__.py b/addons/account_sale_timesheet/__manifest__.py new file mode 100644 index 00000000000..792e8e8fb86 --- /dev/null +++ b/addons/account_sale_timesheet/__manifest__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + + +{ + 'name': 'Account Sale Timesheet', + 'version': '1.0', + 'category': 'Account/sale/timesheet', + 'summary': 'Account sale timesheet', + 'description': 'Bridge created to add the number of invoices linked to an AA to a project form', + 'depends': ['account', 'sale_timesheet'], + 'data': [ + 'views/project_project_views.xml', + ], + 'demo': [], + 'installable': True, + 'auto_install': True, + 'license': 'OEEL-1', +} diff --git a/addons/account_sale_timesheet/models/__init__.py b/addons/account_sale_timesheet/models/__init__.py new file mode 100644 index 00000000000..527e2954c06 --- /dev/null +++ b/addons/account_sale_timesheet/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import project diff --git a/addons/account_sale_timesheet/models/project.py b/addons/account_sale_timesheet/models/project.py new file mode 100644 index 00000000000..d8086b57a4c --- /dev/null +++ b/addons/account_sale_timesheet/models/project.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import fields, models, _ + +class Project(models.Model): + _inherit = 'project.project' + + invoice_count = fields.Integer(related='analytic_account_id.invoice_count') + + # ---------------------------- + # Project Updates + # ---------------------------- + + def _get_stat_buttons(self): + buttons = super(Project, self)._get_stat_buttons() + buttons.append({ + 'icon': 'pencil-square-o', + 'text': _('Invoices'), + 'number': self.invoice_count, + 'action_type': 'object', + 'action': 'action_open_project_invoices', + 'show': self.user_has_groups('account.group_account_readonly') and bool(self.analytic_account_id) and self.invoice_count > 0, + 'sequence': 11, + }) + return buttons diff --git a/addons/account_sale_timesheet/views/project_project_views.xml b/addons/account_sale_timesheet/views/project_project_views.xml new file mode 100644 index 00000000000..77a119d9b6a --- /dev/null +++ b/addons/account_sale_timesheet/views/project_project_views.xml @@ -0,0 +1,26 @@ + + + + + project.project.form.inherit + project.project + + + + + + + + +