This question has been flagged
1 Reply
4289 Views

I want to add a Group by filter on stock_picking_out, on a custom field "commercial".

First of all I added this field on a custom module like this : 

import time
from openerp.osv import fields, osv, orm
from openerp.tools.translate import _

class StockPickingOut(orm.Model):

    _inherit = 'stock.picking.out'
    _name = 'stock.picking.out'
    _columns = {
       'commercial': fields.many2one('res.users','Commercial',readonly= True, required= True, ondelete='cascade'),
    }
    _defaults = {
        'commercial': lambda s, cr, uid, c: uid,
    }

class StockPicking(orm.Model):
    _inherit = 'stock.picking'
    _name = 'stock.picking'
    _columns = {
        'commercial': fields.many2one('res.users', 'Commercial', readonly= True, required= True, ondelete='cascade'),
    }
    _defaults = {
        'commercial': lambda s, cr, uid, c: uid,
    }

 

On XML side : 

        <record id="filter_per_commercial" model="ir.ui.view">
            <field name="name">picking.custom.search</field>
            <field name="model">stock.picking</field>
            <field name="inherit_id" ref="stock.view_picking_out_search"/>
            <field name="arch" type="xml">
                <xpath expr="//search/group/filter[@string='Status']" position="after">
                    <filter string="Commercial" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'commercial'}"/>
                </xpath>

            </field>
        </record>

There is no errors while loading my custom module, but the field Commercial doesn't appear on the Group by filter.

Any suggestions please.

Avatar
Discard
Best Answer

Change <field name="model">stock.picking</field> to <field name="model">stock.picking.out</field> in xml.

Avatar
Discard
Author

Yes thanks it was as simple as that. why the original view is makin stock.picking a source model ?

You might want to check if you have sale_journal module installed. It changed the model of view_picking_out_search from stock.picking to stock.picking.out.

Author

@ivan : No it's not installed.

I think its not related to sale_journal. Take a look at stock.picking.in search view. It has correct model. I hope this is a bug https://bugs.launchpad.net/openobject-addons/+bug/1243640 if i m right.