Browse Source

[ADD]:New Fields In Module

pull/29/head
SHEREEF PT 8 years ago
parent
commit
2114f35e91
  1. 4
      cab_booking_management/__manifest__.py
  2. 47
      cab_booking_management/__manifest__.py~
  3. 12
      cab_booking_management/models/cab_booking.py
  4. 48
      cab_booking_management/models/cab_creation.py
  5. 3
      cab_booking_management/models/cab_location.py
  6. 81
      cab_booking_management/models/cab_log.py
  7. 3
      cab_booking_management/models/cab_timing.py
  8. BIN
      cab_booking_management/static/description/cab_activity.png
  9. BIN
      cab_booking_management/static/description/cab_booking.png
  10. BIN
      cab_booking_management/static/description/cab_cancel.png
  11. BIN
      cab_booking_management/static/description/cab_creation.png
  12. BIN
      cab_booking_management/static/description/cab_details.png
  13. BIN
      cab_booking_management/static/description/cab_maintain.png
  14. 16
      cab_booking_management/static/description/index.html
  15. BIN
      cab_booking_management/static/description/log_details.png
  16. 22
      cab_booking_management/views/cab_booking_view.xml
  17. 5
      cab_booking_management/views/cab_creation_view.xml
  18. 2
      cab_booking_management/views/cab_location_view.xml
  19. 22
      cab_booking_management/views/cab_log_view.xml
  20. 8
      cab_booking_management/views/cab_timing_view.xml

4
cab_booking_management/__manifest__.py

@ -25,8 +25,8 @@
'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',
'version': '10.0.1.0.0',
'depends': ['base', 'mail'],
'data': [
'views/templates.xml',

47
cab_booking_management/__manifest__.py~

@ -1,47 +0,0 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2009-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': "Cab Booking Management System",
'summary': """Complete Cab Booking Management and its Related Records""",
'author': "Cybrosys Techno Solution",
'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,
}

12
cab_booking_management/models/cab_booking.py

@ -21,21 +21,24 @@
#
##############################################################################
from odoo 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
@ -47,4 +50,3 @@ class CabBooking(models.Model):

48
cab_booking_management/models/cab_creation.py

@ -22,12 +22,14 @@
##############################################################################
from odoo import models, fields, api
from odoo.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,46 @@ 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")

3
cab_booking_management/models/cab_location.py

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api
from odoo import models, fields
class CabLocation(models.Model):
@ -11,3 +11,4 @@ class CabLocation(models.Model):
cab_code = fields.Char(string='City Code', size=64, help="The official code for the city")
state_id = fields.Many2one('res.country.state', string='State', required=True)
country_id = fields.Many2one('res.country', string='Country', required=True)

81
cab_booking_management/models/cab_log.py

@ -21,9 +21,9 @@
#
##############################################################################
from odoo import models, fields, api
from odoo.tools.translate import _
from odoo.exceptions import UserError
from odoo import models, fields, api, _
from odoo.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],

3
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

BIN
cab_booking_management/static/description/cab_activity.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 85 KiB

BIN
cab_booking_management/static/description/cab_booking.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 63 KiB

BIN
cab_booking_management/static/description/cab_cancel.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 85 KiB

BIN
cab_booking_management/static/description/cab_creation.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 73 KiB

BIN
cab_booking_management/static/description/cab_details.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

BIN
cab_booking_management/static/description/cab_maintain.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

16
cab_booking_management/static/description/index.html

@ -124,6 +124,22 @@
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_space">
<h3 class="oe_slogan"> Cab Maintenance</h3>
<div class="oe_span6">
<p class='oe_mt32'>
It shows the total expenses for a cab, on daily basis.
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<img src="cab_maintain.png">
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row">
<h3 class="oe_slogan">View All Cab Activities with Advanced Filttrations</h3>

BIN
cab_booking_management/static/description/log_details.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 88 KiB

22
cab_booking_management/views/cab_booking_view.xml

