This question has been flagged
1 Reply
3227 Views

I created a module for dayli stock moves(Initial Stock, In, Out, Final Stock) and need filter by today, specific date and range o dates. But this don't show the search in my tree view. What is wrong?(Sorry for my english)

This is my module(stock_picking_extra.py):

class stock_moves(osv.osv):
_name="report.movimientos.stock"
_auto = False
_columns = {
    'date': fields.date('Fecha', readonly=True),
    'product_id': fields.many2one('product.product','Producto', readonly=True),
    'qty_inicial': fields.float('Inicial', readonly=True),
    'qty_in': fields.float('In', readonly=True),
    'qty_out': fields.float('Out', readonly=True),
    'qty_final': fields.float('Final', readonly=True)
}
_order = "date DESC"
def init(self, cr):
    tools.sql.drop_view_if_exists(cr,'report_movimientos_stock')
    cr.execute("""
        CREATE OR REPLACE VIEW report_movimientos_stock AS 
            SELECT movimientos_stock.id, movimientos_stock.date, movimientos_stock.product_id, movimientos_stock.qty_inicial, movimientos_stock.qty_in, movimientos_stock.qty_out, movimientos_stock.qty_final
            FROM movimientos_stock() movimientos_stock(id, date, product_id, qty_inicial, qty_in, qty_out, qty_final);
        """)

stock_moves()

My filter (stock_picking_in_view.xml)

<record id='movimientos_stock_filter' model='ir.ui.view'>
        <field name="name">movimientos.stock.filter</field>
        <field name="model">report.movimientos.stock</field>
        <field name="arch" type="xml">
            <search string="Moves">
                <field name="date" string="Fecha de Movimiento" filter_domain="['|',('date','=',self)]"/>
                <filter string="Mayor que" name="may_q" icon="terp-accessories-archiver" domain="['|',('date','>',self)]"/>
                <filter string="Menor que" name="men_q" icon="terp-accessories-archiver" domain="['|',('date','>',self)]"/>
            </search>
        </field>
    </record>

My tree (stock_picking_in_view.xml)

<record model='ir.ui.view' id='movimientos_stock_tree'>
        <field name='name'>movimientos.stock.tree</field>
        <field name='model'>report.movimientos.stock</field>
        <field name='type'>tree</field>
        <field name='priority'>10</field>
        <field name='arch' type='xml'>
            <tree string='Movimientos Diarios'>
                <field name='date'/>
                <field name='product_id'/>
                <field name='qty_inicial'/>
                <field name='qty_in'/>
                <field name='qty_out'/>
                <field name='qty_final'/>
            </tree>
        </field>
    </record>

And action

<record model='ir.actions.act_window' id='action_movimientos_stock'>
        <field name="name">Movimientos Diarios</field>
        <field name="res_model">report.movimientos.stock</field>
        <field name="view_type">tree</field>
        <field name="context">{"datetime.strftim('%%Y%%m%%d')":1}</field>
        <field name="view_mode">tree</field>
        <field name="view_id" ref="movimientos_stock_tree"/>
        <field name="search_view_id" ref="movimientos_stock_filter"/>
    </record>
Avatar
Discard
Author Best Answer

The problem was in action, because I wrote "tree" in view_type, but this need, value "form", to show search box

<record model='ir.actions.act_window' id='action_movimientos_stock'>
        <field name="name">Movimientos Diarios</field>
        <field name="res_model">report.movimientos.stock</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree</field>
        <field name="view_id" ref="movimientos_stock_tree"/>
        <field name="search_view_id" ref="movimientos_stock_filter"/>
    </record>

Other error is in filter, the correct value is:

 <filter string="More that" name="more"
 domain="[('days','>',self)]"/>
 <filter string="Less that" name="less"
 domain="[('days','<',self)]"/>

 Where &gt is ">" and &lt is "<"
Avatar
Discard