Wednesday 24 August 2011

Making Sequence and Using default dictionary

showing date as default only year (if the year field is in integer format)

'year' : lambda *a: int(time.strftime('%Y')),

******************
making default date as system

'pay_date': lambda self, cr, uid, context: time.strftime('%Y-%m-%d'),

*******************
making default selection value 'basis' to show

'basis': 'order_booking', #no use of lambda here

*******************************
making Sequence field

'name': fields.char('Ls #', size=64, required=True, select=True),
#in default
'name':lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'ls.master'),

#in xml
<!-- Sequence -->
        <record id="seq_type_ls_master" model="ir.sequence.type">
            <field name="name">ls.master</field>
            <field name="code">ls.master</field>
        </record>

        <record id="seq_ls_master" model="ir.sequence">
            <field name="name">ls.master</field>
            <field name="code">ls.master</field>
            <field name="prefix">Ls</field>
            <field name="padding">3</field>
        </record>
       
_________________________________________________________________

Tuesday 9 August 2011

Creating Openerp buttons

Buttons are declared in xml file like :
<button name=""
              string="Approve"
              type="object"
              icon="gtk-apply" />

it has 'name' attribute where you declare the name of the function which you want to call as you described in the python file.
The 'string' attribute use to declare the name of the button which you want to show.
The 'type' attribute has two (mainly used) values 'object' and 'action'.
The 'icon' attribute use to show different button icon labels.

Here is another example that contains 'special' attribute and no 'name' attribute
When the cancel button is pressed it will automatically close the window without saving.
<button   string="Cancel"
                special="cancel"
                type="object"
                icon="gtk-cancel"/>

In addition there are also other attributes like 'confirm' 'states' e.t.c

Making Wizard

Wizards describe interaction sequences between the client and the server.
A wizard is a succession of steps. A step is composed of several actions;
1. send a form to the client and some buttons
2. get the form result and the button pressed from the client
3. execute some actions
4. send a new action to the client (form, print, ...)

Specifically, wizards can be created just like normal forms, here i am telling the easiest way to experience it all you have to do is to make your python class inherited from (osv.osv_memory) declare all the fields normally as you do.
In the xml where you defined the action for the form just add
<field name="target">new</field>
it will open the wizard in a new window.

Mind it there is another way of creating wizards that use wizard.interface
which i will cover later

Saturday 16 July 2011

Creating First Module

I am using Ubunto, postgres,pgadmin III administration tool and Aptana Studio 3 as openErp framework.
To create a module First create a folder in openErp Server/bin/addons, let say "my_module"
in that folder create
1. __init__.py python module descriptor file, in that class import your python main functional class like "import myclass" as you will name the python file in next step.

2. Create a python file save as myclass. This class will contain your main functionality.

3. Create  __openerp__.py file that is your module descriptor file which determines xml files that will be parsed during initialization of server, and the dependencies of the created module. for help see any __openerp__.py file of any module present in the addons folder.

4. Create an xml file for initialization, demonstration or any reports, wizards, workflows declaration. for help see xml file of any module present in the addons folder.

5. add your xml file name in the  __openerp__.py file in update_xml

These are the main steps that will you do whenever you create a new module. Start the openerp server then the client then go to administration, update module list, after update search your module in the module's list then schedule upgrade it, start configuration and you will see you module in the menu.

Once you have created a module you can also modify it but whenever you make a change in your python file you have to restart server plus update your module configuration and if you modify xml file then there is no need to restart the server just update your module.

Tuesday 12 July 2011

More about Open ERP

OpenERP is a Client/Server system that works over a IP Network.
• OpenERP programming language is Python.
• OpenERP uses Object-Oriented technologies.
• OpenERP records its data with a PostgreSQL relational database.
• OpenERP business objects are modeled with an Object Relational Mapping (ORM) system.
• OpenERP offers three Human Machine Interfaces (HMI) a GTK client, a QT client and a web client (eTiny).
• OpenERP uses ReportLab for report generation in (PDF).
• OpenERP uses XML for several purpose: describing data, view, reports, data transport (XML-RPC)

OpenErp is not easy to learn because of the lack of training material on web, for the developer assistance you can see openobject developer book and technical momento, where you can see developing semantics of the openerp.

Tuesday 5 July 2011

Python programming language

Developed by Guido van Rossum in early nineties, The features that make it attractive is that it is dynamically typed, concise and compact. well, i am personally used to with Java.
It is important to note that asserting that a programmer can be more productive in Python than in Java, is not the same as asserting that one ought always to use Python and never to use Java. Programming languages are tools, and different tools are appropriate for different jobs. It is a poor workman whose toolbox contains only a hammer (no matter how big it is!), and it is a poor programmer (or software development organization) whose development toolkit contains only one programming language. Our toolboxes should contain both Python and Java, so that in any given situation we have the option of choosing the best tool for the job. So our claim is not that Python is the only programming language that you’ll ever need — only that the number of jobs for which Python is the best tool is much larger than is generally recognized.

Start working on Open ERP



Starting with OpenErp is an entirely new experience for me, to do so i have gone through firstly with Python language and xml, all it needs is basics not the core! you can see
www.tutorialspoint.com for python all you have to cover is basics and some advnace topics like classes & objects.
cover xml basics from w3schools.com.

OpenErp is a modern Enterprise management software released under the AGPL license and featuring CRM, HR, Sales, Accounting, manufacturing e.t.c.
"A modular, scalable and intuitive Rapid Application development framework written in Python."