I have added a button in sale.order.line.
<button name="service_line" type="object" icon="fa-check"/>
on clicking it a form view is opened using ir.actions.act_window.
def service_line(self):
form = self.env.ref('product_availability_analysis.form_view_product_group_so').id
context = self.env.context.copy()
context.update({'order_line_id': self.id})
return {
'name': _('Lines'),
'view_type': 'form',
'view_mode': 'form',
'views': [(form, 'form')],
'view_id': form,
'res_model': 'product.group',
'res_id': self.product_id.group_id.id,
'context': context,
'type': 'ir.actions.act_window',
}
On this product.group form view I have added a button in action dropdown.
<record id="add_service_in_sale_order" model="ir.actions.server">
<field name="name">Add To Order</field>
<field name="model_id" ref="alsalman_products_config.model_product_group"/>
<field name="context">{'order_line_id': env.context.get('order_line_id')}</field>
<field name="state">code</field>
<field name="code">action = model.action_create()
</field>
<field name="binding_model_id" ref="alsalman_products_config.model_product_group"/>
</record>How do I get order_line_id in the function(action_create) called from ir.actions.server?
On product group form when I trigger any onchange function to check active_id,
it is of sale.order.line but after clicking Add To Order in action_create active_id is of
product.group and no track of order_line_id. I have also tried passing the context but no luck.