Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
5173 Vizualizări

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.

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor

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.

Autor

@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.

Related Posts Răspunsuri Vizualizări Activitate
1
mar. 15
9803
0
apr. 23
2193
2
sept. 21
4739
22
dec. 23
49417
0
mar. 15
3978