I have this model
class RawMaterialReport(models.Model): _name = 'raw.material.report' _description = 'Raw Material Report' product_id = fields.Many2one( 'product.product', string='Product', required=False, ) @api.multi def open_raw_materials(self): mrp_productions = self._context.get('active_ids') mrp_production = self.env['mrp.production'].browse(mrp_productions) raw_products = mrp_production.mapped('move_raw_ids.product_id') for p in raw_products: self.create({'product_id': p.id}) view_id = self.env.ref('trk.raw_material_report_tree').id view = { 'name': _('Details'), 'view_type': 'form', 'view_mode': 'tree, form', 'res_model': 'raw.material.report', 'views': [(view_id, 'form')], 'type': 'ir.actions.act_window', # 'res_id': self.id, } return view <?xml version="1.0" encoding="utf-8"?> <openerp> <data> <record id="raw_material_report_tree" model="ir.ui.view"> <field name="name">raw.material.report.tree</field> <field name="model">raw.material.report</field> <field name="priority">2</field> <field name="arch" type="xml"> <tree string="Sales Orders" > <field name="product_id" /> </tree> </field> </record> <record id="action_raw_material_report" model="ir.actions.act_window"> <field name="name">zzzzz</field> <field name="type">ir.actions.act_window</field> <field name="res_model">raw.material.report</field> <field name="view_type">form</field> <field name="view_mode">tree,kanban,form</field> </record> <record id="action_server_learn_skill" model="ir.actions.server"> <field name="name">test</field> <field name="type">ir.actions.server</field> <field name="model_id" ref="model_raw_material_report" /> <field name="binding_model_id" ref="mrp.model_mrp_production" /> <field name="state">code</field> <field name="code">model.open_raw_materials()</field> </record> <menuitem id="menu_sale_order1" name="test" action="action_raw_material_report" parent="sale.sale_order_menu" sequence="2" /> </data> </openerp>
When I go to action and run my method everything goes good until that point where I try to return a view it just not redirecting me to my tree view. Nothing happens. But raw.material.report Records got created and I can check them if I go to my menu, it opens list view with them. So there is some kind of a problem with my return, can someone help on this? I actually tried to return an action like this
action = self.env.ref('trk.action_raw_material_report').read()[0] return action
but get the same, it just not redirecting me to my tree view.