diff --git a/cab_booking_management/__openerp__.py b/cab_booking_management/__openerp__.py index e8f8126a6..f7f5e47f3 100644 --- a/cab_booking_management/__openerp__.py +++ b/cab_booking_management/__openerp__.py @@ -22,11 +22,11 @@ ############################################################################## { 'name': "Cab Booking Management System", + 'version': '9.0.1.0.0', 'summary': """Complete Cab Booking Management and its Related Records""", 'author': "Cybrosys Techno Solutions", 'website': "http://www.cybrosys.com", - 'category': 'Tools', - 'version': '0.1', + 'category': 'Industries', 'depends': ['base', 'mail'], 'data': [ 'views/templates.xml', @@ -40,7 +40,6 @@ 'security/ir.model.access.csv' ], 'images': ['static/description/banner.jpg'], - 'license': 'AGPL-3', 'installable': True, 'auto_install': False, 'application': True, diff --git a/cab_booking_management/__openerp__.py~ b/cab_booking_management/__openerp__.py~ deleted file mode 100644 index 97a81eae4..000000000 --- a/cab_booking_management/__openerp__.py~ +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# Cybrosys Technologies Pvt. Ltd. -# Copyright (C) 2008-TODAY Cybrosys Technologies(). -# Author: Nilmar Shereef() -# you can modify it under the terms of the GNU LESSER -# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. -# -# It is forbidden to publish, distribute, sublicense, or sell copies -# of the Software or modified copies of the Software. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. -# -# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE -# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. -# If not, see . -# -############################################################################## -{ - 'name': "Cab Booking Management System", - 'summary': """Complete Cab Booking Management and its Related Records""", - 'author': "Cybrosys", - 'website': "http://www.cybrosys.com", - 'category': 'Tools', - 'version': '0.1', - 'depends': ['base', 'mail'], - 'data': [ - 'views/templates.xml', - 'views/cab_log_view.xml', - 'views/cab_conf_view.xml', - 'views/cab_location_view.xml', - 'views/cab_timing_view.xml', - 'views/cab_booking_view.xml', - 'views/cab_creation_view.xml', - 'views/cab_maintanence_view.xml', - 'security/ir.model.access.csv' - ], - 'images': ['static/description/banner.jpg'], - 'license': 'AGPL-3', - 'installable': True, - 'auto_install': False, - 'application': True, -} diff --git a/cab_booking_management/models/cab_booking.py b/cab_booking_management/models/cab_booking.py index 32921ed37..d8f3e6a9f 100644 --- a/cab_booking_management/models/cab_booking.py +++ b/cab_booking_management/models/cab_booking.py @@ -21,21 +21,24 @@ # ############################################################################## from openerp import models, fields, api +from datetime import date class CabBooking(models.Model): _name = 'cab.booking' _rec_name = 'booking_date' - booking_date = fields.Date(string="Booking Date", required=True) + booking_date = fields.Date(string="Booking Date", default=date.today(), required=True) cab_timing = fields.Many2one('cab.time', string="Timing", required=True) - cab_routes = fields.Many2one('cab.location', string="Route", required=True) + cab_routes = fields.Many2one('cab.location', string="Route From", required=True) + cab_routes_to = fields.Many2one('cab.location', string="Route To", required=True) seat_available = fields.One2many('cab.timing', compute="scheduled_details") - @api.onchange('cab_routes', 'cab_timing') + @api.onchange('cab_routes', 'cab_timing', 'cab_routes_to') def scheduled_details(self): data = self.env['cab.timing'].search([('cab_route.name', '=', self.cab_routes.name), - ('cab_time.name', '=', self.cab_timing.name)]) + ('cab_time.name', '=', self.cab_timing.name), + ('cab_route_to.name', '=', self.cab_routes_to.name)]) self.seat_available = data diff --git a/cab_booking_management/models/cab_creation.py b/cab_booking_management/models/cab_creation.py index 3dc562936..435f81606 100644 --- a/cab_booking_management/models/cab_creation.py +++ b/cab_booking_management/models/cab_creation.py @@ -22,12 +22,14 @@ ############################################################################## from openerp import models, fields, api +from openerp.exceptions import UserError,ValidationError class CabManagement(models.Model): _name = 'cab.management' - name = fields.Char(string="Cab Name", required=True) + name = fields.Char(compute="complete_name_compute", string="Cab Name") + ref_name = fields.Char(string="Cab Name", required=True) cab_image = fields.Binary(string='Image', store=True, attachment=True) licence_plate = fields.Char(string="Licence Plate", required=True) activity_period_from = fields.Date(string="Activity Period") @@ -45,20 +47,45 @@ class CabManagement(models.Model): total_log_details = fields.One2many('cab.maintanence', string='Total Expenses', compute="auto_fetch_total_details") location_log_details = fields.One2many('cab.log', string="Location", compute="auto_fetch_location_details") + @api.onchange('licence_plate') + def check_unique_constraint(self): + for records in self.env['cab.management'].search([]): + if self.licence_plate == records.licence_plate: + raise ValidationError("Record already exists and violates unique field constraint") + + @api.one + def complete_name_compute(self): + self.name = self.ref_name + if self.licence_plate: + self.name = str(self.licence_plate) + ' / ' + str(self.ref_name) + @api.onchange('activity_period_from', 'activity_period_to') def auto_fetch_log_details(self): - data = self.env['cab.log'].search([("cab_log_date", ">=", self.activity_period_from), - ("cab_log_date", "<=", self.activity_period_to)]) - self.related_log_details = data + if self.activity_period_from and self.activity_period_to: + if self.activity_period_from <= self.activity_period_to: + data = self.env['cab.log'].search([("cab_log_date", ">=", self.activity_period_from), + ("cab_log_date", "<=", self.activity_period_to)]) + self.related_log_details = data + else: + self.activity_period_to = 0 + raise UserError("Enter Valid Dates") @api.onchange('activity_period_from', 'activity_period_to') def auto_fetch_total_details(self): - data = self.env['cab.maintanence'].search([("cab_log_date", ">=", self.activity_period_from), - ("cab_log_date", "<=", self.activity_period_to)]) - self.total_log_details = data + if self.activity_period_from and self.activity_period_to: + if self.activity_period_from <= self.activity_period_to: + data = self.env['cab.maintanence'].search([("cab_log_date", ">=", self.activity_period_from), + ("cab_log_date", "<=", self.activity_period_to)]) + self.total_log_details = data + else: + raise UserError("Enter Valid Dates") @api.onchange('activity_period_from', 'activity_period_to') def auto_fetch_location_details(self): - data = self.env['cab.log'].search([("cab_log_date", ">=", self.activity_period_from), - ("cab_log_date", "<=", self.activity_period_to)]) - self.location_log_details = data + if self.activity_period_from and self.activity_period_to: + if self.activity_period_from <= self.activity_period_to: + data = self.env['cab.log'].search([("cab_log_date", ">=", self.activity_period_from), + ("cab_log_date", "<=", self.activity_period_to)]) + self.location_log_details = data + else: + raise UserError("Enter Valid Dates") diff --git a/cab_booking_management/models/cab_log.py b/cab_booking_management/models/cab_log.py index 46c914537..c2c94f9ba 100644 --- a/cab_booking_management/models/cab_log.py +++ b/cab_booking_management/models/cab_log.py @@ -21,9 +21,9 @@ # ############################################################################## -from openerp import models, fields, api -from openerp.tools.translate import _ -from openerp.exceptions import UserError +from openerp import models, fields, api, _ +from openerp.exceptions import ValidationError +from datetime import date class CabLog(models.Model): @@ -31,20 +31,20 @@ class CabLog(models.Model): _inherit = ['mail.thread', 'ir.needaction_mixin'] _description = 'Cab' - name = fields.Many2one('cab.management', string="Name", required=True) - cab_log_date = fields.Date(string="Date", required=True) - fuel_used = fields.Float(string="Fuel Used", required=True) + name = fields.Many2one('cab.management', string="Name", store=True, required=True) + cab_log_date = fields.Date(string="Date", default=date.today(), required=True) + fuel_used = fields.Float(string="Fuel Used", required=True, help="To get total fuel used in Litre") seat_capacity = fields.Integer(string="Seat Capacity", related="name.seating_capacity") seat_available = fields.Integer(string="Seat Available") - cab_location = fields.Many2one('cab.location', string="Location", required=True) - seat_booked = fields.Integer(string="Seat Booked", required=True) - odo_metre = fields.Float(string="OdoMetre Reading", required=True) + cab_location = fields.Char(string="Destination Point", required=True) + cab_location_from = fields.Char(string="Starting Point", required=True) + seat_booked = fields.Integer(string="How many seats you need to book?", required=True) + odo_metre = fields.Float(string="OdoMetre Reading", required=True, help="Total distance covered in Km") cab_expense = fields.Float(string="Expense", required=True) - cab_log_timing = fields.Many2one('cab.time', string="Timing", required=True) + cab_log_timing = fields.Many2one('cab.time', string="Time", required=True) total_passenger = fields.Integer(string="Total Passenger", required=True) - partner_id = fields.Many2one('res.users', string="User Name", required=True) + partner_id = fields.Many2one('res.users', string="Customer Name", required=True) cab_image = fields.Binary(string='Image', store=True, attachment=True) - seat_check = fields.Integer(string='Seat Condition Check') state = fields.Selection([ ('draft', 'Draft'), ('approved', 'Approved'), @@ -53,17 +53,32 @@ class CabLog(models.Model): ('done', 'Done') ], default='draft') - @api.onchange('seat_booked') - def auto_fill_passenger_field(self): - if self.seat_available < self.seat_booked: - self.seat_check = 1 + @api.onchange('name') + def change_location(self): + for records in self.env['cab.timing'].search([('name.name', '=', self.name.name)]): + if self.name.name == records.name.name: + self.cab_location = records.cab_route_to.name + self.cab_location_from = records.cab_route.name - @api.onchange('total_passenger') + @api.one + @api.constrains('cab_log_timing') + def change_time(self): + for records in self.env['cab.timing'].search([('name.name', '=', self.name.name)]): + if self.cab_log_timing: + if self.cab_log_timing not in records.cab_time: + raise ValidationError("No cabs available at given time") + + @api.one + @api.constrains('seat_booked') def error_message(self): - if self.seat_check == 1: - raise UserError("Sorry,No Available Seats") + if self.seat_available < self.seat_booked: + raise ValidationError("No Available Seats") elif self.seat_booked != self.total_passenger: - raise UserError("Sorry, No of seat requested for booking and total passenger must be equal") + raise ValidationError("No of seat requested for booking and total passenger must be equal") + + @api.onchange('seat_booked') + def change_total_passenger(self): + self.total_passenger = self.seat_booked @api.one def action_approve(self): @@ -85,23 +100,22 @@ class CabLog(models.Model): if user_obj == data.cab_manager: self.state = 'approved' - @api.onchange('cab_log_date', 'name', 'seat_booked') + @api.onchange('cab_log_date', 'name', 'cab_log_timing') def change_available_seat(self): - for data in self.env['cab.management'].search([]): - if self.name.name == data.name: - flag = 0 - total_seat_booked = 0 - for records in self.env['cab.log'].search([]): - if self.cab_log_date == records.cab_log_date: + for data in self.env['cab.management'].search([('name', '=', self.name.name)]): + flag = 0 + total_seat_booked = 0 + for records in self.env['cab.log'].search([('name.name', '=', data.name)]): + if self.cab_log_date == records.cab_log_date and self.cab_log_timing == records.cab_log_timing: + if self.cab_location == records.cab_location and self.cab_location_from == records.cab_location_from: total_seat_booked = total_seat_booked+records.seat_booked flag += 1 + if flag > 0: + test_val = self.seat_capacity - total_seat_booked + self.seat_available = test_val - if flag > 0: - test_val = self.seat_capacity - total_seat_booked - self.seat_available = test_val - - else: - self.seat_available = self.seat_capacity + else: + self.seat_available = self.seat_capacity @api.multi def action_sent(self): @@ -116,7 +130,6 @@ class CabLog(models.Model): except ValueError: compose_form_id = False ctx = dict() - print self.ids[0] ctx.update({ 'default_model': 'cab.log', 'default_res_id': self.ids[0], diff --git a/cab_booking_management/models/cab_timing.py b/cab_booking_management/models/cab_timing.py index 39afdd760..c3c5b8b39 100644 --- a/cab_booking_management/models/cab_timing.py +++ b/cab_booking_management/models/cab_timing.py @@ -29,7 +29,8 @@ class CabTiming(models.Model): name = fields.Many2one('cab.management', string="Cab Name", required=True) cab_time = fields.Many2many('cab.time', 'cab_name_rel', string="Time", required=True, help="Use this format 00:00,ex: 01:15") - cab_route = fields.Many2one('cab.location', string='Route', required=True) + cab_route = fields.Many2one('cab.location', string='Starting Place', required=True) + cab_route_to = fields.Many2one('cab.location', string='Destination Place', required=True) seat = fields.Integer(string="Seating Capacity", related='name.seating_capacity', required=True) @api.multi diff --git a/cab_booking_management/static/description/cab_activity.png b/cab_booking_management/static/description/cab_activity.png index 2bb7b4847..634061a3a 100644 Binary files a/cab_booking_management/static/description/cab_activity.png and b/cab_booking_management/static/description/cab_activity.png differ diff --git a/cab_booking_management/static/description/cab_booking.png b/cab_booking_management/static/description/cab_booking.png index 7232f8ce5..c32d9b4bc 100644 Binary files a/cab_booking_management/static/description/cab_booking.png and b/cab_booking_management/static/description/cab_booking.png differ diff --git a/cab_booking_management/static/description/cab_cancel.png b/cab_booking_management/static/description/cab_cancel.png index 4b7478d2e..3910fcab6 100644 Binary files a/cab_booking_management/static/description/cab_cancel.png and b/cab_booking_management/static/description/cab_cancel.png differ diff --git a/cab_booking_management/static/description/cab_creation.png b/cab_booking_management/static/description/cab_creation.png index c416bf057..37cd3ea4a 100644 Binary files a/cab_booking_management/static/description/cab_creation.png and b/cab_booking_management/static/description/cab_creation.png differ diff --git a/cab_booking_management/static/description/cab_maintain.png b/cab_booking_management/static/description/cab_maintain.png new file mode 100644 index 000000000..fca3bf2a8 Binary files /dev/null and b/cab_booking_management/static/description/cab_maintain.png differ diff --git a/cab_booking_management/static/description/index.html b/cab_booking_management/static/description/index.html index 1d0cf7367..d0452dae4 100644 --- a/cab_booking_management/static/description/index.html +++ b/cab_booking_management/static/description/index.html @@ -86,7 +86,7 @@

