From 9efe769dcf5b95564099d9d7171ebbca97f4b436 Mon Sep 17 00:00:00 2001 From: Serpent Consulting Services Date: Fri, 18 May 2012 13:09:13 +0530 Subject: [PATCH 01/84] [ADD] Added modules for hotel management --- hotel_restaurant/__init__.py | 27 + hotel_restaurant/__terp__.py | 54 ++ hotel_restaurant/hotel_restaurant.py | 344 ++++++++++ hotel_restaurant/hotel_restaurant_data.xml | 152 +++++ hotel_restaurant/hotel_restaurant_report.xml | 25 + .../hotel_restaurant_sequence.xml | 41 ++ hotel_restaurant/hotel_restaurant_view.xml | 430 ++++++++++++ hotel_restaurant/hotel_restaurant_wizard.xml | 24 + .../hotel_restaurant_workflow.xml | 70 ++ hotel_restaurant/i18n/es.po | 611 ++++++++++++++++++ hotel_restaurant/i18n/fr_BE.po | 591 +++++++++++++++++ hotel_restaurant/i18n/hotel_restaurant.pot | 591 +++++++++++++++++ hotel_restaurant/i18n/sv.po | 596 +++++++++++++++++ hotel_restaurant/report/__init__.py | 24 + hotel_restaurant/report/bill.rml | 249 +++++++ hotel_restaurant/report/bill.sxw | Bin 0 -> 12343 bytes .../report/hotel_restaurant_report.py | 47 ++ hotel_restaurant/report/kot.rml | 165 +++++ hotel_restaurant/report/kot.sxw | Bin 0 -> 11534 bytes hotel_restaurant/report/res_table.rml | 95 +++ hotel_restaurant/report/res_table.sxw | Bin 0 -> 10080 bytes hotel_restaurant/security/ir.model.access.csv | 11 + hotel_restaurant/wizard/__init__.py | 24 + .../wizard/hotel_restaurant_wizard.py | 108 ++++ 24 files changed, 4279 insertions(+) create mode 100755 hotel_restaurant/__init__.py create mode 100755 hotel_restaurant/__terp__.py create mode 100755 hotel_restaurant/hotel_restaurant.py create mode 100755 hotel_restaurant/hotel_restaurant_data.xml create mode 100755 hotel_restaurant/hotel_restaurant_report.xml create mode 100755 hotel_restaurant/hotel_restaurant_sequence.xml create mode 100755 hotel_restaurant/hotel_restaurant_view.xml create mode 100755 hotel_restaurant/hotel_restaurant_wizard.xml create mode 100755 hotel_restaurant/hotel_restaurant_workflow.xml create mode 100644 hotel_restaurant/i18n/es.po create mode 100755 hotel_restaurant/i18n/fr_BE.po create mode 100755 hotel_restaurant/i18n/hotel_restaurant.pot create mode 100644 hotel_restaurant/i18n/sv.po create mode 100755 hotel_restaurant/report/__init__.py create mode 100755 hotel_restaurant/report/bill.rml create mode 100755 hotel_restaurant/report/bill.sxw create mode 100755 hotel_restaurant/report/hotel_restaurant_report.py create mode 100755 hotel_restaurant/report/kot.rml create mode 100755 hotel_restaurant/report/kot.sxw create mode 100755 hotel_restaurant/report/res_table.rml create mode 100755 hotel_restaurant/report/res_table.sxw create mode 100755 hotel_restaurant/security/ir.model.access.csv create mode 100755 hotel_restaurant/wizard/__init__.py create mode 100755 hotel_restaurant/wizard/hotel_restaurant_wizard.py diff --git a/hotel_restaurant/__init__.py b/hotel_restaurant/__init__.py new file mode 100755 index 000000000..66e84fa20 --- /dev/null +++ b/hotel_restaurant/__init__.py @@ -0,0 +1,27 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import hotel_restaurant +import report +import wizard + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/hotel_restaurant/__terp__.py b/hotel_restaurant/__terp__.py new file mode 100755 index 000000000..db010b7f9 --- /dev/null +++ b/hotel_restaurant/__terp__.py @@ -0,0 +1,54 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + "name" : "Hotel Restaurant Management", + "version" : "1.0", + "author" : "Tiny", + "category" : "Generic Modules/Hotel Restaurant", + "description": """ + Module for Hotel/Resort/Restaurant management. You can manage: + * Configure Property + * Restaurant Configuration + * table reservation + * Generate and process Kitchen Order ticket, + * Payment + + Different reports are also provided, mainly for Restaurant. + """, + "depends" : ["base","hotel"], + "init_xml" : [], + "demo_xml" : ["hotel_restaurant_data.xml", + ], + "update_xml" : [ + "hotel_restaurant_view.xml", + "hotel_restaurant_report.xml", + "hotel_restaurant_workflow.xml", + "hotel_restaurant_wizard.xml", + "hotel_restaurant_sequence.xml", + "security/ir.model.access.csv", + ], + "active": False, + "installable": True +} + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/hotel_restaurant/hotel_restaurant.py b/hotel_restaurant/hotel_restaurant.py new file mode 100755 index 000000000..b088718d0 --- /dev/null +++ b/hotel_restaurant/hotel_restaurant.py @@ -0,0 +1,344 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields +from osv import osv +import time +import ir +from mx import DateTime +import netsvc +import datetime +import pooler +from tools import config + + +class product_category(osv.osv): + _inherit="product.category" + _columns = { + 'ismenutype':fields.boolean('Is Menu Type'), + } +product_category() +class product_product(osv.osv): + _inherit="product.product" + _columns = { + 'ismenucard':fields.boolean('Is Room'), + } +product_product() + +class hotel_menucard_type(osv.osv): + _name='hotel.menucard.type' + _description='amenities Type' + _inherits = {'product.category':'menu_id'} + _columns = { + 'menu_id':fields.many2one('product.category','category',required=True), + } + _defaults = { + 'ismenutype': lambda *a: 1, + + } +hotel_menucard_type() + +class hotel_menucard(osv.osv): + + _name='hotel.menucard' + _inherits={'product.product':'product_id'} + + _description='Hotel Menucard' + _columns = { + + 'product_id': fields.many2one('product.product','Product_id'), + } + _defaults = { + 'ismenucard': lambda *a: 1, + } +hotel_menucard() + + +class hotel_restaurant_tables(osv.osv): + + _name = "hotel.restaurant.tables" + _description="Includes Hotel Restaurant Table" + _columns={ + 'name':fields.char('Table number',size=64,required=True), + 'capacity':fields.integer('Capacity'), + + } +hotel_restaurant_tables() + +class hotel_restaurant_reservation(osv.osv): + + def create_order(self,cr,uid,ids,context=None): + k=[] + for i in self.browse(cr,uid,ids): + table_ids = [x.id for x in i.tableno] + kot_data=self.pool.get('hotel.reservation.order').create(cr,uid,{ + 'reservationno':i.reservation_id, + 'date1':i.start_date, + 'table_no':[(6,0,table_ids)], + }) + + + return True + + def onchange_partner_id(self, cr, uid, ids, part): + if not part: + return {'value':{'partner_address_id': False}} + addr = self.pool.get('res.partner').address_get(cr, uid, [part], ['default']) + pricelist = self.pool.get('res.partner').browse(cr, uid, part).property_product_pricelist_purchase.id + return {'value':{'partner_address_id': addr['default']}} + + def action_set_to_draft(self, cr, uid, ids, *args): + self.write(cr, uid, ids, {'state': 'draft'}) + wf_service = netsvc.LocalService('workflow') + for id in ids: + wf_service.trg_create(uid, self._name, id, cr) + return True + + def table_reserved(self, cr, uid, ids, *args): + + for reservation in self.browse(cr, uid, ids): + + cr.execute("select count(*) from hotel_restaurant_reservation as hrr " \ + "inner join reservation_table as rt on rt.reservation_table_id = hrr.id " \ + "where (start_date,end_date)overlaps( timestamp %s , timestamp %s ) " \ + "and hrr.id<> %d " \ + "and rt.name in (select rt.name from hotel_restaurant_reservation as hrr " \ + "inner join reservation_table as rt on rt.reservation_table_id = hrr.id " \ + "where hrr.id= %d) " \ + ,(reservation.start_date,reservation.end_date,reservation.id,reservation.id)) + + res = cr.fetchone() + + roomcount = res and res[0] or 0.0 + if roomcount: + raise osv.except_osv('Warning', 'You tried to confirm reservation with table those already reserved in this reservation period') + else: + self.write(cr, uid, ids, {'state':'confirm'}) + return True + + + + def table_cancel(self, cr, uid, ids, *args): + + self.write(cr, uid, ids, { + 'state':'cancel' + }) + return True + + def table_done(self, cr, uid, ids, *args): + + self.write(cr, uid, ids, { + 'state':'done' + }) + return True + + _name = "hotel.restaurant.reservation" + _description="Includes Hotel Restaurant Reservation" + _columns={ + 'reservation_id':fields.char('Reservation No',size=64,required=True), + 'room_no':fields.many2one('hotel.room','Room No',size=64), + 'start_date':fields.datetime('Start Date',required=True), + 'end_date':fields.datetime('End Date',required=True), + 'cname':fields.many2one('res.partner','Customer Name',size=64,required=True), + 'partner_address_id':fields.many2one('res.partner.address', 'Address'), + 'tableno':fields.many2many('hotel.restaurant.tables','reservation_table','reservation_table_id','name','Table number'), + 'state' : fields.selection([('draft','Draft'),('confirm','Confirmed'),('done','Done'),('cancel', 'Cancelled')], 'state', select=True, required=True, readonly=True), + } + _defaults = { + 'state': lambda *a: 'draft', + 'reservation_id':lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid,'hotel.restaurant.reservation'), + } + +hotel_restaurant_reservation() + +class hotel_restaurant_kitchen_order_tickets(osv.osv): + _name = "hotel.restaurant.kitchen.order.tickets" + _description="Includes Hotel Restaurant Order" + _columns={ + 'orderno':fields.char('Order Number',size=64,readonly=True), + 'resno':fields.char('Reservation Number',size=64), + 'kot_date':fields.datetime('Date'), + 'room_no':fields.char('Room No',size=64,readonly=True), + 'w_name':fields.char('Waiter Name',size=64,readonly=True), + 'tableno':fields.many2many('hotel.restaurant.tables','temp_table3','table_no','name','Table number',size=64), + 'kot_list':fields.one2many('hotel.restaurant.order.list','kot_order_list','Order List'), + + } + +hotel_restaurant_kitchen_order_tickets() + +class hotel_restaurant_order(osv.osv): + + def _sub_total(self, cr, uid, ids, field_name, arg, context): + res = {} + for sale in self.browse(cr, uid, ids): + res[sale.id] = 0.00 + for line in sale.order_list: + res[sale.id] += line.price_subtotal + return res + + + def _total(self, cr, uid, ids, field_name, arg, context): + res = {} + for line in self.browse(cr, uid, ids): + res[line.id] = line.amount_subtotal + (line.amount_subtotal * line.tax)/100 + return res + + def generate_kot(self,cr,uid,ids,part): + + for order in self.browse(cr,uid,ids): + table_ids = [x.id for x in order.table_no] + kot_data=self.pool.get('hotel.restaurant.kitchen.order.tickets').create(cr,uid,{ + 'orderno':order.order_no, + 'kot_date':order.o_date, + 'room_no':order.room_no.name, + 'w_name':order.waiter_name.name, + 'tableno':[(6,0,table_ids)], + }) + + for order_line in order.order_list: + + o_line={ + 'kot_order_list':kot_data, + 'name':order_line.name.id, + 'item_qty':order_line.item_qty, + } + self.pool.get('hotel.restaurant.order.list').create(cr,uid,o_line) + + return True + + + _name = "hotel.restaurant.order" + _description="Includes Hotel Restaurant Order" + _columns={ + 'order_no':fields.char('Order Number',size=64,required=True), + 'o_date':fields.datetime('Date',required=True), + 'room_no':fields.many2one('hotel.room','Room No',size=64), + 'waiter_name':fields.many2one('res.partner','Waiter Name',size=64,required=True), + 'table_no':fields.many2many('hotel.restaurant.tables','temp_table2','table_no','name','Table number',size=64), + 'order_list':fields.one2many('hotel.restaurant.order.list','o_list','Order List'), + 'tax': fields.float('Tax (%) ', size=64), + 'amount_subtotal': fields.function(_sub_total, method=True, string='Subtotal'), + 'amount_total':fields.function(_total,method=True,string='Total'), + + + + } + _defaults = { + 'order_no': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid,'hotel.restaurant.order'), + + } + +hotel_restaurant_order() + +class hotel_reservation_order(osv.osv): + + def _sub_total(self, cr, uid, ids, field_name, arg, context): + res = {} + for sale in self.browse(cr, uid, ids): + res[sale.id] = 0.00 + for line in sale.order_list: + res[sale.id] += line.price_subtotal + return res + + + def _total(self, cr, uid, ids, field_name, arg, context): + res = {} + for line in self.browse(cr, uid, ids): + res[line.id] = line.amount_subtotal + (line.amount_subtotal * line.tax)/100 + return res + + def reservation_generate_kot(self,cr,uid,ids,part): + + for order in self.browse(cr,uid,ids): + table_ids = [x.id for x in order.table_no] + kot_data=self.pool.get('hotel.restaurant.kitchen.order.tickets').create(cr,uid,{ + 'orderno':order.order_number, + 'resno':order.reservationno, + 'kot_date':order.date1, + 'w_name':order.waitername.name, + 'tableno':[(6,0,table_ids)], + }) + + for order_line in order.order_list: + + o_line={ + 'kot_order_list':kot_data, + 'name':order_line.name.id, + 'item_qty':order_line.item_qty, + } + self.pool.get('hotel.restaurant.order.list').create(cr,uid,o_line) + + return True + + _name="hotel.reservation.order" + _description="Reservation Order" + _columns={ + 'order_number':fields.char('Order No',size=64), + 'reservationno':fields.char('Reservation No',size=64), + 'date1':fields.datetime('Date',required=True), + 'waitername':fields.many2one('res.partner','Waiter Name',size=64), + 'table_no':fields.many2many('hotel.restaurant.tables','temp_table4','table_no','name','Table number',size=64), + 'order_list':fields.one2many('hotel.restaurant.order.list','o_l','Order List'), + 'tax': fields.float('Tax (%) ', size=64), + 'amount_subtotal': fields.function(_sub_total, method=True, string='Subtotal'), + 'amount_total':fields.function(_total,method=True,string='Total'), + + + } + + _defaults = { + 'order_number':lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid,'hotel.reservation.order'), + } + +hotel_reservation_order() + +class hotel_restaurant_order_list(osv.osv): + + def _sub_total(self, cr, uid, ids, field_name, arg, context): + res = {} + for line in self.browse(cr, uid, ids): + res[line.id] = line.item_rate * int(line.item_qty) + return res + + + def on_change_item_name(self,cr, uid, ids, name,context=None): + if not name: + return {'value':{}} + temp=self.pool.get('hotel.menucard').browse(cr,uid,name,context) + return {'value':{'item_rate':temp.list_price}} + + + _name = "hotel.restaurant.order.list" + _description="Includes Hotel Restaurant Order" + _columns={ + 'o_list':fields.many2one('hotel.restaurant.order'), + 'o_l':fields.many2one('hotel.reservation.order'), + 'kot_order_list':fields.many2one('hotel.restaurant.kitchen.order.tickets'), + 'name':fields.many2one('hotel.menucard','Item Name',required=True), + 'item_qty':fields.char('Qty',size=64,required=True), + 'item_rate':fields.float('Rate',size=64), + 'price_subtotal': fields.function(_sub_total, method=True, string='Subtotal'), + } +hotel_restaurant_order_list() + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/hotel_restaurant/hotel_restaurant_data.xml b/hotel_restaurant/hotel_restaurant_data.xml new file mode 100755 index 000000000..ccb4b5fbe --- /dev/null +++ b/hotel_restaurant/hotel_restaurant_data.xml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + All FoodItems + + + + + Punjabi + + + + South Indian + + + + Gujarati + + + + + Paneer Tikaa + + 50.00 + + + Tanduri Roti + + 10 + + + Dosa + + 30.00 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + 50.00 + + + + + + + + + + + + + 3 + 30.00 + + + + + + + + + + + + + + + 3 + 30.00 + + + + + + + + + + + + + + 3 + 50.00 + + + + \ No newline at end of file diff --git a/hotel_restaurant/hotel_restaurant_report.xml b/hotel_restaurant/hotel_restaurant_report.xml new file mode 100755 index 000000000..737c0f2b9 --- /dev/null +++ b/hotel_restaurant/hotel_restaurant_report.xml @@ -0,0 +1,25 @@ + + + + + + + + + + diff --git a/hotel_restaurant/hotel_restaurant_sequence.xml b/hotel_restaurant/hotel_restaurant_sequence.xml new file mode 100755 index 000000000..85722f7cd --- /dev/null +++ b/hotel_restaurant/hotel_restaurant_sequence.xml @@ -0,0 +1,41 @@ + + + + # + # Sequences for hotel.foodorder + # + + + Hotel Order + hotel.restaurant.order + + + Hotel Order + hotel.restaurant.order + 0R/ + 5 + + + + Hotel Reservation + hotel.restaurant.reservation + + + Hotel Reservation + hotel.restaurant.reservation + R0/ + 5 + + + + Hotel Reservation + hotel.reservation.order + + + Hotel Reservation + hotel.reservation.order + 0RR/ + 5 + + + \ No newline at end of file diff --git a/hotel_restaurant/hotel_restaurant_view.xml b/hotel_restaurant/hotel_restaurant_view.xml new file mode 100755 index 000000000..b10e4d1d8 --- /dev/null +++ b/hotel_restaurant/hotel_restaurant_view.xml @@ -0,0 +1,430 @@ + + + + + + + hotel_restaurant_tables.form + hotel.restaurant.tables + form + +
+ + + + + + +
+ + hotel_restaurant_tables.tree + hotel.restaurant.tables + tree + + + + + + + + + Tables Details + hotel.restaurant.tables + form + tree,form + + + + + + hotel_restaurant_reservation.form + hotel.restaurant.reservation + form + +
+ + + + + + + + + + + +