India

ZestyBeanz Technologies Pvt Ltd 4th Floor, Nila, Technopark Thiruvananthapuram,
India – 695581
Phone: +91 471 4063254
Fax : +91 471 2700171

   .

ZestyBeanz Technologies Pvt Ltd
61/3236, Manikkath Cross Road
Ravipuram, Kochi, India - 682016
Phone: +91 484 4063254

  UAE

Zesty Labs
Office # 2003, Millennium Plaza Building
Sheikh Zayed Rd, Dubai, UAE
Phone: +971 4333 2222​
Mobile: +971-52-7553466

  Germany​

ZestyBeanz Technologies GmbH
Reuterstraße 1
90408 Nürnberg
Fon: +49 911 4801 444
Fax: +49 911 4801 445

Contact Form


Shelton's picture

Basics of developing a simple module in OpenERP

OpenObject uses modules as feature containers, to foster maintainable and robust development. The functionality in OpenERP is provided by modules.

Module Composition

A module may contain any of the following elements:

business objects: declared as Python classes extending the osv.osv OpenObject class
data : views, menu, workflows, demo data etc..
wizards : stateful interactive forms
reports : RML (XML format), MAKO or OpenOffice report templates, to be merged with any kind of business data, and generate HTML, ODT or PDF reports.

Module Structure

  A module is created within the server/bin/addons directory


Python Module Descriptor File   [ __init__.py ]


     import module, wizard, report

OpenERP Descriptor File [ __openerp__.py ]


Objects, Fields and Methods
    The data in OpenERP is represented via 'Objects'. Every type of resource in openERP holds an object. OpenERP modeling is based on 'objects' and the data is stored in 'Postgresql' database.



Object Attributes


_name  :  object name   (required)
_columns : dictionary  of object fields    (required)
_defaults  : dictionary of fields holding default values
_inherit   : name of the parent object which the current object inherits from
_constraints  : list of tuples of constraints on the object
_sql_constraints : list of tuples defining the SQL constraints 
_rec_name  : Alternative field to use as name
_auto  : Determines whether a corresponding PostgreSQL table must be generated automatically from the object.


Field Types

Basically, there are 3 types of fields - simple,relational & functional

simple
    boolean
        'active' :fields.boolean('active')
    integer
        'roll_no' : fields.integer('Roll No:)
    float
        'percentage':fields.float('Percentage')

    char
        'name' : fields.char('Name', size=20, required=True),
    text
        'note' : fields.text('Note')
    date
        'date' : fields.date('Date')
    datetime
        'time' : fields.date('Login Time')
    selection
        'gender' : fields.selection((('M','Male'),('F','Female')),'Gender',required=True),
    binary
        'active' : fields.binary('Active')
relational
    many2one - Relationship towards a parent object
        'class': fields.many2one('student.det','class')
   one2many - Virtual relationship towards multiple objects
        'stud_name':fields.many2one('stud.name','Student Name'),
    many2many - Bidirectional multiple relationship between objects
       'mark_list':fields.one2many('stud.mark','stud_rec_id','Mark List')
functional

Functional fields compute the values of the fields dynamically which is executed by a function.

function(fnct, arg=None, fnct_inv=None, fnct_inv_arg=None, type='float', fnct_search=None, obj=None, method=False, store=False, multi=False,...)

ORM Methods  
Parmeters used:
   cr: database connection (cursor)
   uid: id of user performing the operation
   ids: list of record ids, or single integer when there is only one id
   context: optional dictionary of contextual parameters, such as user  language
self.pool.get('object_name')
    can be used to obtain a model class from  anywhere
create(cr, uid, values, context=None)
    Creates a new record with the specified value , Returns: id of the new record 
search(cr, uid, args, offset=0, limit=None, order=None,  context=None, count=False)
    Returns: list of ids of records matching the given criteria
read(cr, user, ids, fields=None, context=None)
Returns: list of dictionaries with requested field values
write(cr, uid, ids, values, context=None)
    Updates records with given ids with the given values.  Returns: True
unlink(cr, uid, ids, context=None)
    Deletes records with the given ids . Returns: True
browse(cr, uid, ids, context=None)
    Fetches records as objects, allowing to use dot-notation to  browse fields and relations Returns: object or list of objects requested


Views
Views describe how objects are exposed to the user. The views are written in XML. There are two types of views- form view and tree view. Following is a form view of the student record:
   

Menus and Actions

Menu

A menuitem is a shortcut for declaring an ir.ui.menu record and  triggering actions defined.

Actions

Actions define the way of the system response according to the user triggering an action like user login, clicking a button, etc..

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo], [[foo]]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.