- It shows the total expenses for a cab, on daily basis. + It shows the expenses for a cab, on daily basis.

@@ -124,6 +124,22 @@ +
+
+

Cab Maintenance

+
+

+ It shows the total expenses for a cab, on daily basis. +

+
+
+
+ +
+
+
+
+

View All Cab Activities with Advanced Filttrations

diff --git a/cab_booking_management/static/description/index.html~ b/cab_booking_management/static/description/index.html~ deleted file mode 100644 index 03a195c09..000000000 --- a/cab_booking_management/static/description/index.html~ +++ /dev/null @@ -1,161 +0,0 @@ -
-
-

Cab Booking Management System (CBMS)

-

Manage the cabs with ease

-

Cybrosys Technologies , www.cybrosys.com

-
-

Major Features:

-
    -
  •   Booking the Cab.
  • -
  •   Auto approval Settings in Configuration.
  • -
  •   Cab Logs for Every Trip.
  • -
  •   Record Every Activity Related to CBMS.
  • -
  •   Email Notification for Successful Booking.
  • -
  •   Booking Status.
  • -
  •   View All Cab Activities with Advanced Filttrations.
  • -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-

Cab Booking

-
-

- We can book cabs from list of cabs based on your time and location. -

-
-
-
- -
-
-
-
- -
-
-

