Skip to Content
Menu
This question has been flagged
2 Replies
5478 Views

How we can create a extra menu item in "Action"when selecting the sale order? When I click that menu item popup a wizard inside the wizard show all the active ids in sale order?please give a solution.

Thanks.

Avatar
Discard
Best Answer

Hi,

You can add a new item to the action button by following code in the sale.order object.

<record id="sale_order_confirm_view" model="ir.ui.view">
<field name="name">sale.order.confirm.form</field>
<field name="model">sale.order.confirm</field>
<field name="arch" type="xml">
<form string="Confirm Sale">
<p class="oe_grey">
Only records of state Quotation and Quotation Sent will be Confirmed.
Other will get skipped
</p>
<footer>
<button string="Confirm" name="sale_confirm" type="object" default_focus="1" class="btn-primary"/>
<button string="Cancel" class="btn-default" special="cancel"/>
</footer>
</form>
</field>
</record>

<act_window id="action_sale_confirm"
multi="True"
key2="client_action_multi" name="Confirm Quotation"
view_id="sale_order_confirm_view"
res_model="sale.order.confirm" src_model="sale.order"
view_mode="form" target="new" view_type="form" />


Then Once you click the confirm button in the wizard the python function in the transient model will get called.


class SaleOrderConfirm(models.TransientModel):
_name = 'sale.order.confirm'
_description = "Wizard - Sale Order Confirm/Cancel"

@api.multi
def sale_confirm(self):
"""filter the records of the state 'draft' and 'sent', and will confirm this and others will be skipped"""
quotations = self._context.get('active_ids')

#here in quotations you will get the id of the selected records

quotations_ids = self.env['sale.order'].browse(quotations).\
filtered(lambda x: x.state == 'draft' or x.state == "sent")
for quotation in quotations_ids:
quotation.action_confirm()

Inside the function you will get the selected records from the active_ids in the context.

quotations = self._context.get('active_ids')

Code is from this module in the store, please look at for reference: Sale,Purchase Mass Confirm and Cancel


Thanks

Avatar
Discard
Best Answer

Refer Journal Entry having multi post option


Avatar
Discard