İçereği Atla
Menü
Bu soru işaretlendi
6 Cevaplar
28332 Görünümler

Here is my declared field in account_voucher.py file,

'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Dr/Cr')

In the view(xml file),

 <field name="type" widget="radio" options='{"horizontal": 1}' />

Right now it is radio button I want to change it to checkbox  

Avatar
Vazgeç
En İyi Yanıt

To explain this and make it clearer,this type of checkbox that you want to add works only with the manytomany fields,and this field will display one checkbox for each record existing in the model targeted by the relation, according to the given domain if one is specified.Checked records will be added to the relation 

and There’s no way to use this widget to create new items

<field name="field_name" widget="many2many_checkboxes"/>

and as it seems you declared that field as selection filed so you have two options the first is to follow the first method of boolean type or to do like Ankit H had said

you could create boolean fields for each selection and put them in your view definition like this in the .py file:

_columns = {

'dr': fields.boolean('Debit'),
'cr': fields.boolean('Credit'),
}

and in the xml:

<field name="arch" type="xml">

<form>

<group>

<field name="dr" attrs="{'invisible': [('cr','=',True)]}"/>

<field name="cr" attrs="{'invisible': [('dr','=',True)]}"/>

</group>

</form>

</field>

hope it helps you

Avatar
Vazgeç
Üretici

I dont want to alter python code, I just to want to acheive it just by using xml file, So is their any widget for checkbox?

hope it helps, modified my answer

En İyi Yanıt

hai,

Just create given below in .py file

          'blue' : fields.boolean('Blue'),

         'pink' : fields.boolean('Pink'),

then xml file do this,

         <field name="blue" type="checkbox" />

       <field name="pink" type="checkbox" />

Try this it's worked for me


Avatar
Vazgeç
En İyi Yanıt

Hello Bhanukiran,

You could use widget like many2many_checkboxes.

But your field type must be many2many

For example

in .py file.

class type_type(osv.Model):

_name = 'type.type'

_columns = {

'name': fields.char('Name')

}

class your_class_name(osv.Model):

_name = 'your.class.name'

_columns = {

'type_checkbox': fields.many2many('type.type', 'type_help_rel', 'type_id', 'help_id', 'Type')

}

in xml file.

<field name="type_checkbox" widget="many2many_checkboxes"/>

Hope this help for you.

Cheers,

Ankit H Gandhi.

Avatar
Vazgeç

Hello Ankit I have used checkbox of many2many fields for stock location. It works fine for me but how to divide checkbox there is lots of number of record in stock location its showing me right side only there is any type to divide into row and column to the checkbox

En İyi Yanıt

hai arun,

  It  works thank you.

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Ara 16
4799
1
Tem 16
5015
4
Nis 16
6866
6
Kas 15
5291
1
Mar 15
3301