【问题标题】:Odoo 10 : How to increase the field width?Odoo 10:如何增加字段宽度?
【发布时间】:2018-11-16 14:52:59
【问题描述】:

我有一个看起来像这样的表单视图:

xml 看起来像这样:

<notebook>
<page>
<group string="In case of student employee or intern">   
     <field name="immatriculation" attrs="{'readonly':True}"/>
     <field name="studentStatus" attrs="{'readonly':True}"/>
     <field name="studentQuestionnaire" attrs="{'readonly':True}"/>
     <field name="studentOtherjobs" attrs="{'readonly':True}"/>
</group>
</page>
</notebook> 

我想增加这些字段的宽度,以便所有文本(例如学生身份确认(强制实习)) 单行。我在下面尝试过,但没有看到宽度有任何变化:

<field name="studentStatus" attrs="{'readonly':True}" style="width:200px"/>

更改组内这些字段宽度的正确方法是什么?

【问题讨论】:

    标签: css xml forms field odoo


    【解决方案1】:

    只需放置一个&lt;div/&gt; 标签,它将为标签呈现 50% 的空间,为字段呈现 50% 的空间 像这样

    <group string="In case of student employee or intern">
         <div /> <!-- here it is -->
         <field name="immatriculation" attrs="{'readonly':True}"/>
         <field name="studentStatus" attrs="{'readonly':True}"/>
         <field name="studentQuestionnaire" attrs="{'readonly':True}"/>
         <field name="studentOtherjobs" attrs="{'readonly':True}"/>
    </group>
    

    如果你需要超过 50% 的空间,那么你必须应用样式

    【讨论】:

      【解决方案2】:

      当复选框字符串很长时,我会将字符串放在框的右侧。

      您可以考虑以下视图。

      <group>
          <label string="Confirmation" for="confirm1" class="oe_inline"/>
          <div>
              <field name="confirm1" nolabel="1" class="oe_inline" modifiers="{}"/>
              <label string="blah blah blah" class="oe_inline"/>
          </div>
          <label string=" " for="confirm2" class="oe_inline"/>
          <div>
              <field name="confirm2" nolabel="1" class="oe_inline" modifiers="{}"/>
              <label string="blah blah blah" class="oe_inline"/>
          </div>
          <label string=" " for="confirm3" class="oe_inline"/>
          <div>
              <field name="confirm3" nolabel="1" class="oe_inline" modifiers="{}"/>
              <label string="blah blah blah" class="oe_inline"/>
          </div>
      </group>
      

      【讨论】:

        【解决方案3】:

        这有点棘手,但您可以尝试一个简单的解决方案,将 colspan 设置为使用笔记本页面的整个宽度。

        &lt;group string="In case of student employee or intern" colspan="4"&gt;

        【讨论】:

        • 对不起!宽度没有改变。还是一样!
        【解决方案4】:

        试试这个......也许你必须在每个领域都这样做

        <field name="field1" style="width:40%%" />
        

        【讨论】:

        • 这是做什么的?它如何回答这个问题?不要只是脱口而出代码。解释你自己! stackoverflow.com/help/how-to-answer
        • 你可以把它放在XML中你想增加或减少的字段中。 % 取决于您。
        • 这很明显,但您应该将其作为答案的一部分而不是评论。我不确定你是否已经解释了为什么这会回答这个问题。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-06-10
        • 2015-07-30
        • 2020-09-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-17
        相关资源
        最近更新 更多