Odoo Help

3

0
3 Answers
0
Juan Carlos Guatemala
12/18/14, 6:51 PM

You can use  invisible="1" in xml field.

<field name="name" invisible="1" />

0
Avatar

Ivan Indonesia

--Ivan--

3440
| 6 3 9
Jakarta, Indonesia
--Ivan--
Ivan Indonesia
12/18/14, 7:00 PM

If customer field is a selection, you usually do the reverse: [('customer', '=', False)]

0
heru Indonesia
12/18/14, 6:57 PM

@Juan Carlos

so my code become :

<field name="code_ahm" attrs="{'invisible': [('customer','!=',1)]}"/>   ?

Right ?

@Ivan 

Ivan, type Customer field is boolean ...

6 Comments
Ivan Indonesia
12/18/14, 7:24 PM

You mentioned that "... but type field is Selection ...." Anyway, if you need to domain by a selection field you can use treat it as normal character field with the value being the code of the selection chosen, e.g. [('selection_field', '=', 'value1')], [('selection_field', 'in', ('value1', 'value2'))], etc.

heru Indonesia
12/18/14, 7:46 PM
oh I'm sorry ...

I use example your code, in file .xml or .py ?

I make class 'pilih_branch' in file .py :

class pilih_branch(osv.osv):
    _inherit = 'res.partner'
    _columns = {
                'pilih' : fields.selection([('c','Customer'),('b','Branch')],'Opsi Pengisian Data'),

and I make code in file .xml :

<record model="ir.ui.view" id="res_partner_formBranch_view">
    <field name="name">master customer</field>            
    <field name="model">res.partner</field>            
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <field name="function" position="before">
        <field name="pilih" placeholder="--Silahkan Pilih Salah Satu--"/>
        </field>
        </field>
</record>

<record model="ir.ui.view" id="res_partner_form_view"> <field name="name">master cabang</field> <field name="model">res.partner</field> <field name="inherit_id" ref="base.view_partner_form"/> <field name="arch" type="xml"> <field name="website" position="after"> <field name="code_md" attrs="{'invisible': [('b','!=','True')]}"/> <field name="code_dealer" /> </field> </field> </record>
                
                }

<record model="ir.ui.view" id="res_partner_form5_view">
    <field name="name">master customer</field>            
    <field name="model">res.partner</field>            
    <field name="inherit_id" ref="base.view_partner_form"/>
    <field name="arch" type="xml">
        <field name="phone" position="before">
        <field name="tgl_lahir" attrs="{'invisible': [('c','!=','True')]}"/>
        </field>
        </field>
</record>

can you help me,  what is wrong my code ?


On Fri, Dec 19, 2014 at 7:24 AM, Ivan <niecw@mail.odoo.com> wrote:

You mentioned that "... but type field is Selection ...." Anyway, if you need to domain by a selection field you can use treat it as normal character field with the value being the code of the selection chosen, e.g. [('selection_field', '=', 'value1')], [('selection_field', 'in', ('value1', 'value2'))], etc.

--
Ivan
Sent by Odoo Inc. using Odoo about Forum Post False
Ivan Indonesia
12/18/14, 7:59 PM

As the value is only available after the record is displayed this can only be done from view XML. I see that you have pilih field as the selection field, right? 'b' and 'c' are the values. First, if you want to use the field in domain, you need to include the field first, which I see have been included in res_partner_formBranch_view. Then you use it like: attrs="{'invisible': [('pilih','!=','c')]}" if you want to hide, say, the tgl_lahir field if the pilih field is not 'c'.

heru Indonesia
12/18/14, 11:30 PM
oh yeah, its works ...
Ivan, can you give me sample code , for clear the field ...

I try make code for clear the field , like :
class branch(osv.osv):
    _inherit = 'res.partner'
    _columns = {
                         'pilih' : fields.selection([('c','Customer'),('b','Branch')],'Opsi Pengisian Data'),
                         'code_md': fields.char('Code MD'),
                         'am': fields.char('AM'),
                         }

    def onchange_value(self, cr, uid, ids, pilih):
        val={
             'value':{                
                      'am':' '   
                     }        
             }
        if pilih=='c':
            val={
                 'value':{
                          'code_md':' '
                          }
             }
        elif pilih=='b':
            val={
                 'value':{
                          'am':' '
                          }
             }
             
        return val

branch()

can you tell me what is the mistake with code ?

<img src="cid:gtalk.328@goomoji.gmail" goomoji="gtalk.328" style="margin: 0px 0.2ex; vertical-align: middle;">



On Fri, Dec 19, 2014 at 7:59 AM, Ivan <niecw@mail.odoo.com> wrote:

As the value is only available after the record is displayed this can only be done from view XML. I see that you have pilih field as the selection field, right? 'b' and 'c' are the values. First, if you want to use the field in domain, you need to include the field first, which I see have been included in res_partner_formBranch_view. Then you use it like: attrs="{'invisible': [('pilih','!=','c')]}" if you want to hide, say, the tgl_lahir field if the pilih field is not 'c'.

--
Ivan
Sent by Odoo Inc. using Odoo about Forum Post False
Ivan Indonesia
12/18/14, 11:51 PM

@Heru, please post a different question, don't mixed the subject. The image is not displayed, so I can't help you. Also, please consider learning grep (http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_04_02.html). You can find a lot of examples from the official addons module. That's, AFAIK, is the best route for learning the basics.

heru Indonesia
12/20/14, 9:59 PM
sorry Ivan, I can reply your new message , 
oh ok Insya Allah i study your modul ...

Ivan , do you have moduls about odoo ? 

On Fri, Dec 19, 2014 at 11:51 AM, Ivan <niecw@mail.odoo.com> wrote:

@Heru, please post a different question, don't mixed the subject. The image is not displayed, so I can't help you. Also, please consider learning grep (http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_04_02.html). You can find a lot of examples from the official addons module. That's, AFAIK, is the best route for learning the basics.

--
Ivan
Sent by Odoo Inc. using Odoo about Forum Post False

Ask a Question
Writer
Keep Informed
1 follower(s)
About This Community

This platform 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.

Register
Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now