Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to hide fields?

By
Frankie Chan
on 7/1/14, 11:24 PM 890 views

Hello, 

I want to modify the existing sale module.

I have added a field in new_sale.py and replaced the fileds in new_sale.xml as follows:

----------------------------------------------------------------------------------------------------------

new_sale.py:

from openerp.osv import fields, osv

class new_sale(osv.osv):

  _inherit = "res.partner"

  _columns = {
    'projects_id': fields.integer('Project ID', size=11)
  }

  _defaults ={
    'projects_id': 0
  }

new_sale();

----------------------------------------------------------------------------------------------------------

new_sale.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <record model="ir.ui.view" id="view_new_sale_form">
        <field name="name">res.partner.form</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form" />
        <field name="arch" type="xml">
            <field name="fax" position="replace">
                <field name="projects_id" />
            </field>
        </field>
    </record>

----------------------------------------------------------------------------------------------------------

Now, I would like to hide the original "Title" field, which is a drop-down menu.

How can I do that?

BTW, I need to press the upgrade button and restart the server,  can I do the two in the command line at the same time? For example, adding some parameters after /etc/init.d/openerp-server force-reload xxxx yyyy zzzz

Thanks.

0

Jagdish Panchal

--Jagdish Panchal--
2674
| 5 3 6
Gandhinagar, India
--Jagdish Panchal--

OpenERP Developer

Jagdish Panchal
On 7/1/14, 11:41 PM

Hi

Try below code

    <record model="ir.ui.view" id="view_new_sale_form">
        <field name="name">res.partner.form</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form" />
        <field name="arch" type="xml">
            <field name="fax" position="replace">
                <field name="projects_id" />
            </field>
            <field name="title" position="replace">
                <field name="title" invisible="1"/>
            </field>            
        </field>
    </record>

If you only need to change/add attributes to a field, there is no need to use position="replace" and redefine the field, just use position="attributes" and define the attribute. See Felipe's answer.

Leonardo Donelli
on 7/2/14, 4:06 AM
3

Felipe

--Felipe--
962
| 5 3 8
Bogotá, Colombia
--Felipe--
Informatics engineer Industrial engineer
Felipe
On 7/1/14, 11:41 PM

    <record model="ir.ui.view" id="view_new_sale_form">
        <field name="name">res.partner.form</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form" />
        <field name="arch" type="xml">
            <field name="fax" position="replace">
                <field name="projects_id" />
            </field>
            <field name="title" position="attributes">
                <attribute name="invisible">1</attribute>
            </field>
        </field>
    </record>

 

---EDIT---

wow another answer at the same minute.

it is always better to make the field invisible, instead of deleting it(with replace) as other modules may depend on it for this form.

0
Frankie Chan
On 7/2/14, 1:44 AM

Thanks a lot. 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/1/14, 11:24 PM
Seen: 890 times
Last updated: 3/16/15, 8:10 AM