I am using odoo11, and i am working on the following code, that adds a menu item in the "action" dropdown for sale orders, in order for the user to confirm multiple sale orders at once:
Python:
class SaleOrderConfirmWizard(models.TransientModel):
_name = "sale.order.confirm.wizard"
_description = "Wizard - Sale Order Confirm"
@api.multi
def confirm_sale_orders(self):
self.ensure_one()
active_ids = self._context.get('active_ids')
orders = self.env['sale.order'].browse(active_ids)
for order in orders:
print(order.id)
if order.state in ['draft', 'sent']:
order.action_confirm()
XML:
<record id="view_confirm_sale_order" model="ir.ui.view">
<field name="model">sale.order.confirm.wizard</field>
<field name="arch" type="xml">
<form string="Confirm Sale Orders">
<footer>
<button name="confirm_sale_orders" string="Confirm" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_confirm_sale_order" model="ir.actions.act_window">
<field name="name">Confirm Sale Orders</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order.confirm.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_confirm_sale_order" />
<field name="target">new</field>
<field name="multi">True</field>
</record>
<act_window id="confirm_sale_order"
name="Confirm Sale Orders"
src_model="sale.order"
res_model="sale.order.confirm.wizard"
view_type="form"
view_mode="form"
key2="client_action_multi"
target="new"/>
Now, I may be blind, but I can't see anywhere the reference to the treeview (which is "sale.view_order_tree" if im not wrong) this stuff should appear in.
I wanted something similar for the "quotation" treeview, and i thought i had to change some view reference (quotations are still instances of "sale.order" model, so i guess i have to change nothing on the model side)...
But, as strange as it sounds, i cannot find in this code any reference to the sale order treeview to change. I am probably missing something very evident, so please forgive this pretty dumb question.
Thank you in advance
EDIT:
I can't really explain why, but now i can see the new menu item even in the quotation page (maybe i didn't refresh properly the page?). In any case, i'd like to know if its normal that there is no explicit reference to the view?