Hello there :)
I am trying to add an action to a simple app I've made.
Therefore I have added a method to my class:
class RollsManagement(models.Model):
_name = 'rollsmanagement.roll'
_description = 'Managing rolls'
_order = 'sequence'
_rec_name = 'name'
...
simply like this:
...
def action_create_inventory_from_selection(self):
....
In my XML I've added the action like this:
<record id="action_roll_inventory_import" model="ir.actions.server">
<field name="name">Create Inventory from Rolls</field>
<field name="model_id" ref="model_rollsmanagement_roll"/>
<field name="binding_model_id" ref="model_rollsmanagement_roll"/>
<field name="binding_view_types">list</field>
<field name="state">code</field>
<field name="code">
action = model.action_create_inventory_from_selection()
</field>
</record>
My action appears when I've selected one or more data entries (rolls) in the drop down button "Actions" and when I click it, it ends in this error:
File "ir.actions.server(660,)", line 1, in <module>
AttributeError: 'rollsmanagement.roll' object has no attribute 'action_create_inventory_from_selection'
I have the strong feeling, I am missing something essential, maybe simple even. The model is there and working as always but somehow it seems that I cannot call the action the right way. Two LLMs are already at the end of their knowledge, it seems. Does anyone have a hint?
PS: If you're interested, my app lists some special rolls and simple information about them. I try to make an action that sums up their square meters and put that into the inventory adjustment.
Hello,
Remove binding_model_id and write with decorator as below:
@api.model
def action_create_inventory_from_selection(self):
Let me know if it is not working.
Hi @Codesphere Tech :) Thanks, but still the same: "AttributeError: 'rollsmanagement.roll' object has no attribute 'action_create_inventory_from_selection'".