2016-11-11 5 views
1

Я хочу, чтобы скрыть/показать поля, в зависимости от булева поля, в Odoo v9 сообществаЛогическое поле не работает - Odoo v9 сообщество

Во-первых, я не знаю, почему он не работает, это мой код:

class account_invoice(models.Model): 
    _inherit = "account.invoice" 

    is_export = fields.Boolean(string="¿Es exportación?") 
    field_1 = fields.Char ... 
    field_2 = fields.Many2one ... 

Теперь на мой взгляд:

 <record model="ir.ui.view" id="embarque_form_view"> 
     <field name="name">account.invoice.embarque.form</field> 
     <field name="model">account.invoice</field> 
     <field name="inherit_id" ref="account.invoice_form" /> 
     <field name="arch" type="xml"> 
      <field name='partner_id' position="after"> 
       <field name="is_export" class="oe_edit_only" widget="radio"/> 
       <field name="puerto_embarque" attrs="{'invisible': [('is_export', '!=', 'True')]}"/> 
       <field name="puerto_desembarque" attrs="{'invisible': [('is_export', '!=', 'True')]}"/> 
       <field name="moneda_export" attrs="{'invisible': [('is_export', '!=', 'True')]}"/> 
       <field name="tara_unit" attrs="{'invisible': [('is_export', '!=', 'True')]}"/> 
       <field name="weight_unit" attrs="{'invisible': [('is_export', '!=', 'True')]}"/> 
       <field name="net_weight_unit" attrs="{'invisible': [('is_export', '!=', 'True')]}"/> 
       <field name="transporte_tipo" attrs="{'invisible': [('is_export', '!=', 'True')]}"/> 
       <field name="modal_idad" attrs="{'invisible': [('is_export', '!=', 'True')]}"/> 
      </field> 
     </field> 
    </record> 

поля фактически скрыты, но когда я пытаюсь нажать на логическое поле, чтобы активировать их, он не работает, я имею в виду он просто нажимает и не становится «T rue 'или что-то еще, это похоже на то, что оно было отброшено.

Я не знаю, если это о ATTRS я добавляю в любой другой области, как: attrs="{'invisible': [('is_export', '!=', 'True')]}"

Что я здесь делаю неправильно?

ответ

2

Логическое поле не работает из-за виджета = «радио» атрибут поле, чтобы скрыть/показать другие поля.

Объявить is_export поле со значением по умолчанию Ложные

Try с помощью следующего кода:

is_export = fields.Boolean(string="¿Es exportación?", default=False) 

Обновить Ваше мнение файл с

сервера
<record model="ir.ui.view" id="embarque_form_view"> 
    <field name="name">account.invoice.embarque.form</field> 
    <field name="model">account.invoice</field> 
    <field name="inherit_id" ref="account.invoice_form" /> 
    <field name="arch" type="xml"> 
     <field name='partner_id' position="after"> 
      <field name="is_export"/> 
      <field name="puerto_embarque" attrs="{'invisible': [('is_export', '=', False)]}"/> 
      <field name="puerto_desembarque" attrs="{'invisible': [('is_export', '=', False)]}"/> 
      <field name="moneda_export" attrs="{'invisible': [('is_export', '=', False)]}"/> 
      <field name="tara_unit" attrs="{'invisible': [('is_export', '=', False)]}"/> 
      <field name="weight_unit" attrs="{'invisible': [('is_export', '=', False)]}"/> 
      <field name="net_weight_unit" attrs="{'invisible': [('is_export', '=', False)]}"/> 
      <field name="transporte_tipo" attrs="{'invisible': [('is_export', '=', False)]}"/> 
      <field name="modal_idad" attrs="{'invisible': [('is_export', '=', False)]}"/> 
     </field> 
    </field> 
</record> 

Restart Odoo и обновить свой модуль ,

+0

Большое спасибо Odedra, но все то же самое :( – NeoVe

+0

Попробуйте с удалением * виджет = «радио» * от * is_export * поле. –

+0

Спасибо так много Odedra, лол, что это было! – NeoVe

Смежные вопросы