# Button creation

**URL:** https://discuss.tryton.org/t/button-creation/6804
**Category:** Developer
**Created:** [December 19, 2023, 2:17pm UTC](https://discuss.tryton.org/t/button-creation/6804 "2023-12-19T14:17:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pumontjm](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/bbce88/32.png) [@pumontjm](https://discuss.tryton.org/u/pumontjm)
#### Post date: [December 19, 2023, 2:17pm UTC](https://discuss.tryton.org/t/button-creation/6804/1 "2023-12-19T14:17:49Z")

</div>

Hello,

Usually I have no problem creating a button and managing its attributes.  
However here the button that I create is in “readonly” state by default.  
Am I missing something?

```auto
@classmethod
    def __setup__ (cls):
        super(ContractContractAttribute, cls). __setup__ ()

        cls._buttons.update({
            'fill_in': {}
        })

@classmethod
    @ModelView.button
    def fill_in(cls, attribute):
        product = attribute[0].product

        if product:
            attribute[0].attibute = product.attribute
            attribute[0].base_price = product.list_price
            attribute[0].uos = product.uos
            attribute[0].save()

        return True

```

```auto
<record model="ir.model.button" id="contract_attribute_fill_button">
          <field name="name">fill_in</field>
          <field name="string">Remplir</field>
          <field name="model" search="[('model', '=', 'contract.contract.attribute')]"/>
</record>

```

```auto
<form>
...
    <button name="fill_in"/>
...
</form>

```

(when I move this code to another class. The button behaves normally) ??

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 19, 2023, 2:48pm UTC](https://discuss.tryton.org/t/button-creation/6804/2 "2023-12-19T14:48:18Z")

</div>

I suspect that it is in a One2Many so the record is not yet saved so buttons are disabled.
