تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
4578 أدوات العرض

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'),
              }

 

الصورة الرمزية
إهمال
أفضل إجابة

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.

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
4
ديسمبر 15
6198
1
سبتمبر 23
4920
2
يونيو 20
9490
2
مايو 16
16442
2
سبتمبر 23
8754