Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
7289 Widoki

In python, I have the following field:

'permit':fields.selection([('new', 'New'),
            ('applied', 'Applied'),
            ('received','Received')], 'Permit', select=True), 

def apply_permit(self, cr, uid, ids, context=None):
        data = {'value': {'permit':'applied'}}
        return data

In XML, I have the following:

 <field name="permit" readonly="True"/>
 <button name="apply_permit" string="Apply" type="action" class="oe_highlight" attrs="{'invisible':[('permit','=','applied')]}" />

The attrs code above doesn't currently work but what I want to do is: when click on the button 'permit' field value will be set to 'applied' and then hide the button.All these done before the form save. The button is inside the form.

Awatar
Odrzuć
Najlepsza odpowiedź

Your code just returns the value, which your don't necessarily need to do. You need to write the value to the database.

something like: self.write(cr, uid, ids, {'value': 'applied'}, context=context)

Awatar
Odrzuć
Autor

thank you