Hi,
I am creating one of the restaurant management module in which orders are taken.
I created a button called Generate Invoice and it is of the type Object.
I just want the value of amount_total field should get invoiced and then Invoice will be created of that value.
Plz help me anyone with that!
Here is my code,
class hotel_reservation_order(osv.Model):
def reservation_generate_kot(self, cr, uid, ids, part):
order_tickets_obj = self.pool.get('hotel.restaurant.kitchen.order.tickets')
rest_order_list_obj = self.pool.get('hotel.restaurant.order.list')
for order in self.browse(cr, uid, ids):
table_ids = [x.id for x in order.table_no]
kot_data = order_tickets_obj.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,
}
rest_order_list_obj.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'),
'voucher_id':fields.many2one('account.move','order_id', string="Payments")
}
_defaults = {
'order_number':lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'hotel.reservation.order'),
}
class account_move(osv.Model):
_inherit="account.move"
_columns={
'order_id':fields.many2one('hotel.reservation.order','Generating Order')
}