Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5198 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 15
9813
0
thg 4 23
2196
2
thg 9 21
4749
22
thg 12 23
49435
0
thg 3 15
3990