Odoo18-Base/addons/pos_restaurant/models/pos_session.py

35 lines
1.3 KiB
Python
Raw Permalink Normal View History

2025-01-06 10:57:38 +07:00
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models, api
import json
class PosSession(models.Model):
_inherit = 'pos.session'
@api.model
def _load_pos_data_models(self, config_id):
data = super()._load_pos_data_models(config_id)
if self.config_id.module_pos_restaurant:
data += ['restaurant.floor', 'restaurant.table']
return data
@api.model
def _set_last_order_preparation_change(self, order_ids):
for order_id in order_ids:
order = self.env['pos.order'].browse(order_id)
last_order_preparation_change = {
'lines': {},
'generalNote': '',
}
for orderline in order['lines']:
last_order_preparation_change['lines'][orderline.uuid + " - "] = {
"uuid": orderline.uuid,
"name": orderline.full_product_name,
"note": "",
"product_id": orderline.product_id.id,
"quantity": orderline.qty,
"attribute_value_ids": orderline.attribute_value_ids.ids,
}
order.write({'last_order_preparation_change': json.dumps(last_order_preparation_change)})