1
votes

Im having problems with creating a filter on stock.picking object. Just recently i build a simple "privilege relay" - in each stock location you can define "Assigned User Group", thanks to that users that are in particular group can or cannot confirm moves for or out of the location.

Stock.picking:location_id -> assigned_user_group -> users

Now I would like to create a filter (later to be set default) on stock picking tree view that will show only the moves which locations (source location and destination location; i use them in stock.picking object) can be managed by a viewing user.

By far I wrote a filter that looks like that:

<record id="view_picking_internal_search_pl" model="ir.ui.view">
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_internal_search"/>
        <field name="arch" type="xml">
            <filter icon="terp-dialog-close" name="done" string="Done" domain="[('state','=','done')]" help="Pickings already processed" position="after">
                <filter icon="terp-check" name="locgroup" string="Location Group" domain="[('user_id','in',[user.id for user in location_id.user_group.users])]" context="{'group_by':'date'}"/>
            </filter>
        </field>
    </record>

I also added field location_id to the tree view.

But Im still getting an error (after choosing the filter) that even google doesnt know anything about:

TypeError: results.group_by is undefined

My questions are:

  1. By looking on domain in filter field - what am i doing wrong?

  2. Is something like that even possible?

I will gladly welcome any help.

1
can you post the full view file (xml) here ?Senthilnathan

1 Answers

0
votes

Firstly, i think your domain is not correct, it could have been :

[('user_group.users.id', '=', uid)]

(because the first element of the tuple is a field on the model; and uid is a special value supplied in search views)

Next, This error :

TypeError: results.group_by is undefined

Seems to be a Javascript Error (coming from openerp-web interface), it often throws error like that when it receives unexpected values (when we make a mistake defining a view for example).

can you tell us if using the domain above solved your problem ?

NB: does your field user_group is a required field ? If not, i think the domain above won't display picking where user_group is not set, if you want to display picking where user_group is not set too, you can set a domain like that:

['|',('user_group.users.id', '=', uid), ('user_group','=',False)]

Regards