Skip to main content

Allows managing barcode readers with simple scenarios

Project description

License: AGPL-3

Stock Scanner : WorkFlow engine for scanner hardware

This module allows managing barcode readers with simple scenarios:

  • You can define a workflow for each object (stock picking, inventory, sale, etc)

  • Works with all scanner hardware model (just SSH client required)

Some demo/tutorial scenarios are available in the “demo” directory of the module. These scenarios, are automatically imported when installing a new database with demo data.

Installation

The odoo-sentinel specific client can be installed from pip:

$ pip install odoo-sentinel

This application is a separate client, and can be run on any device.

For mobile devices, like Windows Mobile or Android smart barcode scanners, we usually install it on a server, accessed through SSH.

To test the module, some modules provide scenario.

Configuration

In Odoo

Declare hardware

You have to declare some hardware scanners in Odoo.

Go to “Inventory > Configuration > Scanner Configuration > Scanner Hardware” and create a new record.

The “step type code” sent by the “odoo-sentinel” client at start-up is the IP address of the hardware, if connected through SSH.

If needed enable Login/Logout

The module comes with 2 predefined scenarii for Login and Logout. The functionality is disabled by default and the user to use in Odoo must be specified in the .odoorpcrc file used by odoo-sentinel and can be overriden on the Scanner Hardware definition in Odoo.

If the Login/logout functionality is enabled, when a user starts a session with odoo-sentinel, only the Login scenario is displayed on the screen. The scenario will prompt the user for its login and pwd. If the authentication succeeds, each interaction with Odoo will be done using the uid of the connected user. Once connected, a Logout scenario is displayed in the list of available scenarii and the Login scenario no longer appears.

The Login/logout functionality enables you to specify on the scenario a list of users and/or a list of groups with access to the scenario.

To enable the Login/logout functionality:
  • Go to “Settings > Warehouse” and check the checkbox Login/logout scenarii enabled.

  • Create a Technical User ‘sentinel’ without roles in Human Resources and with ‘Sentinel: technical users’ checked.

  • Use this user to launch your odoo-sentinel session.

Be careful, the role Sentinel: technical users is a technical role and should only be used by sentinel.

The timeout of sessions is managed by a dedicated cron that resets the inactive sessions. The timeout can be configured on settings. “Settings > Warehouse”

For the odoo-sentinel client

The odoo-sentinel client uses an OdooRPC profile to connect to Odoo. The default configuration file is ~/.odoorpcrc, but this can be customized, using the -c/–config argument. See the hardware/odoorpcrc.sample file for an example.

If the -p/–profile argument is not given on the command line, a profile named sentinel will be used.

The file used to log errors can be defined by using the -l/–log-file argument, which defaults to ~/sentinel.log.

Note : If you want to copy the application outside this git repository, you will need to copy the i18n folder too.

Autoconfiguration feature

The odoo-sentinel client has an autoconfiguration feature, used to automatically recognize the hardware being connected. During initialization, the odoo-sentinel client tries to detect an SSH connection, and sends the terminal’s IP address as terminal code. If the IP address is found on the code field on a configured hardware in the database, this hardware configuration will automatically be used. If the IP address is not found, the client will ask the user to type (or scan) a code.

This can be used only if the Odoo server and the connected hardware are on the same network.

Writing scenario

Creation

The preferred way to start the creation of a scenario is to create steps and transitions in diagram view.

Once your steps are created, you can write python code directly from Odoo, or you can export the scenario to write the python code with your preferred code editor.

In the python code of each step, some variables are available :
  • cr : Cursor to the database

  • uid : ID of the user executing the step (user used to log in with the sentinel, or user configured on the hardware, if any)

  • pool : Pooler to the database

  • env : Environment used to execute the scenario (new API)

  • model : Pooler on the model configured on the scenario

  • term : Recordset on the current scenario

  • context : Context used on the step

  • m or message : Last message sent by the hardware

  • t or terminal : Browse record on the hardware executing the step

  • tracer : Value of the tracer of the used transition to access this step

  • wkf or workflow : Workflow service

  • scenario : Recordset on the current scenario for the hardware

  • _ : The translation function provided by Odoo (useable like in any other python file)

Some of these variables are also available on transition conditions execution.

As stated previously, the step must always return:

  • A step type code, in the act variable

  • A message to display on the hardware screen, in the res variable

  • Optionally, a default value, in the val variable

Step types

The step types are mostly managed by the client.

The standard step types are :

  • M : Simple message

  • F : Final step, like M, but ends the scenario

  • T : Text input

  • N : Number input (integer)

  • Q : Quantity input (float)

  • L : List

  • E : Error message, like M, but displayed with different colors

  • C : Confirm input

  • A : Automatic step. This type is used to automatically execute the next step

Import

Scenarios are automatically imported on a module update, like any other data. You just have to add the path to your Scenario_Name.scenario files in the data or demo sections in the __manifest__.py file.

Export

The export script is in the script directory of the module

A scenario is exported as a set of files, containing :
  • Scenario_Name.scenario : Global description of the scenario (name, warehouses, steps, transitions, etc.)

  • A .py file per step : The name of the file is the XML ID of the step

Using a test file

When developing scenarios, you will often have the same steps to run. The odoo-sentinel client allows you to supply a file, which contains the keys pressed during the scenario.

You can define the file to use in the -t/–test-file argument. This file will be read instead of calling the curses methods when the scenario is waiting for a user input (including line feed characters). When the file has been fully read, the client exits.

A sample test file can be found in the “Step Types” demo scenario.

Special keys : For special keys (arrows, delete, etc.), you must write a line containing ‘:’, followed by the curses key code.

Valid key codes are :
  • KEY_DOWN : Down arrow

  • KEY_UP : Up arrow

  • KEY_LEFT : Left arrow

  • KEY_RIGHT : Right arrow

  • KEY_BACKSPACE : Backspace

  • KEY_DC : Delete

Usage

On start-up, the client lists available scenarii. When the user selects a scenario, the current scenario and step are stored on the hardware configuration’s entry in Odoo.

When the client sends a message to the server, the next step is selected depending on the current step and the message sent. Then, the server returns the result of the step, which contains its type code and the text to display on the hardware screen. Unlike the standard Odoo Workflow, each step needs to find a valid transition, because a step needs to be displayed on the hardware screen at all times.

Try me on Runbot

A client for the Datalogic PowerScan scanners was developped for a very early version or this module. The files have been removed, but are still available in the git repository history.

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.

Credits

Images

  • Odoo Community Association: Icon.

Contributors

Maintainer

Odoo Community Association

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file odoo12_addon_stock_scanner-12.0.1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo12_addon_stock_scanner-12.0.1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b53c69ab770d129cac1680863a4c9627e1efd02cb8725a0799003da73178c46c
MD5 b3f1b7de8948bd71eea8264e7f68959b
BLAKE2b-256 e449ac77f71fb573878eadc6fb27620a223f62f46aa55b67e55bc5f8fde81aa6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page