-
-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] point_of_sale: migration script
- Loading branch information
1 parent
a2b066a
commit 57c543d
Showing
5 changed files
with
233 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 20 additions & 20 deletions
40
openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/noupdate_changes.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<odoo> | ||
<record id="product_product_consumable" model="product.product"> | ||
<!-- <record id="product_product_consumable" model="product.product"> | ||
<field name="available_in_pos">False</field> | ||
</record> | ||
</record>--> | ||
<record id="product_product_tip" model="product.product"> | ||
<field name="available_in_pos">False</field> | ||
</record> | ||
<record id="rule_pos_config_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record> | ||
<record id="rule_pos_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record> | ||
<record id="rule_pos_order_report_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record> | ||
<record id="rule_pos_payment_method_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record> | ||
<record id="rule_pos_payment_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record> | ||
<record id="rule_pos_session_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record> | ||
<!-- <record id="rule_pos_config_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record>--> | ||
<!-- <record id="rule_pos_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record>--> | ||
<!-- <record id="rule_pos_order_report_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record>--> | ||
<!-- <record id="rule_pos_payment_method_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record>--> | ||
<!-- <record id="rule_pos_payment_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record>--> | ||
<!-- <record id="rule_pos_session_multi_company" model="ir.rule"> | ||
<field name="global"/> | ||
</record>--> | ||
</odoo> |
56 changes: 56 additions & 0 deletions
56
openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def convert_field_m2o_to_o2m(env): | ||
openupgrade.m2o_to_x2m( | ||
env.cr, env["pos.order"], "pos_order", "picking_ids", "picking_id" | ||
) | ||
|
||
|
||
def fill_sesion_on_picking_by_pos_order(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE stock_picking | ||
SET pos_session_id = (SELECT session_id | ||
FROM pos_order | ||
WHERE pos_order.id = stock_picking.pos_order_id | ||
LIMIT 1) | ||
WHERE pos_session_id IS NULL AND pos_order_id IS NOT NULL; | ||
""", | ||
) | ||
|
||
|
||
def set_point_of_sale_update_stock_quantities_to_real(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE res_company | ||
SET point_of_sale_update_stock_quantities = 'real'; | ||
""", | ||
) | ||
|
||
|
||
def transfer_new_session_state(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE pos_session ps | ||
SET state = CASE | ||
WHEN pc.cash_control=True AND | ||
COALESCE(ps.rescue,False)=False THEN 'opening_control' | ||
ELSE 'opened' | ||
END | ||
FROM pos_config pc | ||
WHERE pc.id = ps.config_id AND ps.state = 'new_session'; | ||
""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
convert_field_m2o_to_o2m(env) | ||
fill_sesion_on_picking_by_pos_order(env) | ||
set_point_of_sale_update_stock_quantities_to_real(env) | ||
transfer_new_session_state(env) | ||
openupgrade.load_data(env.cr, "point_of_sale", "14.0.1.0.1/noupdate_changes.xml") |
53 changes: 53 additions & 0 deletions
53
openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def fill_pos_config_default_picking_type_id(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE pos_config | ||
SET picking_type_id = (SELECT pos_type_id | ||
FROM stock_warehouse | ||
WHERE stock_warehouse.company_id = pos_config.company_id | ||
LIMIT 1) | ||
WHERE picking_type_id IS NULL; | ||
""", | ||
) | ||
|
||
|
||
def delete_constraint(env): | ||
# Disappeared constraint | ||
openupgrade.logged_query( | ||
env.cr, | ||
"""ALTER TABLE res_partner | ||
DROP CONSTRAINT IF EXISTS res_partner_unique_barcode""", | ||
) | ||
openupgrade.delete_records_safely_by_xml_id( | ||
env, ["point_of_sale.constraint_res_partner_unique_barcode"] | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
fill_pos_config_default_picking_type_id(env) | ||
|
||
openupgrade.set_xml_ids_noupdate_value( | ||
env, | ||
"point_of_sale", | ||
[ | ||
"rule_pos_bank_statement_account_user", | ||
"rule_pos_bank_statement_line_account_user", | ||
"rule_pos_bank_statement_line_user", | ||
"rule_pos_bank_statement_user", | ||
"rule_pos_cashbox_line_accountant", | ||
"rule_pos_config_multi_company", | ||
"rule_pos_multi_company", | ||
"rule_pos_order_report_multi_company", | ||
"rule_pos_payment_method_multi_company", | ||
"rule_pos_payment_multi_company", | ||
"rule_pos_session_multi_company", | ||
], | ||
True, | ||
) | ||
|
||
delete_constraint(env) |
103 changes: 103 additions & 0 deletions
103
openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/upgrade_analysis_work.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
---Models in module 'point_of_sale'--- | ||
---Fields in module 'point_of_sale'--- | ||
point_of_sale / pos.config / iface_precompute_cash (boolean): DEL | ||
point_of_sale / pos.config / manage_orders (boolean) : NEW | ||
point_of_sale / pos.config / manual_discount (boolean) : NEW hasdefault | ||
point_of_sale / pos.config / module_pos_reprint (boolean) : DEL | ||
# NOTHING TO DO | ||
|
||
point_of_sale / pos.config / picking_type_id (many2one) : now required, req_default: function | ||
# DONE: pre-migration fill record having empty field with default value | ||
|
||
point_of_sale / pos.config / product_configurator (boolean): NEW | ||
point_of_sale / pos.order / _order : _order is now 'date_order desc, name desc, id desc' ('id desc') | ||
point_of_sale / pos.order / is_tipped (boolean) : NEW | ||
# NOTHING TO DO | ||
|
||
point_of_sale / pos.order / location_id (many2one) : DEL relation: stock.location | ||
# NOTHING TO DO | ||
|
||
point_of_sale / pos.order / picking_id (many2one) : DEL relation: stock.picking | ||
point_of_sale / pos.order / picking_ids (one2many) : NEW relation: stock.picking | ||
# DONE: post-migration convert data many2one to one2many | ||
|
||
point_of_sale / pos.order / tip_amount (float) : NEW | ||
point_of_sale / pos.order.line / full_product_name (char) : NEW | ||
point_of_sale / pos.payment / cardholder_name (char) : NEW | ||
point_of_sale / pos.payment / is_change (boolean) : NEW hasdefault | ||
point_of_sale / pos.payment / payment_status (char) : NEW | ||
point_of_sale / pos.payment / ticket (char) : NEW | ||
point_of_sale / pos.payment.method / active (boolean) : NEW hasdefault | ||
point_of_sale / pos.session / cash_real_difference (float) : NEW | ||
point_of_sale / pos.session / cash_real_expected (float) : NEW | ||
point_of_sale / pos.session / cash_real_transaction (float) : NEW | ||
point_of_sale / pos.session / picking_ids (one2many) : NEW relation: stock.picking | ||
# NOTHING TO DO | ||
|
||
point_of_sale / pos.session / state (selection) : selection_keys is now '['closed', 'closing_control', 'opened', 'opening_control']' ('['closed', 'closing_control', 'new_session', 'opened', 'opening_control']') | ||
# Done: convert new_session state to other state | ||
|
||
point_of_sale / pos.session / update_stock_at_closing (boolean): NEW | ||
# NOTHING TO DO | ||
|
||
point_of_sale / res.company / point_of_sale_update_stock_quantities (selection): NEW selection_keys: ['closing', 'real'], hasdefault | ||
# Done: post-migration set value to 'real' corresponding v13 work | ||
|
||
point_of_sale / res.partner / barcode (char) : module is now 'base' ('point_of_sale') | ||
point_of_sale / res.partner / barcode (char) : not stored anymore | ||
# NOTHING TO DO | ||
|
||
point_of_sale / stock.picking / pos_order_id (many2one) : NEW relation: pos.order | ||
# DONE: post-migration convert data many2one to one2many | ||
|
||
point_of_sale / stock.picking / pos_session_id (many2one) : NEW relation: pos.session | ||
# DONE: post-migration fill session following pos order | ||
|
||
pos_cash_rounding / account.cash.rounding / loss_account_id (many2one) : module is now 'account' ('pos_cash_rounding') | ||
pos_cash_rounding / account.cash.rounding / loss_account_id (many2one) : not stored anymore | ||
# NOTHING TO DO: handle by ORM | ||
|
||
---XML records in module 'point_of_sale'--- | ||
NEW ir.model.access: point_of_sale.access_account_cash_rounding_pos_user | ||
NEW ir.model.access: point_of_sale.access_closing_balance_confirm_wizard | ||
NEW ir.model.access: point_of_sale.access_money_in_out_wizard | ||
NEW ir.model.access: point_of_sale.access_pos_details_wizard | ||
NEW ir.model.access: point_of_sale.access_pos_make_payment | ||
NEW ir.model.access: point_of_sale.access_product_attribute_custom_value_pos_manager | ||
NEW ir.model.access: point_of_sale.access_product_attribute_pos_manager | ||
NEW ir.model.access: point_of_sale.access_product_attribute_value_pos_manager | ||
NEW ir.model.access: point_of_sale.access_product_product_attribute_pos_manager | ||
NEW ir.model.access: point_of_sale.access_product_template_attribute_exclusion_pos_manager | ||
NEW ir.model.access: point_of_sale.access_product_template_attribute_line_pos_manager | ||
DEL ir.model.access: pos_cash_rounding.access_account_cash_rounding | ||
# NOTHING TO DO | ||
|
||
DEL ir.model.constraint: point_of_sale.constraint_res_partner_unique_barcode | ||
# DONE pre-migration: deleted obsolete constraint | ||
|
||
ir.rule: point_of_sale.rule_pos_bank_statement_account_user (noupdate) (noupdate switched) | ||
ir.rule: point_of_sale.rule_pos_bank_statement_line_account_user (noupdate) (noupdate switched) | ||
ir.rule: point_of_sale.rule_pos_bank_statement_line_user (noupdate) (noupdate switched) | ||
ir.rule: point_of_sale.rule_pos_bank_statement_user (noupdate) (noupdate switched) | ||
ir.rule: point_of_sale.rule_pos_cashbox_line_accountant (noupdate) (noupdate switched) | ||
ir.rule: point_of_sale.rule_pos_config_multi_company (noupdate) (noupdate switched) | ||
ir.rule: point_of_sale.rule_pos_multi_company (noupdate) (noupdate switched) | ||
ir.rule: point_of_sale.rule_pos_order_report_multi_company (noupdate) (noupdate switched) | ||
ir.rule: point_of_sale.rule_pos_payment_method_multi_company (noupdate) (noupdate switched) | ||
ir.rule: point_of_sale.rule_pos_payment_multi_company (noupdate) (noupdate switched) | ||
ir.rule: point_of_sale.rule_pos_session_multi_company (noupdate) (noupdate switched) | ||
# DONE: pre-migration change noupdate | ||
|
||
NEW ir.ui.view: point_of_sale.assets_common | ||
NEW ir.ui.view: point_of_sale.pos_rounding_form_view_inherited | ||
NEW ir.ui.view: point_of_sale.qunit_suite | ||
NEW ir.ui.view: point_of_sale.qunit_suite_assets | ||
NEW ir.ui.view: point_of_sale.qunit_suite_tests | ||
DEL ir.ui.view: pos_cash_rounding.assets | ||
DEL ir.ui.view: pos_cash_rounding.pos_config_view_form_inherit_cash_rounding | ||
DEL ir.ui.view: pos_cash_rounding.pos_order_view_form_inherit_cash_rounding | ||
DEL ir.ui.view: pos_cash_rounding.pos_rounding_form_view_inherited | ||
DEL ir.ui.view: pos_cash_rounding.res_config_view_form_inherit_pos_cash_rounding | ||
DEL ir.ui.view: pos_reprint.assets | ||
DEL ir.ui.view: pos_reprint.pos_config_view_form_inherit_pos_reprint | ||
# NOTHING TO DO |