Create a custom button for new record

Hi,

I will thank how to create a new record from a custom button. I read about how tryton use it on Ctrl + N but I want a custom button or after a specific action. For example, after post an invoice create a new record.

Thanks in advance!

If you have a custom workflow, you have to write a wizard for it.

I’m not sure where to start the development, maybe some decorator like this to create a new record, but I don’t know, maybe some docs to read about these case.

You can use the button_action decorator to launch a wizard but indeed if you do not need any input from the user, you can just put your code in the button method.

I searched a lot but I could not find an example for create a new record from a button, which code I need to add to create a new record in a custom module? I’m not sure, maybe something like this:

It is not clear what you want to do.
I think instead of asking for how to do what you think is the solution, you should describe your real need.

I need to create a new record from a custom button when it is pressed. The button is in form view of Invoice records.

A new record of which model? A new invoice or another model?

What is the new record? What is the purpose and the usage? With which data is it created? Is the user’s input required? What should happen to the record once created? What should see the user? etc.

The button is in the invoice view form, I need to create a new empty record in the same view (similar to press Ctrl + N). The purpose of the usage is that the user that invoice doesn’t want to press Ctrl + N every time he post an invoice, instead after press post button, after post the invoice automatically create a new invoice record. When the new record is created the user is ready to edit it and fill the form. Maybe the user need to see a warning windows that ask him if he want to create a new record.

In the same invoice model.

The method of the button may return the string ‘new’.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.