I am trying to move an ID to a transient model.
Using NEW API. If old api is required, I would like to understand where it is being used and why.
With this code I get the new tree view displayed, but no ID is moved to stock_picking_id in the transient model, why?
So I have the following button defined in stock picking view to launch a wizard:
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class StockPicking(models.Model):
_inherit = "stock.picking"
@api.multi
def view_tree_label_picking(self):
return {
'type': 'ir.actions.act_window',
'name': 'view_tree_label_picking',
'view_type': 'tree',
'view_mode': 'tree',
'res_model': 'label.picking',
'context': {'stock_picking_id': self.id},
'target': 'new',
}
Then I have the following class defined for the wizard,
how do I retrieve stock_picking_id assigned from the button code?
XML:
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data>
<record id="view_tree_label_picking" model="ir.ui.view">
<field name="name">Labels Dispatch Items Tree</field>
<field name="model">label.picking</field>
<field name="arch" type="xml">
<tree>
<field name="stock_picking_id"/>
</tree>
</field>
</record>
</data>
</openerp>
Transient Model:
# -*- coding: utf-8 -*-
from openerp import models, fields, api
class LabelPicking(models.TransientModel):
_name = "label.picking"
_inherit = "stock.picking"
stock_picking_id = fields.Many2one('stock.picking', string='Stock Picking',
readonly=True,
default=lambda self: self.env.id)