diff --git a/service_event_base/__init__.py b/service_event_base/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/service_event_base/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/service_event_base/__manifest__.py b/service_event_base/__manifest__.py new file mode 100644 index 0000000..dcd04d0 --- /dev/null +++ b/service_event_base/__manifest__.py @@ -0,0 +1,20 @@ +{ + 'name': 'Event & Service Management - Base', + 'version': '1.0', + 'category': 'Services', + 'sequence': 2, + 'summary': 'for event and service booking system', + 'description': """Event/Service management.""", + 'depends': ['base','mail','event'], + 'data': [ + 'security/ir.model.access.csv', + 'views/service_event_base.xml', + # 'views/service_event_category_views.xml', + # 'views/service_event_registration_views.xml', + # 'views/service_event_views.xml', + ], + 'author': 'sujal asodariya', + 'installable': True, + 'application': True, + 'license': 'LGPL-3', +} diff --git a/service_event_base/data/data.xml b/service_event_base/data/data.xml new file mode 100644 index 0000000..c21accd --- /dev/null +++ b/service_event_base/data/data.xml @@ -0,0 +1,18 @@ + + + + + + + + \ No newline at end of file diff --git a/service_event_base/models/__init__.py b/service_event_base/models/__init__.py new file mode 100644 index 0000000..645f9b6 --- /dev/null +++ b/service_event_base/models/__init__.py @@ -0,0 +1,5 @@ +# from . import event_category +from . import event_registration +from . import event_service +# from . import event_tag + diff --git a/service_event_base/models/event_registration.py b/service_event_base/models/event_registration.py new file mode 100644 index 0000000..27bdc75 --- /dev/null +++ b/service_event_base/models/event_registration.py @@ -0,0 +1,36 @@ +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError + + +class EventRegistration(models.Model): + _name = 'event.registrations' + _description = 'Event Registration' + + name = fields.Char('Name', required=True) + state = fields.Selection([ + ('draft', 'Draft'), + ('confirmed', 'Confirmed'), + ('cancelled', 'Cancelled') + ], 'Status', default='draft', required=True) + active = fields.Boolean('Active', default=True) + + booking_date = fields.Datetime('Booking Date', default=fields.Datetime.now) + booking_amount = fields.Monetary('Booking Amount', currency_field='currency_id', compute='_compute_booking_amount', store=True, readonly=True) + + service_id = fields.Many2one('event.service', 'Event Service', ondelete='cascade', required=True) + partner_id = fields.Many2one('res.partner', 'Partner', index=True) + currency_id = fields.Many2one('res.currency', 'Currency', related='service_id.currency_id', readonly=True) + company_id = fields.Many2one('res.company', 'Company', related='service_id.company_id', store=True, readonly=True) + + # Compute fields + @api.depends('service_id') + def _compute_booking_amount(self): + for record in self: + record.booking_amount = record.service_id.price + + # Python constrains + @api.constrains('booking_date') + def _check_booking_date(self): + for record in self: + if record.booking_date and record.booking_date < fields.Datetime.now(): + raise ValidationError(_("Booking date cannot be in the previous one.")) diff --git a/service_event_base/models/event_service.py b/service_event_base/models/event_service.py new file mode 100644 index 0000000..01c7d8c --- /dev/null +++ b/service_event_base/models/event_service.py @@ -0,0 +1,49 @@ +from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError + + +class EventService(models.Model): + _name = 'event.service' + _description = 'Event Management Service' + + name = fields.Char('Event Name', required=True) + description = fields.Html('Description') + price = fields.Monetary('Price', currency_field='currency_id') + active = fields.Boolean('Active', default=True) + start_date = fields.Datetime('Start Date') + end_date = fields.Datetime('End Date') + + event_type_id = fields.Many2one('event.type', 'Event Type', ondelete='set null', index=True) + company_id = fields.Many2one('res.company', required=True, default=lambda self: self.env.company) + booking_ids = fields.One2many('event.registrations', 'service_id', 'Bookings') + + currency_id = fields.Many2one('res.currency', 'Currency', default=lambda self: self.company_id.currency_id, readonly=True) + + @api.constrains('start_date', 'end_date') + def _check_dates(self): + for record in self: + if record.start_date and record.end_date and record.end_date <= record.start_date: + raise ValidationError(_('End date must be after start date.')) + + @api.constrains('price') + def _check_price(self): + for record in self: + if record.price < 0: + raise ValidationError(_('Price must be zero or positive.')) + + @api.onchange('price') + def _onchange_price(self): + if self.price and self.price < 0: + self.price = 0 + return { + 'warning': { + 'title': _('Invalid Price'), + 'message': _('Price cannot be negative.'), + } + } + + @api.model_create_multi + def create(self, vals_list): + records = super().create(vals_list) + #logic here write + return records diff --git a/service_event_base/security/ir.model.access.csv b/service_event_base/security/ir.model.access.csv new file mode 100644 index 0000000..20ab511 --- /dev/null +++ b/service_event_base/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_event_management_user,access.event.service.user,model_event_service,base.group_user,1,1,1,1 +access_event_registrations_user,access.event.registrations.user,model_event_registrations,base.group_user,1,1,1,1 diff --git a/service_event_base/static/description/image.jpeg b/service_event_base/static/description/image.jpeg new file mode 100644 index 0000000..a8b61ce Binary files /dev/null and b/service_event_base/static/description/image.jpeg differ diff --git a/service_event_base/views/service_event_base.xml b/service_event_base/views/service_event_base.xml new file mode 100644 index 0000000..4f13532 --- /dev/null +++ b/service_event_base/views/service_event_base.xml @@ -0,0 +1,26 @@ + + + + + Service Events + event.service + list + +

+ No service events found +

+
+
+ + + + +