diff --git a/docsource/modules130-140.rst b/docsource/modules130-140.rst index 24144b917a4c..c68811c64289 100644 --- a/docsource/modules130-140.rst +++ b/docsource/modules130-140.rst @@ -520,7 +520,7 @@ Module coverage 13.0 -> 14.0 +--------------------------------------------+-------------------------------------------------+ |phone_validation | Nothing to do | +--------------------------------------------+-------------------------------------------------+ -|point_of_sale | | +|point_of_sale | Done | +--------------------------------------------+-------------------------------------------------+ |portal | Nothing to do | +--------------------------------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/noupdate_changes.xml b/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/noupdate_changes.xml index 4e39c29f02cc..19b70ca66d66 100644 --- a/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/noupdate_changes.xml +++ b/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/noupdate_changes.xml @@ -1,27 +1,27 @@ - + False - - - - - - - - - - - - - - - - - - + + + + + + diff --git a/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/post-migration.py b/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/post-migration.py new file mode 100644 index 000000000000..a33a842696b7 --- /dev/null +++ b/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/post-migration.py @@ -0,0 +1,65 @@ +from openupgradelib import openupgrade + + +def convert_pos_order_pickings(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 sp + SET pos_session_id = po.session_id + FROM pos_order po + WHERE po.id = sp.pos_order_id + AND sp.pos_session_id IS 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 AND NOT COALESCE(ps.rescue, FALSE) + THEN 'opening_control' + ELSE 'opened' + END + FROM pos_config pc + WHERE pc.id = ps.config_id AND ps.state = 'new_session'; + """, + ) + + +def activate_pos_config_manage_orders(env): + openupgrade.logged_query( + env.cr, + """ + UPDATE pos_config + SET manage_orders = TRUE""", + ) + + +@openupgrade.migrate() +def migrate(env, version): + convert_pos_order_pickings(env) + fill_sesion_on_picking_by_pos_order(env) + set_point_of_sale_update_stock_quantities_to_real(env) + transfer_new_session_state(env) + activate_pos_config_manage_orders(env) + openupgrade.load_data(env.cr, "point_of_sale", "14.0.1.0.1/noupdate_changes.xml") diff --git a/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/pre-migration.py b/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/pre-migration.py new file mode 100644 index 000000000000..a0d4210a7c88 --- /dev/null +++ b/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/pre-migration.py @@ -0,0 +1,44 @@ +from openupgradelib import openupgrade + + +def fill_pos_config_default_picking_type_id(env): + openupgrade.logged_query( + env.cr, + """ + UPDATE pos_config pc + SET picking_type_id = sw.pos_type_id + FROM stock_warehouse sw + WHERE sw.company_id = pc.company_id + AND pc.picking_type_id IS NULL""", + ) + + +def delete_constraint(env): + # Disappeared constraint + openupgrade.delete_sql_constraint_safely( + env, "point_of_sale", "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) diff --git a/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/upgrade_analysis_work.txt new file mode 100644 index 000000000000..afdd831806a5 --- /dev/null +++ b/openupgrade_scripts/scripts/point_of_sale/14.0.1.0.1/upgrade_analysis_work.txt @@ -0,0 +1,105 @@ +---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 / manual_discount (boolean) : NEW hasdefault +point_of_sale / pos.config / module_pos_reprint (boolean) : DEL +# NOTHING TO DO + +point_of_sale / pos.config / manage_orders (boolean) : NEW +# DONE: post-migration: active by default + +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 \ No newline at end of file