Skip to content

Commit 5a98d1c

Browse files
authored
Merge pull request #5320 from Tecnativa/18.0-ou-add-pos_restaurant
[18.0][OU-ADD] pos_restaurant : Migration to 18.0
2 parents 5f13e23 + 768e81c commit 5a98d1c

File tree

4 files changed

+89
-1
lines changed

4 files changed

+89
-1
lines changed

docsource/modules170-180.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ Module coverage 17.0 -> 18.0
822822
+---------------------------------------------------+----------------------+-------------------------------------------------+
823823
| pos_razorpay | | |
824824
+---------------------------------------------------+----------------------+-------------------------------------------------+
825-
| pos_restaurant | | |
825+
| pos_restaurant | Done | |
826826
+---------------------------------------------------+----------------------+-------------------------------------------------+
827827
| pos_restaurant_adyen | |No DB layout changes. |
828828
+---------------------------------------------------+----------------------+-------------------------------------------------+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2025 Tecnativa - Carlos Lopez
2+
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
3+
from openupgradelib import openupgrade
4+
5+
6+
def _fill_restaurant_table_table_number(env):
7+
# Update when name is numeric
8+
openupgrade.logged_query(
9+
env.cr,
10+
"""
11+
UPDATE restaurant_table
12+
SET table_number = name::integer
13+
WHERE name ~ '^[0-9]+$';
14+
""",
15+
)
16+
# Generate numbering by floor_id when 'name' is not numeric
17+
openupgrade.logged_query(
18+
env.cr,
19+
"""
20+
WITH numbered AS (
21+
SELECT id,
22+
ROW_NUMBER() OVER (PARTITION BY floor_id ORDER BY id) AS rn
23+
FROM restaurant_table
24+
WHERE name !~ '^[0-9]+$'
25+
)
26+
UPDATE restaurant_table t
27+
SET table_number = n.rn
28+
FROM numbered n
29+
WHERE t.id = n.id;
30+
""",
31+
)
32+
33+
34+
@openupgrade.migrate()
35+
def migrate(env, version):
36+
_fill_restaurant_table_table_number(env)
37+
openupgrade.delete_records_safely_by_xml_id(
38+
env,
39+
["pos_restaurant.pos_config_main_restaurant"],
40+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2025 Tecnativa - Carlos Lopez
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
from openupgradelib import openupgrade
4+
5+
field_renames = [
6+
("pos.config", "pos_config", "self_ordering_takeaway", "takeaway"),
7+
("pos.config", "pos_config", "self_ordering_alternative_fp_id", "takeaway_fp_id"),
8+
("pos.order", "pos_order", "take_away", "takeaway"),
9+
]
10+
11+
12+
@openupgrade.migrate()
13+
def migrate(env, version=None):
14+
openupgrade.rename_fields(env, field_renames)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---Models in module 'pos_restaurant'---
2+
---Fields in module 'pos_restaurant'---
3+
pos_restaurant / pos.config / iface_orderline_notes (boolean): DEL
4+
# NOTHING TO DO: Odoo enables by default the possibility to add a note into order lines without an additional setting
5+
# see https://github.com/odoo/odoo/commit/f47b9a27e50266899e73b43a71c31621e57e8c6c
6+
7+
pos_restaurant / pos.config / module_pos_restaurant (False) : DEL mode: modify
8+
# NOTHING TO DO: this field is present in the point_of_sale module.
9+
# Odoo removed the default value of True, so when creating a new pos.config,
10+
# enabling restaurant features must be an explicit user setting, without altering existing data.
11+
12+
pos_restaurant / pos.config / takeaway (boolean) : NEW
13+
pos_restaurant / pos.config / takeaway_fp_id (many2one) : NEW relation: account.fiscal.position
14+
pos_restaurant / pos.order / takeaway (boolean) : NEW hasdefault: default
15+
# DONE: pre-migration: Moved from pos_self_order and renamed these fields
16+
# see https://github.com/odoo/odoo/commit/1395065fe1283db957a99305bccc742483999485
17+
18+
pos_restaurant / pos.order.line / note (char) : module is now 'point_of_sale' ('pos_restaurant')
19+
# NOTHING TO DO: field moved in commit https://github.com/odoo/odoo/commit/1b079fdc18bbede882ac8e68b81ca0516344aba6
20+
21+
pos_restaurant / restaurant.floor / floor_background_image (binary): NEW attachment: True
22+
# NOTHING TO DO: New feature added in https://github.com/odoo/odoo/commit/b42b0f8b541a13621b671b0b7e57812ef11fc1b2
23+
24+
pos_restaurant / restaurant.table / name (char) : DEL required
25+
pos_restaurant / restaurant.table / table_number (integer) : NEW required, hasdefault: default
26+
# DONE: post-migration: convert char to integer where possible, otherwise generate a table number by floor_id
27+
# see https://github.com/odoo/odoo/commit/e96cbbcc9656089da21afe57c16970fdd0621d1c
28+
29+
pos_restaurant / restaurant.table / parent_id (many2one) : NEW relation: restaurant.table
30+
# NOTHING TO DO: new feature to merge tables, introduced in commit https://github.com/odoo/odoo/commit/fbd632a9a6a8a68618f0445c96e2c2746ffc907d
31+
32+
---XML records in module 'pos_restaurant'---
33+
DEL pos.config: pos_restaurant.pos_config_main_restaurant (noupdate)
34+
# DONE: post-migration: safely delete

0 commit comments

Comments
 (0)