### Install OpenUpgrade Library using pip Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/odoo/openupgrade/doc/source/migration_details.rst This command installs the latest version of the openupgradelib from GitHub using pip. Ensure you have pip installed and configured correctly to fetch packages from Git repositories. ```bash $ pip install git+git://github.com/OCA/openupgradelib.git ``` -------------------------------- ### Defining a Client Action Widget Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/web/doc/module.rst Provides an example of a JavaScript widget used for a client action. The widget's 'start' method is used to add content to its DOM, controlling the page's display. ```javascript openerp.web_example.ExampleWidget = openerp.web.Widget.extend({ start: function() { this.$el.append($('
').text('Hello from my widget!')); } }); ``` -------------------------------- ### Asynchronous Widget Start Method in JavaScript Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/web/doc/client_action.rst This example illustrates the 'start' method for a client action widget, handling asynchronous operations. It returns a $.Deferred and uses $.when to manage multiple deferred operations, including reading a 'res.widget' object. ```javascript start: function () { return $.when( this._super(), // Simply read the res.widget object this action should display new instance.web.Model('res.widget').call( 'read', [[this.widget_id], ['title']]) .then(this.proxy('on_widget_loaded'))); } ``` -------------------------------- ### Install OpenUpgrade Library using pip Source: https://github.com/tickernelz/openupgrade/blob/main/13.0/odoo/openupgrade/doc/source/migration_details.rst Installs the latest version of the OpenUpgrade library from GitHub using pip or pip3. This ensures you have the most recent updates and fixes for the migration tool. ```shell $ pip/pip3 install git+git://github.com/OCA/openupgradelib.git ``` -------------------------------- ### Creating a Client Action Widget - JavaScript Source: https://github.com/tickernelz/openupgrade/blob/main/13.0/addons/web/doc/module.rst Provides an example of a client action widget in OpenUpgrade. This widget replaces the default client action and adds custom content to the page's DOM using its 'start' method. ```javascript openerp.web_example.ExampleActionWidget = openerp.web.Widget.extend({ start: function() { this.$el.text('Hello from Example Action Widget!'); return $.when(); } }); ``` -------------------------------- ### Asynchronous Widget Initialization with Data Fetching Source: https://github.com/tickernelz/openupgrade/blob/main/13.0/addons/web/doc/client_action.rst This JavaScript snippet shows how to implement the start method for an OpenERP Web Widget. It uses Promise.all to concurrently execute the superclass's start method and asynchronously fetch data for a 'res.widget' object using a model's 'read' call, then proxies the result to 'on_widget_loaded'. ```javascript start: function () { return Promise.all([ this._super(), // Simply read the res.widget object this action should display new instance.web.Model('res.widget').call( 'read', [[this.widget_id], ['title']]) .then(this.proxy('on_widget_loaded')) ]); } ``` -------------------------------- ### Install OpenUpgrade Library Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/odoo/openupgrade/doc/source/API.rst Installs the OpenUpgrade library using pip. This is a prerequisite for using the library in Python scripts for migration tasks. ```bash pip install openupgradelib ``` -------------------------------- ### JavaScript: Basic Testing Structure Setup Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/web/doc/module.rst Demonstrates the initial steps for setting up a JavaScript testing environment. This includes creating a test file, defining a test section with sample tests, and registering the test file within the module's manifest. ```javascript openerp.test_suite = openerp.test_suite || {}; openerp.test_suite.tickernelz = function (test) { test.ok(1, 'this is a test'); }; ``` -------------------------------- ### JavaScript: Initialize Widget and Load Data Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/web/doc/module.rst Overrides the `start` method of an OpenERP widget to perform asynchronous initialization. It fetches previously recorded data using `openerp.web.Query` and appends it to an ordered list within the widget's template. ```javascript openerp.tickernelz.Clicker.include({ start: function () { var self = this; this._super.apply(this, arguments); return new openerp.web.Query(this, [ ['user_id', '=', openerp.web.session.uid] ]) .filter(['id', 'duration', 'user_id']) .all().then(function (records) { _.each(records, function (record) { self.add_record(record); }); }); } }); ``` -------------------------------- ### Manage Onboarding Steps for Payment Providers Source: https://github.com/tickernelz/openupgrade/blob/main/17.0/openupgrade_scripts/scripts/account_payment/17.0.2.0/upgrade_analysis_work.txt This snippet shows the creation (NEW) of an onboarding step related to payment providers. This addition helps guide users through the setup process for payment services within the application, with a note indicating no further action was required. ```plaintext NEW onboarding.onboarding.step: account_payment.onboarding_onboarding_step_payment_provider (noupdate) # NOTHING TO DO ``` -------------------------------- ### State Machine Initialization: Default 'none' state (JavaScript) Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/base_import/static/lib/javascript-state-machine/README.md Explains the default initialization behavior of a state machine when no initial state is specified. In this case, the machine starts in the 'none' state, requiring an explicit event (like 'startup') to transition to an initial defined state. The example shows creating a machine and triggering the 'startup' event. ```javascript var fsm = StateMachine.create({ events: [ { name: 'startup', from: 'none', to: 'green' }, { name: 'panic', from: 'green', to: 'red' }, { name: 'calm', from: 'red', to: 'green' }, ]}); alert(fsm.current); // "none" fsm.startup(); alert(fsm.current); // "green" ``` -------------------------------- ### Basic JavaScript Test File Setup Source: https://github.com/tickernelz/openupgrade/blob/main/13.0/addons/web/doc/module.rst Demonstrates the basic structure for creating a JavaScript test file within an OpenERP module. This involves defining a test section and including a few initial tests to verify the test runner is functioning correctly. ```javascript openerp.testing.add("web_timer", [ // ... tests will go here ]); ``` -------------------------------- ### Install Etherpad-lite Plugin with npm Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/pad/static/plugin/ep_disable_init_focus/README.md This command installs the 'ep_disable_init_focus' plugin for Etherpad-lite. Ensure your Etherpad-lite server is stopped before running this command. It requires Node.js and npm to be installed. ```sh npm install node_modules/ep_disable_init_focus/ ``` -------------------------------- ### Defining a QWeb Template for Widget Rendering Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/web/doc/module.rst Integrates a QWeb template file into the widget's rendering process. QWeb is OpenERP Web's template language, offering special integration with OpenERP Web widgets and features not always found in other templating engines. ```xml
Hello World
``` -------------------------------- ### Install Etherpad-lite Plugin with npm Source: https://github.com/tickernelz/openupgrade/blob/main/13.0/addons/pad/static/plugin/ep_disable_init_focus/README.md This command installs the ep_disable_init_focus plugin into your Etherpad-lite installation. Ensure your Etherpad-lite server is stopped before running this command. It adds the plugin to your project's dependencies. ```sh npm install node_modules/ep_disable_init_focus/ ``` -------------------------------- ### HTML Template Structure for System Information Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/hw_posbox_homepage/views/homepage.html This HTML template is designed to display various system and device information. It uses Jinja2 templating syntax to dynamically render data such as hostname, version, IP address, MAC address, network status, and IoT device details. It also includes links for configuration, updates, and accessing other features. ```html {% extends "layout.html" %} {% block head %} table { width: 100%; border-collapse: collapse; } table tr { border-bottom: 1px solid #f1f1f1; } table tr:last-child { border-width: 0px; } table td { padding: 8px; border-left: 1px solid #f1f1f1; } table td:first-child { border-left: 0; } td.heading { font-weight: bold; vertical-align: top; width: 30%; text-align: left; } .device-status { margin: 6px 0; } .device-status .message { font-size: 0.8rem; max-width: 350px; } .device-status .indicator { margin-left: 4px; font-size: 0.7rem; text-transform: uppercase; } .device-status .device { font-weight: 500; } .collapse .collapsible{ border: 1px solid #f1f1f1; } .collapse .title { position: relative; color: #00a09d; cursor: pointer; padding: 8px; } .collapse .active, .collapse .title:hover { background-color: #f1f1f1; color: #006d6b; } .collapse .content { padding: 0 8px; max-height: 0; overflow: hidden; transition: max-height 0.2s ease-out; } .arrow-down::after { content: '\25bc'; padding: 0 10px; position: absolute; right: 0; } .arrow-up::after { content: '\25b2'; padding: 0 10px; position: absolute; right: 0; } {% endblock %} {% block content %} Your IoT Box is up and running ------------------------------ Name {{ hostname }} [configure](/server) Version {{ version }} [update](/hw_proxy/upgrade/) IP Address {{ ip }} Mac Address {{ mac }} Network {{ network_status }} [configure wifi](/wifi) Server [{{ server_status }}]({{ server_status }})[configure](/server) IOT Device {% if iot_device_status|length == 0 %} No Device Found {% endif %} {% for iot_devices in iot_device_status|groupby('type') %} {{ iot_devices.grouper|capitalize }}s {% for device in iot_devices.list %} {{ device['name'] }} {{ device['message'] }} {% endfor %} {% endfor %} [drivers list](/list_drivers) [POS Display](/point_of_sale/display) [Remote Debug](/remote_connect) [Printers server](http://{{ ip }}:631) {% if server_status != "Not Configured" %} [Credential](/list_credential) {% endif %} {% endblock %} ``` -------------------------------- ### Calendar Event Ordering Update Source: https://github.com/tickernelz/openupgrade/blob/main/14.0/openupgrade_scripts/scripts/calendar/14.0.1.0/upgrade_analysis_work.txt Updates the ordering of calendar events from 'id desc' to 'start desc'. This change aims to order events by their starting date, providing a more intuitive display. ```python calendar / calendar.event / _order : _order is now 'start desc' ('id desc') # NOTHING TO DO: ordered by starting date ``` -------------------------------- ### Remove Old Property and Installer Access Rights Source: https://github.com/tickernelz/openupgrade/blob/main/18.0/openupgrade_scripts/scripts/base/18.0.1.3/upgrade_analysis_work.txt This snippet shows the removal of 'ir.model.access' entries related to 'ir.property' and 'res.config_installer'. This indicates that access control for system properties and the configuration installer has been changed or deprecated. ```xml DEL ir.model.access: base.access_ir_property_group_system DEL ir.model.access: base.access_ir_property_group_user DEL ir.model.access: base.access_res_config_installer ``` -------------------------------- ### JavaScript QWeb Template Rendering and Testing Utilities Source: https://github.com/tickernelz/openupgrade/blob/main/13.0/addons/web/static/lib/qweb/qweb-test.js.html This snippet contains JavaScript functions for rendering QWeb templates and setting up automated QUnit tests. It includes a QWeb2 engine instance, a trim function for cleaning output, and a render function. The `test` function sets up QUnit modules and tests, loading templates and comparing rendered output against expected results. Dependencies include QWeb2 and QUnit. ```javascript var QWeb = new QWeb2.Engine(); function trim(s) { return s.replace(/(^\s+|\s+$)/g, ''); } function render(template, context) { return trim(QWeb.render(template, context)).toLowerCase(); } /** * Loads the template file, and executes all the test template in a * qunit module $title */ function test(title, template) { QUnit.module(title, { setup: function () { var self = this; this.qweb = new QWeb2.Engine(); QUnit.stop(); this.qweb.add_template(template, function (_, doc) { self.doc = doc; QUnit.start(); }) } }); QUnit.test('autotest', function (assert) { var templates = this.qweb.templates; for (var template in templates) { if (!templates.hasOwnProperty(template)) { continue; } // ignore templates whose name starts with _, they're // helpers/internal if (/^\_/.test(template)) { continue; } var params = this.doc.querySelector('params#' + template); var args = params ? JSON.parse(params.textContent) : {}; var results = this.doc.querySelector('result#' + template); assert.equal(trim(this.qweb.render(template, args)), trim(results.textContent), template); } }); } $(document).ready(function() { test("Output", 'qweb-test-output.xml'); test("Context-setting", 'qweb-test-set.xml'); test("Conditionals", 'qweb-test-conditionals.xml'); test("Attributes manipulation", 'qweb-test-attributes.xml'); test("Template calling (to the faraway pages)", 'qweb-test-call.xml'); test("Foreach", 'qweb-test-foreach.xml'); test("Global", 'qweb-test-global.xml'); test('Template inheritance', 'qweb-test-extend.xml'); }); ``` -------------------------------- ### JavaScript Option Customization Example Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/website/doc/website.snippet.rst Demonstrates how to define custom methods within JavaScript options for customizing HTML snippets. The example shows the 'check_class' and 'selectClass' methods, which can be triggered by data attributes in HTML list items. ```javascript // Example custom methods within a JavaScript option object // ... other methods like _setActive, start, onFocus, etc. check_class(type, className, $li) { // Toggle the className on $target based on data-check_class attribute this.$target.toggleClass(className); }, selectClass(type, className, $li) { // Remove other 'selectClass' values and add the current one // ... implementation details ... } // Example HTML for triggering these methods: //
  • Apply Style
  • ``` -------------------------------- ### Creating a JavaScript Module with Instance Access Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/web/doc/module.rst Shows how to define a JavaScript module that runs within the OpenERP web client context. It receives an 'instance' parameter, providing access to the client's APIs. ```javascript openerp.web_example = function(instance) { var self = this; instance.web.action_handlers.client_action = function(action) { console.log('Web Example module loaded!'); return self.action_manager.do_action(action); }; }; ``` -------------------------------- ### Basic OpenUpgrade Module Structure - Text Source: https://github.com/tickernelz/openupgrade/blob/main/13.0/addons/web/doc/module.rst Defines the minimal directory structure for a basic OpenUpgrade module, consisting of __init__.py and __manifest__.py files. ```text web_example ╰__init__.py ╰__manifest__.py ``` -------------------------------- ### Implementing Stopwatch Logic in OpenERP JavaScript Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/web/doc/module.rst Adds core logic for a stopwatch widget, including initialization, time difference calculation, display updates, starting, stopping, and clearing intervals to prevent memory leaks. It manages internal variables like start time and update tickers. ```javascript var StopwatchWidget = openerp.web.Widget.extend({ init: function() { this._super.apply(this, arguments); this._start = null; this._watch = null; }, update_counter: function() { // Calculate and format time difference }, watch_start: function() { this._start = new Date(); this._watch = setInterval(this.update_counter, 33); }, watch_stop: function() { clearInterval(this._watch); this.update_counter(); this._start = null; this._watch = null; }, destroy: function() { clearInterval(this._watch); this._super(); } }); ``` -------------------------------- ### Basic OpenERP Module Structure Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/web/doc/module.rst Defines the minimal file structure for a valid OpenERP module, consisting of an __init__.py and an __manifest__.py file. ```text web_example ├── __init__.py └── __manifest__.py ``` -------------------------------- ### Get String Representation with py.PY_str in JavaScript Source: https://github.com/tickernelz/openupgrade/blob/main/13.0/addons/web/static/lib/py.js/doc/utility.rst py.PY_str computes and returns the string representation of a py.object. This function is equivalent to calling str() on a Python object. ```javascript var stringRepresentation = py.PY_str(myObject); ``` -------------------------------- ### JavaScript Module Initialization - JavaScript Source: https://github.com/tickernelz/openupgrade/blob/main/13.0/addons/web/doc/module.rst Shows the structure of a JavaScript module for OpenUpgrade, designed to be loaded and initialized by the web client. It receives an 'instance' object providing access to the web client's APIs. ```javascript openerp.web_example = function(instance) { var module = instance.module.web_example; // Your module code here console.log('Web Example module loaded'); }; ``` -------------------------------- ### Create Window Actions (XML) Source: https://github.com/tickernelz/openupgrade/blob/main/14.0/openupgrade_scripts/scripts/website_event_track/14.0.1.1/upgrade_analysis_work.txt This section defines new window actions (`ir.actions.act_window`) for various models within the `website_event_track` module. These actions likely provide user interfaces for managing sponsors, tracks, visitors, and tags. ```XML NEW ir.actions.act_window: website_event_track.event_sponsor_action_from_event NEW ir.actions.act_window: website_event_track.event_sponsor_type_action NEW ir.actions.act_window: website_event_track.event_track_action_from_visitor NEW ir.actions.act_window: website_event_track.event_track_tag_category_action NEW ir.actions.act_window: website_event_track.event_track_visitor_action NEW ir.actions.act_window: website_event_track.website_visitor_action_from_track ``` -------------------------------- ### Get Length of Object - py.len() Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/web/static/lib/py.js/doc/builtins.rst Returns the length (number of items) of an object. This is analogous to Python's built-in len() function. ```python py.len(object) ``` -------------------------------- ### Initialize State Machine with Deferred Event (JavaScript) Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/base_import/static/lib/javascript-state-machine/README.md Demonstrates initializing a state machine where the initial event is deferred. This allows for setup before the first state transition occurs. The `defer: true` option delays the execution of the initial event until `fsm.init()` is called. ```javascript var fsm = StateMachine.create({ initial: { state: 'green', event: 'init', defer: true }, events: [ { name: 'panic', from: 'green', to: 'red' }, { name: 'calm', from: 'red', to: 'green' }, ]}); alert(fsm.current); // "none" fsm.init(); alert(fsm.current); // "green" ``` -------------------------------- ### Load Openupgrade Framework Module (Shell) Source: https://github.com/tickernelz/openupgrade/blob/main/18.0/openupgrade_framework/README.rst This snippet demonstrates how to load the openupgrade_framework module along with other essential modules when starting an Odoo instance via the command line. ```shell odoo --load=base,web,openupgrade_framework ``` -------------------------------- ### Get String Representation of py.js Object Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/web/static/lib/py.js/doc/utility.rst PY_str computes and returns the string representation of a py.js object 'o'. The returned value is a py.str object, equivalent to calling str(o) in Python. ```javascript var string_representation = py.PY_str(my_py_object); ``` -------------------------------- ### HTML Structure and Jinja Templating Source: https://github.com/tickernelz/openupgrade/blob/main/12.0/addons/hw_posbox_homepage/views/configure_wizard.html This HTML snippet defines the structure of a configuration page, utilizing Jinja templating for dynamic content. It includes placeholders for loading indicators, error messages, and redirect countdowns. The structure is designed to work with the accompanying JavaScript for step navigation. ```html {% extends "layout.html" %} {% from "loading.html" import loading_block_ui %} {% block head %} ... {% endblock %} {% block content %} ... {{ loading_block_ui(loading_message) }} {% endblock %} ``` -------------------------------- ### Define Model A with Restricted Many2Many Fields Source: https://github.com/tickernelz/openupgrade/blob/main/14.0/openupgrade_scripts/scripts/test_new_api/14.0.1.0/upgrade_analysis.txt Defines 'model_a', featuring two 'many2many' fields, 'a_restricted_b_ids' and 'b_restricted_b_ids', both relating to 'test_new_api.model_b'. This indicates a restricted relationship setup between these models. ```odoo test_new_api / test_new_api.model_a / a_restricted_b_ids (many2many): NEW relation: test_new_api.model_b test_new_api / test_new_api.model_a / b_restricted_b_ids (many2many): NEW relation: test_new_api.model_b ```