You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

70 lines
2.7 KiB

# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2023-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# 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 (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import fields, models
class PosOrder(models.Model):
_inherit = "pos.order"
is_takeaway = fields.Boolean(default=False, string="Is a Takeaway Order",
help="Is a Takeaway Order")
token_number = fields.Char(string="Token Number",
help="Token number starts from 1")
def generate_token(self, uid):
"""
This function check whether the order is a take-away order or a dine-in.
If it is a take-away order, it will create the token number for that
order and returns it.
:param : uid: the pos order id
:return : order.token_number: token number of the pos order having the
order reference uid
"""
uid = "Order " + uid[0]
order = self.env['pos.order'].search([('pos_reference', 'ilike', uid)])
order.is_takeaway = True
if not order.token_number and \
self.env['res.config.settings'].get_values()[
'generate_token']:
if self.env['res.config.settings'].get_values()[
'pos_token']:
order.token_number = int(
self.env['res.config.settings'].get_values()[
'pos_token']) + 1
else:
order.token_number = 1
self.env['ir.config_parameter'].sudo().set_param(
'pos_takeaway.pos_token',
order.token_number)
return order.token_number
else:
return 0
def ticket_scheduler(self):
"""This function will reset the Token to 0 by a cron job."""
generate_token = self.env['ir.config_parameter'].sudo().get_param(
'generate_token')
if generate_token:
self.env['ir.config_parameter'].sudo().set_param('pos_token', 0)