@ -1,8 +1,8 @@
<odoo>
<data>
<record model="ir.ui.view" id="cab_booking_form_view">
<field name="name">CabBooking</field>
<record model="ir.ui.view" id="cab_booking_form_view">
<field name="name">Cab Booking</field>
<field name="model">cab.booking</field>
<field name="arch" type="xml">
<form string="Cab Management">
@ -17,17 +17,23 @@
<group>
<group>
<field name="booking_date"/>
<field name="cab_routes"/>
</group>
<group>
<field name="cab_timing"/>
<field name="cab_timing" style="width:50%%"/>
</group>
</group>
<group>
<label for="cab_routes" class="oe_inline"/>
<div >
<field name="cab_routes" class="oe_inline"/> to
<field name="cab_routes_to" class="oe_inline"/>
</div>
</group>
<field name="seat_available">
<tree name="Cab InformationTree">
<tree name="Cab InformationTree" editable="bottom">
<field name="name"/>
<field name="seat" style="text-align: center;"/>
<button name="action_log_form_view" type="object" icon="fa-arrow-right" />
<button name="action_log_form_view" type="object" icon="fa-arrow-right" />
</tree>
</field>
</sheet>
@ -36,7 +42,7 @@
</record>
<record model="ir.ui.view" id="cab_booking_tree_view">
<field name="name">CabBooking</field>
<field name="name">Cab Booking</field>
<field name="model">cab.booking</field>
<field name="arch" type="xml">
<tree string="Cab Booking">
@ -48,7 +54,7 @@
</record>
<record model="ir.actions.act_window" id="cab_booking_action">
<field name="name">CabBooking</field>
<field name="name">Cab Booking</field>
<field name="res_model">cab.booking</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,calender</field>

5
cab_booking_management/views/cab_creation_view.xml

@ -1,7 +1,7 @@
<odoo>
<data>
<record model="ir.ui.view" id="cab_management_form_view">
<record model="ir.ui.view" id="cab_management_form_view">
<field name="name">Cab Details</field>
<field name="model">cab.management</field>
<field name="arch" type="xml">
@ -11,7 +11,8 @@
<div class="oe_title">
<label for="name"/>
<h1>
<field name="name" placeholder=" Vehicle Name" style="width:50%%"/>
<field name="ref_name" placeholder=" Vehicle Name" style="width:50%%"/>
<field name="name" invisible="1"/>
</h1>
<label for="licence_plate"/>
<h2>

2
cab_booking_management/views/cab_location_view.xml

@ -1,7 +1,7 @@
<odoo>
<data>
<record model="ir.ui.view" id="cab_location_form_view">
<record model="ir.ui.view" id="cab_location_form_view">
<field name="name">Location</field>
<field name="model">cab.location</field>
<field name="arch" type="xml">

22
cab_booking_management/views/cab_log_view.xml

@ -1,7 +1,6 @@
<odoo>
<data>
<record model="ir.ui.view" id="cab_log_form_view">
<record model="ir.ui.view" id="cab_log_form_view">
<field name="name">Cab Details</field>
<field name="model">cab.log</field>
<field name="arch" type="xml">
@ -49,19 +48,19 @@
<group>
<group>
<field name="cab_log_date"/>
<field name="fuel_used"/>
<field name="seat_capacity"/>
<field name="seat_available"/>
<field name="cab_location"/>
<field name="seat_booked" attrs="{'readonly':['|',('seat_available', '==', 0) ] }"/>
<field name="seat_check" invisible="1"/>
<field name="partner_id"/>
<field name="cab_log_timing" style="width:50%%"/>
<field name="cab_location_from" style="width:50%%"/>
<field name="cab_location" style="width:50%%"/>
<field name="seat_capacity" invisible="1"/>
</group>
<group>
<field name="seat_available"/>
<field name="seat_booked" attrs="{'readonly':['|',('seat_available', '==', 0) ] }"/>
<field name="fuel_used"/>
<field name="odo_metre"/>
<field name="cab_expense"/>
<field name="cab_log_timing"/>
<field name="total_passenger"/>
<field name="partner_id" attrs="{'readonly':['|',('seat_check', '==', 1)]}" />
<field name="total_passenger" invisible="1"/>
</group>
</group>
</sheet>
@ -78,6 +77,7 @@
<field name="seat_available"/>
<field name="cab_log_date"/>
<field name="cab_log_timing"/>
<field name="cab_location_from"/>
<field name="cab_location"/>
<field name="odo_metre"/>
<field name="fuel_used"/>

8
cab_booking_management/views/cab_timing_view.xml

@ -1,7 +1,7 @@
<odoo>
<data>
<record model="ir.ui.view" id="cab_timing_form_view">
<record model="ir.ui.view" id="cab_timing_form_view">
<field name="name">Cab Timing</field>
<field name="model">cab.timing</field>
<field name="arch" type="xml">
@ -18,11 +18,12 @@
<group>
<group>
<field name="name"/>
<field name="cab_route"/>
<field name="cab_route" style="width:50%%"/>
<field name="cab_route_to" style="width:50%%"/>
</group>
<group>
<field name="cab_time" widget="many2many_tags"/>
<field name="seat"/>
<field name="seat" style="width:25%%"/>
</group>
</group>
</sheet>
@ -37,6 +38,7 @@
<tree string="Cab Timing">
<field name="name"/>
<field name="cab_route"/>
<field name="cab_route_to"/>
<field name="cab_time" widget="many2many_tags"/>
<field name="seat"/>
</tree>

Loading…
Cancel
Save