Package: odoo9-addon-stock-scanner
Stock Scanner : WorkFlow engine for scanner hardwareThis module allows managing barcode readers with simple scenarios:You can define a workfow 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.InstallationThe “sentinel.py” specific ncurses client is available in the “hardware” directory.
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.If you plan to use the specific “sentinel.py”, you will need the “openobject-library” Python module, available from pip:$ sudo pip install “openobject-library<2”NoteYou must use openobject-library earlier than 2.0 with Odoo.
The version 2.0 of openobject-library only implements the Net-RPC protocol, which was removed from v7.To test the module, some modules provide scenario.ConfigurationIn OdooDeclare hardwareYou 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 “sentinel.py” client at start-up is the IP address of the hardware, if connected through SSH.If needed enable Login/LogoutThe module come with 2 predifined scenarii for Login and Logout. The functionality is disabled by default and the user to use in
Odoo must be specified in the .oerp_sentinelrc file used by sentinel and can be overriden on the Scanner Hardware definition
in Odoo.If the Login/logout functionality is enabled, when a user start a session with sentinel, only the Login scenario is displayed on the
screen. The scenario will prompt the user for its login and pwd. If the authentication succeed, 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 more appear.The Login/logout functionality enable 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 aTechnical User‘sentinel’without roles in Human Resourcesand with ‘Sentinel: technical users’ checked.Use this user to launch your sentinel session.Be careful, the roleSentinel: technical usersis a technical role and should only be used by sentinel.The timeout of sessions is managed by a dedicated cron that reset the inactive sessions. The timeout can be configured on
settings. “Settings > Warehouse”For the sentinel.py clientThe sentinel.py client needs a config file in the standardiniformat, which is not automatically created.
This file can be named.oerp_sentinelrc,.openerp_sentinelrcor.odoo_sentinelrc, and can be located in the current working directory, or in the user’s home directory.The user put in the configuration file is used by the sentinel.py client to connect to Odoo.
It can be overriden by hardware by setting theUserfield, to execute steps with the defined user, without having to create a configuration file per used that will need to connect.This file simply contains information for server connection (hostname, port, username, password and database).[openerp]
host = localhost
password = admin
database = demoSee thehardware/odoo_sentinelrc.samplefile for an example.Note: If you want to copy the application outside this git repository, you will need to copy the i18n folder too.Autoconfiguration featureThesentinel.pyclient has an autoconfiguration feature, used to automatically recognize the hardware being connected.
During initialization, thesentinel.pyclient tries to detect an SSH connection, and sends the terminal’s IP address as terminal code.
If the IP address is found on thecodefield 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 scenarioCreationThe 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 databaseuid : 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 databaseenv : Environment used to execute the scenario (new API)model : Pooler on the model configured on the scenariocustom : Pooler on the custom values modelterm : Recordset on the current scenariocontext : Context used on the stepm or message : Last message sent by the hardwaret or terminal : Browse record on the hardware executing the steptracer : Value of the tracer of the used transition to access this stepwkf or workflow : Workflow servicescenario : 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 theactvariableA message to display on the hardware screen, in theresvariableOptionally, a default value, in thevalvariableStep typesThe step types are mostly managed by the client.The standard step types are :M : Simple messageF : Final step, like M, but ends the scenarioT : Text inputN : Number input (integer)Q : Quantity input (float)L : ListE : Error message, like M, but displayed with different colorsC : Confirm inputA : Automatic step. This type is used to automatically execute the next stepNoteThe automatic step often needs to define a value inval, corresponding to the value the user must send.
This step type is generally used as replacement of another type, at the end of the step code, by redefining theactvariable in some cases, for example when a single value is available for a list step.ImportScenarios are automatically imported on a module update, like any other data.
You just have to add the path to yourScenario_Name.scenariofiles in thedataordemosections in the__openerp__.pyfile.ExportThe export script is in thescriptdirectory of the moduleA 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 stepUsing a test fileWhen developing scenarios, you will often have the same steps to run.
The sentinel.py client allows you to supply a file, which contains the keys pressed during the scenario.You can define the file to use in the configuration file, on the “test_file” key.
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 arrowKEY_UP : Up arrowKEY_LEFT : Left arrowKEY_RIGHT : Right arrowKEY_BACKSPACE : BackspaceKEY_DC : DeleteUsageOn 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.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 thegit repository history.Bug TrackerBugs are tracked onGitHub 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 welcomedfeedback.CreditsImagesOdoo Community Association:Icon.ContributorsAlexandre Fayolle <afayolle.ml@free.fr>Christophe CHAUVET <christophe.chauvet@syleam.fr>Damien Crier <damien@crier.me>Laetitia Gangloff <laetitia.gangloff@acsone.eu>Laurent Mignon <laurent.mignon@acsone.eu>Olivier Dony <odo@openerp.com>Sebastien LANGE <sebastien.lange@syleam.fr>Sylvain Garancher <sylvain.garancher@syleam.fr>MaintainerThis 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 visithttps://odoo-community.org.