I am trying to develop a new popup for stock_picking which will display the move.lines and allow user to select them and print a custom report with selected ones.
As a first try I want to generate the popup with just a couple of fields of the stock.picking.
- Do I have to use models.Transient or models.Model?
- Do I have to give it a different _name="label.picking" or just extend "stock.picking" and use it?
- Do I have to use view_id field in the button controller?
This is the model:
# -*- coding: utf-8 -*-
from openerp import models, fields
class LabelPicking(models.TransientModel):
_name = "label.picking"
_inherit = "stock.picking"
def view_tree_print_dispatch_items(self):
return {
'type': 'ir.actions.act_window',
'name': 'view_tree_print_dispatch_items',
'view_type': 'tree',
'view_mode': 'tree',
'res_model': 'label.picking',
'target': 'new',
}
And this is the XML:
<?xml version="1.0" encoding="utf-8" ?>
<openerp>
<data>
<record model="ir.ui.view" id="stock.view_picking_form_item_labels">
<field name="name">stock.picking.form.item_labels</field>
<field name="model">stock.picking</field>
<field name="inherit_id" ref="stock.view_picking_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='state']" position="before">
<button name="view_tree_print_dispatch_items" string="Imprimir Items" type="object"/>
</xpath>
</field>
</record>
<record id="view_tree_print_dispatch_items" model="ir.ui.view">
<field name="name">Labels Dispatch Items Tree</field>
<field name="model">stock.picking</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>-
<field name="origin"/>-
</tree>
</field>
</record>
</data>
</openerp>