From a291d2f389d27c7a4c43e3097c2b63df3b0c531b Mon Sep 17 00:00:00 2001 From: Henrik Norlin Date: Wed, 30 Aug 2023 14:10:16 +0200 Subject: [PATCH] [IMP] resource_booking: Partner button --- resource_booking/__manifest__.py | 1 + resource_booking/models/__init__.py | 1 + resource_booking/models/res_partner.py | 20 ++++++++++++++++++++ resource_booking/views/res_partner_views.xml | 16 ++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 resource_booking/models/res_partner.py create mode 100644 resource_booking/views/res_partner_views.xml diff --git a/resource_booking/__manifest__.py b/resource_booking/__manifest__.py index 1c757ee1..41ab6ebe 100644 --- a/resource_booking/__manifest__.py +++ b/resource_booking/__manifest__.py @@ -33,6 +33,7 @@ "security/ir.model.access.csv", "templates/portal.xml", "views/calendar_event_views.xml", + "views/res_partner_views.xml", "views/resource_booking_combination_views.xml", "views/resource_booking_type_views.xml", "views/resource_booking_views.xml", diff --git a/resource_booking/models/__init__.py b/resource_booking/models/__init__.py index 38ad3480..c75cebc1 100644 --- a/resource_booking/models/__init__.py +++ b/resource_booking/models/__init__.py @@ -1,4 +1,5 @@ from . import calendar_event +from . import res_partner from . import resource_booking from . import resource_booking_combination from . import resource_booking_type diff --git a/resource_booking/models/res_partner.py b/resource_booking/models/res_partner.py new file mode 100644 index 00000000..e10248f1 --- /dev/null +++ b/resource_booking/models/res_partner.py @@ -0,0 +1,20 @@ +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + resource_booking_count = fields.Integer(compute='_compute_resource_booking_count', string='Resource Booking Count') + resource_booking_ids = fields.One2many('resource.booking', "partner_id", string="Bookings") + + def _compute_resource_booking_count(self): + for p in self: + p.resource_booking_count = len(p.resource_booking_ids) + + def action_view_resource_booking_timeline(self): + self.ensure_one() + action = self.env["ir.actions.actions"]._for_xml_id("resource_booking.resource_booking_action") + action['context'] = { + 'default_partner_id': self.id, + } + return action diff --git a/resource_booking/views/res_partner_views.xml b/resource_booking/views/res_partner_views.xml new file mode 100644 index 00000000..2762e309 --- /dev/null +++ b/resource_booking/views/res_partner_views.xml @@ -0,0 +1,16 @@ + + + + res.partner + form + + +
+ +
+
+
+ +
\ No newline at end of file