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?
@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
<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>
<form>
...
<button name="fill_in"/>
...
</form>
(when I move this code to another class. The button behaves normally) ??