0
votes

How to align field at user module in openerp. fields are not properly aligning in my form. follows my code:

xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
    <!-- ===================== This is tree layout =============================-->
    <record id="lis_tree" model="ir.ui.view">
            <field name="name">Lab</field>
            <field name="model">lis.lab</field>
            <field name="arch1" type="xml">
                <tree string="name">
                    <field name = "name"/>
                    <field name = "customer_name" />
                    <field name = "excutive_name" />
                    <field name = "date_birth"/>
                    <field name = "date_delivery" />
                    <field name = "hospital_name"/>
                    <field name = "hospital_city"/>
                    <field name = "hospital_state"/>
                    <field name = "hospital_country"/>
                    <field name = "hospital_phone"/>
                </tree>
            </field>
        </record>
<!-- ========================This is Form layout===============================-->
    <record id="lis_form" model="ir.ui.view">
            <field name="name">Lab</field>
            <field name="model">lis.lab</field>
            <field name="arch1" type="xml">
                <form string="lab" version="7.0">
                    <label for="name" class="oe_edit_only"/>
                    <h1><field name="name"/></h1>
                    <group>
                        <field name = "customer_name" /> <!--on_change="on_change_customer(customer_name)"/>-->
                        <field name = "excutive_name" />
                        <field name = "date_birth"/>
                        <field name = "date_delivery" />
                        <field name = "hospital_name"/>
                        <field name = "hospital_city"/>
                        <field name = "hospital_state"/>
                        <field name = "hospital_country"/>
                        <field name = "hospital_phone"/>
                    </group>
                </form>
           </field>
        </record>
    <!-- ========================= Action Layout ============================= -->
        <record id="action_lab" model="ir.actions.act_window">
            <field name="name">Lab</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">lis.lab</field>
            <field name="view_type">form</field>
            <field name="view_mode">tree,form</field>
            <field name="view_id" ref="lis_form"/>
        </record>
    <!-- ===========================Menu Settings=========================== -->
        <menuitem name = "LIS" id = "menu_lis_lab" action = "action_lab"/>
</data>
</openerp>

python:

from osv import osv from osv import fields

class cus(osv.osv):
 _name = "lis.lab"
 _description = "This table is for keeping lab data of cord blood"
 _columns = {
 'name': fields.char('Lab Id',size=64,required=True),
 'date_birth': fields.char('Customer', size=64),
 'excutive_name': fields.char('Excutive Name', size=64),
 'date_birth': fields.date('Date of Birth'),
 'date_delivery': fields.date('Delivery Date'),
 'hospital_name': fields.char('Hospital', size=64),
 'hospital_city': fields.char('City', size=64),
 'hospital_state': fields.char('State', size=64),
 'hospital_phone': fields.char('Phone', size=64)
}

above codes are working fine. but these fields are randomly viewed like follow

city
customer name
lab id
executive

How can i have the same order as in xml?

2
View of form design in xml how that you make. You can use different form tag, sheet tag, group and div etc. You can make partition like 4 fields and value one side and other side. I don't think so fields view display randomly.If you like this than i will help you make better view compare to current view. - Bhavesh Odedra
i need your help. how to show my application screenshot? - Balakrishnan
Take your screen shot and edit your question you can see that image tag is their below the Title, it gives you to upload your image. - Bhavesh Odedra

2 Answers

1
votes

try this, in your .py file

class cus(osv.osv):
_name = "lis.lab"
_description = "This table is for keeping lab data of cord blood"
_columns = {
    'name': fields.char('Lab Id',size=64,required=True),
    'excutive_name': fields.char('Excutive Name', size=64),
    'date_birth': fields.date('Date of Birth'),
    'date_delivery': fields.date('Delivery Date'),
    'hospital_name': fields.char('Hospital', size=64),
    'hospital_city': fields.char('City', size=64),
    'hospital_state': fields.char('State', size=64),
    'hospital_phone': fields.char('Phone', size=64),
    'customer_name': fields.many2one('res.partner', 'Customer Name', domain=[('customer', '=', True)]),
    'hospital_country': fields.char('Hospital Country'),
}

.xml for view file

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- ===================== This is tree layout =============================-->
<record id="lis_tree" model="ir.ui.view">
        <field name="name">Lab</field>
        <field name="model">lis.lab</field>
        <field name="arch1" type="xml">
            <tree string="name">
                <field name = "name"/>
                <field name = "customer_name" />
                <field name = "excutive_name" />
                <field name = "date_birth"/>
                <field name = "date_delivery" />
                <field name = "hospital_name"/>
                <field name = "hospital_city"/>
                <field name = "hospital_state"/>
                <field name = "hospital_country"/>
                <field name = "hospital_phone"/>
            </tree>
        </field>
    </record>

<!-- ========================This is Form layout===============================-->
<record id="lis_form" model="ir.ui.view">
        <field name="name">Lab</field>
        <field name="model">lis.lab</field>
        <field name="arch" type="xml">
            <form string="lab" version="7.0">
                <sheet>
                    <group cols='4'>
                        <group>
                            <field name="name"/>
                            <field name = "customer_name" /> <!--on_change="on_change_customer(customer_name)"/>-->
                            <field name = "excutive_name" />
                            <field name = "date_birth"/>
                            <field name = "date_delivery" />
                        </group>
                        <group>
                            <field name = "hospital_name"/>
                            <field name = "hospital_city"/>
                            <field name = "hospital_state"/>
                            <field name = "hospital_country"/>
                            <field name = "hospital_phone"/>
                        </group>
                    </group>
                </sheet>
            </form>
       </field>
    </record>

<!-- ========================= Action Layout ============================= -->
    <record id="action_lab" model="ir.actions.act_window">
        <field name="name">Lab</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">lis.lab</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="view_id" ref="lis_form"/>
    </record>
<!-- ===========================Menu Settings=========================== -->
    <menuitem name = "LIS" id = "menu_lis_lab" action = "action_lab"/>
</data>
</openerp>

Hope this will now better look than your view.

0
votes

Please check whether you have specified the xml file path in your __openerp__.py file under the key 'data' or 'update_xml'. for example if your xml is inside your module's wizard folder then in the __openerp__.py file,

{
    'name': 'Module name',
    'version': '1.0',
    'category': 'its category',
    'description': """


If you install this module, then blah blah blah.
    """,
    'author': 'author name',
    'depends': ['base'],#dependent module list
    'data': ['wizard/your_xml_file.xml'],#list of xml files used in this module
    'demo': [],#list of demo xml files used in this module
    'test': [],#list of test xml files used in this module
    'installable': True,
    'auto_install': False,
}