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