In manufacturing order model, I added new buttons beside create (Produce button, and Mark as Done button). I wanted the "Produce" button to pop up a wizard that will ask for a res.user and after clicking Save button, it will write the res.user to each records. How can I make this possible?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
Just an update! This can now be implemented in Odoo 14 by adding a button in the header of a tree view.
<record id="my_view_id" model="ir.ui.view">
<field name="name">view.name</field>
<field name="model">my.model</field>
<field name="arch" type="xml">
<tree>
<header>
<button name="%(action_for_wizard)d" string="Action" object="action"/>
</header>
</tree>
...
When a record is selected:
When no record is selected:
This working on Odoo14 as like what I want.
Thanks,
Tri Nanda
Sharing a video example o the same: https://www.youtube.com/watch?v=R8eG6uOxHKw
Hi Serge: If I have understood your question correctly, you should be able to loop through the variable "self" that gets passed to each action to get what you need.
EDIT:
Actions can be linked to buttons in one of two ways depending on where the action is defined.
If the action is defined as a server action, you can use the following syntax:
<button name="SERVER_ACTION_ID" type="action" string="BUTTON LABEL"/>
NOTE: type="action" and name=id of the server action.
The server action id can be defined to be automatically picked up at installation time (instead of hard coding it) by using the syntax
%(EXTERNAL_ID_OF_SERVER_ACTION)d
For example,
<button name="%(stock.action_stock_report)d" type="action" string="Stock Report"/>
If the action is defined as a function in the underlying object, you can use the following syntax:
<button name="FUNCTION_NAME" type="object" string="BUTTON LABEL"/>NOTE: type="object" and name=name of the function defined in the python class of the object
I just realized my question is incomplete, but thank you for this Paresh! This is a step further for what I was aiming for.
Hello, Paresh! What I did that worked is that I created a server action using a wizard <act_window ... />
I was referring to this tutorial at first:
but the multi="True" is not necessary anymore and won't work in Odoo 13, and the attribute src_model is now binding_model. This is the code I used:
<act_window id="multi_production_batch_wizard"
name="Create Production Batch"
binding_model="mrp.production"
res_model="production.batch.wizard"
view_mode="form"
target="new"
/>
I was able to retrieve the selected ids using:
manufacturing_orders = self.env['mrp.production'].browse(self._context.get('active_ids'))
It only solved half of the problem, I want to implement that server action into a new button using this:
I don't know how to call a wizard by extending the ListView.buttons as shown here: https://imgur.com/a/tWf2cst
Hi Serge: I have edited my earlier answer and added an explanation of how to link an action to a button.
Hello Paresh, how do I implement that if the button used is like in the link below? I added a custom ListView buttons
Hello, Paresh! This is working now in Odoo 14 since they added a header for the tree view already. Thank you!
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
Where do you want to write the user record? To MRP record or consumed lines or finished product or somewhere else?
Note: To update any record, you can use write method.
Open wizard on button click: https://learnopenerp.blogspot.com/2020/01/open-wizard-on-button-click-in-odoo.html
Hello, Sudhir and Sehrish!
The button that I meant to describe are these buttons added above the tree view.
https://imgur.com/a/tWf2cst
<t t-extend="ListView.buttons">
<t t-jquery="button.o_list_button_add" t-operation="after">
<button t-if="widget.modelName == 'mrp.production'" class="btn btn-primary oe_produce_button" type="button" accesskey="f">Produce</button>
<blockquote class="imgur-embed-pub" lang="en" data-id="a/tWf2cst" data-context="false" ><a href="//imgur.com/a/tWf2cst"></a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
Please disregard my other comment.
The buttons were added using this:
https://stackoverflow.com/questions/58514381/hide-the-create-button-in-a-specific-module-only-in-odoo11
The function of that wizard will link the mrp.production to a custom model I named production.batch. Before this custom model is created, it will ask for a an attachment to be uploaded. Once I clicked save, all the records of mrp.production's field called production_batch will be filled with that of the wizard.
This is how I implemented the wizard (works on server action):
https://imgur.com/sYEVY2h