experimental Package

This package store experimental features of openerp-proxy project usualy implemented as extensions or plugins.

Warning

Ususaly code placed here have no tests and might be changed or moved to other packages. Even it may not work!

Use this functionality on your own risk!

experimental.ipy_utils Module

This module contains some IPython integration utils

openerp_proxy.experimental.ipy_utils.in_progress(seq, msg='Progress: [%(processed)d / %(total)d]', length=None, close=True)[source]

Iterate over sequence, yielding item with progress widget displayed. This is useful if you need to precess sequence of items with some time consuming operations

Note

This works only in Jupyter Notebook

Note

This function requires ipywidgets package to be installed

Parameters:
  • seq – sequence to iterate on.
  • msg (str) –

    (optional) message template to display. Following variables could be used in this template:

    • processed
    • total
    • time_total
    • time_per_item
  • length (int) – (optional) if seq is generator, or it is not possible to apply ‘len(seq)’ function to ‘seq’, then this argument is required and it’s value will be used as total number of items in seq.

Example example:

import time
for i in in_progress(range(10)):
    time.sleep(1)

experimental.onchange Module

Implement onchange related logic for Odoo 8.0+ onchanges api

class openerp_proxy.experimental.onchange.ObjectOnchangeUtils(service, object_name)[source]

Bases: openerp_proxy.experimental.utils.ObjectUtils

find_onchanges(view_info=None)[source]

Find onchange spec for specified model and view

Parameters:view_info (dict) – result of model’s fields_view_get or get_view_info method
Returns:dict of format {‘field’: bool(have onchange)}
parse_model_subfields(fields)[source]

returns tuple: tuple({model: [fields]}, model_fields, related_fields)

process_onchanges(data, fields=None, view_info=None, context=None)[source]

Run onchanges

Parameters:
  • data (dict) – data to be processed by onchanges
  • fields (list) – list of changed fields (optional)
  • view_info (dict) – result of model’s fields_view_get or get_view_info method (optional)
  • context (dict) – context to prcess onchanges within (optional)
Returns:

result of onchange events

process_onchanges_r(data, fields=None, view_info=None, keep_fields=None, context=None)[source]
process_onchanges_x(data, *args, **kwargs)[source]

Same as process_onchanges but applies convert_to_write method to its result

experimental.relations Module

This module contains functions and classes that could be used to get information abour record relations

class openerp_proxy.experimental.relations.RecordListRelations(obj, ids=None, fields=None, cache=None, context=None)[source]

Bases: odoo_rpc_client.orm.record.RecordList

Find all links to all records from other models

class openerp_proxy.experimental.relations.RecordRelations(obj, rid, cache=None, context=None)[source]

Bases: odoo_rpc_client.orm.record.Record

Find all links to this record

get_rel_data_domain(field)[source]
class openerp_proxy.experimental.relations.RelationsObject(service, object_name)[source]

Bases: odoo_rpc_client.orm.object.Object

Get a dictionary {<model>: RecordList(‘ir.model.fields’)} which contains related models, and list of relational fields that points to specified model

Get related models for specified model

return RecordList(‘ir.model’) which contains models related to specified model

experimental.utils Module

class openerp_proxy.experimental.utils.ObjectUtils(service, object_name)[source]

Bases: odoo_rpc_client.orm.object.Object

convert_to_write(data)[source]

Simple function that adapts data, to be suitable for odoo write functions.

At this moment used mostly to adapt results of odoo’s onchange model method.

Parameters:data (dict) – data to be converted
Returns:data suitable for Odoo’s create/write methods
get_view_info(view_id=None)[source]

Get view_info for specified model (result of fields_view_get)

if view_id is not passed, default model view is used if view_id is string, than it is assumed that it is xmlid of view

Parameters:
  • model (str) – string model name (Ex. ‘account.invoice’)
  • view_id (int|str) – integer ID or xmlid of view to get info for
Returns:

result of model’s fields_view_get