19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:29:53 +01:00
parent 6e54c1af6c
commit 3ca647e428
1087 changed files with 132065 additions and 108499 deletions

View file

@ -1,64 +1,35 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
from itertools import groupby
from odoo.osv.expression import AND
from odoo import models, api
import json
class PosSession(models.Model):
_inherit = 'pos.session'
def _pos_ui_models_to_load(self):
result = super()._pos_ui_models_to_load()
@api.model
def _load_pos_data_models(self, config):
data = super()._load_pos_data_models(config)
if self.config_id.module_pos_restaurant:
result.append('restaurant.printer')
if self.config_id.is_table_management:
result.append('restaurant.floor')
return result
data += ['restaurant.floor', 'restaurant.table', 'restaurant.order.course']
return data
def _loader_params_restaurant_floor(self):
return {
'search_params': {
'domain': [('pos_config_id', '=', self.config_id.id)],
'fields': ['name', 'background_color', 'table_ids', 'sequence'],
'order': 'sequence',
},
}
def _loader_params_restaurant_table(self):
return {
'search_params': {
'domain': [('active', '=', True)],
'fields': [
'name', 'width', 'height', 'position_h', 'position_v',
'shape', 'floor_id', 'color', 'seats', 'active'
],
},
}
def _get_pos_ui_restaurant_floor(self, params):
floors = self.env['restaurant.floor'].search_read(**params['search_params'])
floor_ids = [floor['id'] for floor in floors]
table_params = self._loader_params_restaurant_table()
table_params['search_params']['domain'] = AND([table_params['search_params']['domain'], [('floor_id', 'in', floor_ids)]])
tables = self.env['restaurant.table'].search(table_params['search_params']['domain'], order='floor_id')
tables_by_floor_id = {}
for floor_id, table_group in groupby(tables, key=lambda table: table.floor_id):
floor_tables = self.env['restaurant.table'].concat(*table_group)
tables_by_floor_id[floor_id.id] = floor_tables.read(table_params['search_params']['fields'])
for floor in floors:
floor['tables'] = tables_by_floor_id.get(floor['id'], [])
return floors
def _loader_params_restaurant_printer(self):
return {
'search_params': {
'domain': [('id', 'in', self.config_id.printer_ids.ids)],
'fields': ['name', 'proxy_ip', 'product_categories_ids', 'printer_type'],
},
}
def _get_pos_ui_restaurant_printer(self, params):
return self.env['restaurant.printer'].search_read(**params['search_params'])
@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': {},
'generalCustomerNote': '',
}
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)})