Monday, March 14, 2011

Things to note while migrating OpenERP 5 modules to OpenERP 6 (OpenERP 5 to OpenERP 6 Module Migration)

Pragmatic Techsoft Pvt Ltd. (http://www.pragtech.co.in) has put forward a list of technical changes which need to be taken care while migrating modules from OpenERP 5 to OpenERP 6. This list is no way comprehensive and comments and feedback are welcome.


Wizard

OpenERP V5
1. Both normal and memory wizards are used.
2. Normal Wizard created by single .py file, which is created in wizard folder of our module.
3. To call normal wizard we need following code in .xml file which is outside the wizard folder.
<wizard
            id="wizard_student"
            model="student.student"
            name="student.student.wizard"
            string="Student Detail"/>

4. To call memory wizard we need following code in .xml file which is outside the wizard folder. If we call wizard on button.
<button name="%(act_student_memory_wizard)d" string="Memory Wizard" type="action"/>
OpenERP V6
1. Only memory wizards are used.
2. Wizard in V6 is similar to memory wizard in V5.
3. To call wizard we need following code in .xml file which is outside the wizard folder. If we call wizard on button.
<button name="%(student.act_student_memory_wizard)d" string="Memory Wizard" type="action"/>
4. if we call the wizard through Action menu then we need following code to call given wizard
<act_window name="Student Detail"
            res_model="student.detail.bymarks"
            src_model="student.student"
            key2="client_action_multi"
            multi="True"
            view_mode="form"
            view_type="form"
            target="new"
            id="action_student_onmarks"/>

Search views

OpenERP V5:
1. The only facility of search is there in list view(treeview).
OpenERP V6:
1. Improves over built-in search features in v5
2. Always associated with other view: list, calendar, ...
New view type: <search>
    Two main building blocks:
        • <field name='...'>
        • <filter domain='...' context='...'>
    Structured with:
        • <group>
        • <separator>
        • <newline>
No need of select=”1” or select=”2”,just need select=”True”

<record id="view_sales_order_filter" model="ir.ui.view">
            <field name="name">sale.order.list.select</field>
            <field name="model">sale.order</field>
            <field name="type">search</field>
            <field name="arch" type="xml">
                <search string="Search Sales Order">
                    <filter icon="terp-document-new" string="Quotations" domain="[('state','=','draft')]" help="Sales Order that haven't yet been confirmed"/>
                    <filter icon="terp-check" string="Sales" domain="[('state','in',('manual','progress'))]"/>
                    <separator orientation="vertical"/>
                    <filter icon="terp-dolar_ok!" string="To Invoice" domain="[('state','=','manual')]" help="Sales Order ready to be invoiced"/>
                    <separator orientation="vertical"/>
                    <field name="name" select="1"/>
                    <field name="date_order" select="1" string="Order date" />
                    <field name="partner_id" select="1"/>
                    <field name="user_id" select="1">
                        <filter domain="[('user_id','=',uid)]" help="My Sale Orders" icon="terp-personal"/>
                    </field>
                    <newline/>
                    <group expand="0" string="Group By..." colspan="11" col="11" groups="base.group_extended">
                        <filter string="Customer" icon="terp-personal" domain="[]" context="{'group_by':'partner_id'}"/>
                        <filter string="Salesman" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
                        <separator orientation="vertical"/>
                        <filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
                        <separator orientation="vertical"/>
                        <filter string="Order Date" icon="terp-go-month" domain="[]" context="{'group_by':'date_order'}"/>
                    </group>
             </search>
            </field>
        </record>


<record id="action_order_form" model="ir.actions.act_window">
            <field name="name">Sales Orders</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">sale.order</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form,calendar,graph</field>
            <field name="search_view_id" ref="view_sales_order_filter"/>
            <field name="help">Sales Orders helps you manage quotations and orders done with your customers. OpenERP suggests that you to start by creating a quotation. Once the order is confirmed, the quotation is converted into a Sale Order. OpenERP can handle several types of products so that a sales order can trigger tasks, delivery orders, manufacturing orders, purchases and so on. Based on the configuration of the sale order, a draft invoice will be generated so that you just have to confirm it when you want to bill your customer.</field>
        </record>
        <menuitem action="action_order_form" id="menu_sale_order" parent="base.menu_sales" sequence="3" groups="base.group_sale_salesman,base.group_sale_manager"/>

<fields> with embedded <filters>
    Advanced attributes for <field>:
    • context=”{'country_visible':True}”
    • domain=”[('country_id', '=', 'Belgium')]”
    • filter_domain=”['|', ('location_to', '=', self),
                        ('location_src', '=', self)]”
    Default values for filters and fields, via action context:
    • context=”{'search_default_filter1': True}”
    • context=”{'search_default_field1': 'test'}”
    • context=”{'search_default_field1': lang}”
    Specific search view can be forced in caller action:

<field name="search_view_id" ref="view_sales_order_filter"/>
context attribute of elements can toggle aggregation of associated list views
<filter string="Salesman" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
Multiple group-by levels are supported
    • <filter string="Salesman,State"
                    name="salesman_state"
                    context="{'group_by':['user_id','state']}"/>
    Order of group-by entries matters!

Tree Views


Openerp V5:
1. Normal Tree view is there.
2. We can edit data in columns in tree view, but no buttons are theire to process on selected row.

Openerp V6:
1. List views can now display buttons
        Regular <button> elements as in form views
            Action/Method/Workflow called on single record

    2. Columns can be toggled via context
        • context = {'section_mode': True}
    • <field name=”country_id”
        invisible=”context.get('invisible_country')”>

Diagram views

OpenERP V5:
1. No diagram view is theire.
2. But we can see similar to it in customized workflow

OpenERP V6:
New <diagram> view type
Constructed with
    • <node object=”node.model”
        shape=”...”
            bgcolor=”...”>
    • <arrow object=”transition.model”
                source=”source_field”
                destination=”dest_field” >
    • <field> (included in quick view)
Objects must form a coherent graph
<node> model must have a many2one to its container

<record id="view_marketing_campaign_diagram" model="ir.ui.view">
        <field name="name">marketing.campaign.diagram</field>
        <field name="model">marketing.campaign</field>
        <field name="type">diagram</field>
        <field name="arch" type="xml">
            <diagram string="Campaign Editor">
                <node object="marketing.campaign.activity" shape="rectangle:type=='subcampaign'" bgcolor="gray:start==True">
                    <field name="name"/>
                    <field name="type"/>
                    <field name="start" invisible="1"/>
                    <field name="condition" widget="char"/>
                </node>
                <arrow object="marketing.campaign.transition" source="activity_from_id" destination="activity_to_id" label="['name']">
                    <field name="activity_from_id"/>
                    <field name="activity_to_id"/>
                    <field name="interval_nbr"/>
                    <field name="interval_type"/>
                </arrow>
            </diagram>
        </field>
    </record>

Testing framework: YAML

OpenERP V5:
1. No such Testing framework(.YAML) file used in it.
OpenERP V6:
1. New YAML data serialization supported in v6
2. Data-oriented syntax “YAML Ain't a Markup Language”
3. Whitespace delimiters, Python-like
    Human-readable
        no quotes, brackets, braces, ... by default
    Supports everything supported by XML and more
        Calling internal service such as workflows
            Arbitrary python code
4. When added to the test section of the module descriptor, tests are rolled back by default
    New logging level test for showing test results

    OpenERP supports specific custom types:
    • !record {model: res_model, id: xml_id, context: {...} }
    • !python {model: res_model}
    • !workflow {model:res_model, action:signal, ref: xml_id}
    And equivalents for all XML supported elements
    • !act_window
    • !report
    • !function
    • !menuitem
    • !assert

In order to test Account Journal Select wizard I open journal entries using this wizard
-
    !record {model: account.journal.select, id: account_journal_select_0}:
    {}
-
    I clicked on Open Journal Button to open the entries

-
    !python {model: account.journal.select}: |
    self.action_open_window(cr, uid, [ref("account_journal_select_0")], {"lang":
     'en_US', "active_model": "account.journal.period", "active_ids": [ref("account.a_recv")],
     "tz": False, "active_id": ref("account.a_recv"), })
-
    I check that the entries open successfully

Other Improvements


OpenERP V5:
1.Simpler __terp__ structure: data, demo

2. Security:
        safe_eval
        Private _methods() are callable via RPC
        def _foo(self):
        print “hi all “
3. class for res.partner.function object is present.

OpenERP V6:
1. Simpler __openerp__ structure: data, demo, test

2. API:
        _defaults may be literal
        _constraints, _sql_constraints may be callables
3. Security:
        safe_eval replaced built-in eval
        Private _methods() not callable via RPC
        def _foo(self):
        print “hi all “
        1. if you try to call this method on button ,it will not allow you
            2. so solution for this problem is that do not define function start with _(underscore).

4. Reporting engine more modular (e.g report_webkit)

5. Performance improvements in RML reports
    <blockTable rowHeights="2cm" colWidths="11.0,7.0">
    Smarter translations, cached
6. Actions have new properties:
    help="Business description for this action"
    multi=True
7. Simpler XML declaration for wizards actions
    res.roles => res.groups

8. base_report_designer includes OOo plugin

9. 'View logs' shows XML ID now

10. class for res.partner.function object is not not V6 replace by char field.

Action Help

Openerp V5:
1. There is no facility of help regarding action

Openerp V6:
1. you can specify help of action by following way
<record id="action_tax_code_tree" model="ir.actions.act_window">
            <field name="name">Chart of Taxes</field>
            <field name="res_model">account.tax.code</field>
            <field name="domain">[('parent_id','=',False)]</field>
            <field name="view_type">tree</field>
            <field name="view_id" ref="view_tax_code_tree"/>
            <field name="help">The chart of taxes is used to generate your periodic tax statement. You will see here the taxes with codes related to your legal statement according to your country.</field>
        </record>

No comments:

Post a Comment