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.

3

how to hide the color column that refer to division selection ?

By
DEDE
on 12/18/14, 2:41 AM 738 views

xml file

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>  
            <record id="pr_form_view" model="ir.ui.view">
                <field name="name">pr.form.view</field>
                <field name="model">purchase.requisition</field>
                <field name="inherit_id" ref="purchase_requisition.view_purchase_requisition_form"/>
                <field name="arch" type="xml">
                    <data>
                        <xpath expr="//field[@name='user_id']" position="before">
                              <field name="cabang_id"/>
                              <field name="divisi_id"/>
                        </xpath>
                        <xpath expr="//field[@name='date_end']" position="after">
                            <field name="date"/>
                        </xpath>
                        <field name="product_qty" position="after">
                        <field name="warna" attrs="{'invisible':[('divisi_id','!=','t')]}"/>
                        
                    </field>
                            
                    </data>
                </field>
               </record>                   
           
 </data>
 </openerp>

 

py file

 

import time
import pytz
from openerp import SUPERUSER_ID
from datetime import datetime
from dateutil.relativedelta import relativedelta

from openerp.osv import fields, osv
from openerp import netsvc
from openerp import pooler
from openerp.tools.translate import _
import openerp.addons.decimal_precision as dp
from openerp.osv.orm import browse_record, browse_null
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT, DATETIME_FORMATS_MAP
from pygments.lexer import _inherit
from bsddb.dbtables import _columns


class purchase(osv.osv):
    _inherit="purchase.requisition"
    _columns={
              'cabang_id':fields.many2one('res.partner',string='Branch'),
              'divisi_id':fields.selection([('t','Unit'),('s','Sparepart'),('u','Umum'),('f','Finance')],string='Division',change_default=True,required=True),
              'date':fields.date('Date'),
              
              }
    
class warna(osv.osv):
    _inherit="purchase.requisition.line"
    _columns={
              'warna':fields.many2one('kode.warna', string='Color'),
              }

 

0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 12/18/14, 3:05 AM

The meaning of [('divisi_id','!=','t')] in <field name="warna" attrs="{'invisible':[('divisi_id','!=','t')]}"/> is that the field "warna" will be invisible if the divisi_id's Database ID is not equal to 't' (Unit).  So, you should see the the "warna" field anytime unless if you choose Unit ('t') as division_id.

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: 12/18/14, 2:41 AM
Seen: 738 times
Last updated: 3/16/15, 8:10 AM