Auto approval

-
-
- -
-
-
-

- Approve cab booking automatically. -

-
-
-
- -
-
-

Cab Logs for Every Trip

-
-

- It keep the record of all expenses of each cab trips. -

-
-
-
- -
-
-
-
- -
-
-

Record Every Activity Related to CBMS

-
-
- -
-
-
-

- It shows the total expenses for a cab, on daily basis. -

-
-
-
- -
-
-

Email Notification for Successful Booking.

-
-

- Email is sent to the user on successful booking of cab. -

-
-
-
- -
-
-
-
- -
-
-

Booking Status

-
-
- -
-
-
-

- View your status of booking.You can also cancel your booking. -

-
-
-
- -
-
-

View All Cab Activities with Advanced Filttrations

-
-
- -
-
-
-
- -
-

You Looking for a free Documentation of this Application.?

-

Give a Request Mail to:    oddo@cybrosys.com

-
- -
-

Need Any Help?

- - -
- - - - diff --git a/cab_booking_management/static/description/log_details.png b/cab_booking_management/static/description/log_details.png index 72494ea34..65cba1f4d 100644 Binary files a/cab_booking_management/static/description/log_details.png and b/cab_booking_management/static/description/log_details.png differ diff --git a/cab_booking_management/views/cab_booking_view.xml b/cab_booking_management/views/cab_booking_view.xml index 9ac360d60..fb5bc135b 100644 --- a/cab_booking_management/views/cab_booking_view.xml +++ b/cab_booking_management/views/cab_booking_view.xml @@ -16,12 +16,18 @@ - - + + + diff --git a/cab_booking_management/views/cab_conf_view.xml b/cab_booking_management/views/cab_conf_view.xml index 03e61bac2..0995cf2ef 100644 --- a/cab_booking_management/views/cab_conf_view.xml +++ b/cab_booking_management/views/cab_conf_view.xml @@ -1,7 +1,7 @@ - + Cab Management @@ -47,7 +47,7 @@ - + diff --git a/cab_booking_management/views/cab_creation_view.xml b/cab_booking_management/views/cab_creation_view.xml index 7a5f15fcf..de147c6fd 100644 --- a/cab_booking_management/views/cab_creation_view.xml +++ b/cab_booking_management/views/cab_creation_view.xml @@ -11,7 +11,8 @@