This question has been flagged
5 Replies
18499 Views

I'm working on "stock" addons, in the tree in Warehouse>Warehouse Management>Delivery Orders, and finaly chose a delivery order.

There is a tree with a many2one field tracking_id (Pack field).

How to display the field's form by clicking on it? (if it is possible)

If it is not possible, I'll do it by displaying a button, but is it possible to set the label of the button to the Pack name?

Avatar
Discard

Same problem here, Anyone has a clue to solve this?

Same question here, it's for improve the traceability view.

Best Answer

For embedded one2many fields in form views, I add a button that calls a function returning an action dictionary to the referenced record.  In the tree view (inside the o2m field tag):

<button type="object" string="Open" name="open_full_record" icon="gtk-next" attrs="{'invisible': [('tracking_id','=',False)]}"/>

Then inside the class of the tree's source object:

def open_full_record(self, cr, uid, ids, context=None):
    return {
        'type': 'ir.actions.act_window',
        'view_type': 'form',
        'view_mode': 'form',
        'res_model': self._name,
        'res_id': ids[0],
        'target': 'current',
        'context': context,  # May want to modify depending on the source/destination
    }

I've never tried it directly on a tree view, but I don't see why it wouldn't work.

Avatar
Discard