Skip to Content
Menu
This question has been flagged
2 Replies
24929 Views

Hello, I am creating a custom form view for odoo stock.picking module

My xml file contains the following record:

<record id="raizs_stock_picking_form_view" model="ir.ui.view">
    <field name="name">raizs.stock.picking.form.view</field>
    <field name="model">stock.picking</field>
    <field name="priority" eval="20"/>
    <field name="arch" type="xml">
        <form string="Movimentos">
            <sheet>
                <group>
                    <field name="name"></field>
                    <field name="partner_id"></field>
                    <field name="state"></field>
                </group>
                <notebook>
                    <page string="Produtos" >
                            <field name="id" invisible="1"/>
                        <field name="move_lines" style="pointer-events:none;">
                            <tree create="false" edit="false" editable="bottom" options="{'no_open': True}">
                                    <field name="state" invisible="True"/>
                                    <field name="additional" invisible="
                                    <field name="is_initial_demand_editable" invisible="True"/>
                                    <field name="is_quantity_done_editable" invisible="True"/>
                                    <field name="has_move_lines" invisible="True"/>
                                    <field name="product_id" required="1" attrs="{'readonly': ['|', '&amp;', ('state', '!=', 'draft'),                                                 ('additional', '=', False), ('has_move_lines', '=', True)]}"/>
                                    <field name="product_uom_qty" string="Initial Demand" attrs="{'readonly':                                                 [('is_initial_demand_editable', '=', False)]}"/>
                                    <field name="quantity_done" string="Done" attrs="{'readonly': [('is_quantity_done_editable',                                                 '=', False)]}"/>
                                    <field name="product_uom" attrs="{'readonly': [('state', '!=', 'draft'), ('additional', '=', False)]}"                                             options="{'no_open': True, 'no_create': True}" string="Unit of Measure"                                             groups="product.group_uom"/>
                            </tree>
                    </field>
            </page>
        </notebook>
    </sheet>
</form>
</field>
  </record>


I am having two problems:

1. I am trying to prevent the clicking on the move_line tree lines from opening the form view, but it keeps opening.

2. I want to display this tree view on odoo app for android, but it keeps showing the move_line records as a kanban view, even if I didn't specify it.

How do I get these 2 points right?

Thank you!

Avatar
Discard
Author Best Answer

Thanks to your answer @subbarao, Unfortunately, the changes  you mentioned didn't work for me =/

I will post my whole view to clarify things, but basically I created to two menuitems and two actions for them, that open the same list and form views, but with different domains.

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <menuitem
        id="raizs_receipt_root_menu"
        name="Recebimentos"
    />

<record id="raizs_stock_picking_form_view" model="ir.ui.view">
    <field name="name">raizs.stock.picking.form.view</field>
    <field name="model">stock.picking</field>
    <field name="priority" eval="20"/>
    <field name="arch" type="xml">
    <form string="Movimentos">
        <sheet>
            <group>
                <field name="name"></field>
                <field name="partner_id"></field>
                <field name="state"></field>
           </group>
           <notebook>
                <page string="Produtos" >
                    <field name="id" invisible="1"/>
                    <field name="move_lines">
                        <tree create="false" editable="bottom" options="{'no_open': True}">
                            <field name="state" invisible="True"/>
                            <field name="additional" invisible="True"/>
                            <field name="is_initial_demand_editable" invisible="True"/>
                            <field name="is_quantity_done_editable" invisible="True"/>
                            <field name="has_move_lines" invisible="True"/>
                            <field name="product_id" required="1" attrs="{'readonly': ['|', '&amp;', ('state', '!=', 'draft'),                             ('additional', '=', False), ('has_move_lines', '=', True)]}"/>
                            <field name="product_uom_qty" string="Initial Demand" attrs="{'readonly':                             [('is_initial_demand_editable', '=', False)]}"/>
                            <field name="quantity_done" string="Done" attrs="{'readonly': [('is_quantity_done_editable', '=',                             False)]}"/>
                            <field name="product_uom" attrs="{'readonly': [('state', '!=', 'draft'), ('additional', '=', False)]}"                             options="{'no_open': True, 'no_create': True}" string="Unit of Measure"                             groups="product.group_uom"/>
                            <button name="add_quantity_done" string="+" type="object"/>
                            <button name="remove_quantity_done" string="-" type="object"/>
                        </tree>
                    </field>
                </page>
                </notebook>
            </sheet>
         </form>
    </field>
</record>

<record id="raizs_stock_picking_tree_view" model="ir.ui.view">
    <field name="name">raizs.stock.picking.tree.view</field>
    <field name="model">stock.picking</field>
    <field name="arch" type="xml">
        <tree string="Movimentos">
            <field name="partner_id"></field>
            <field name="scheduled_date"></field>
            <field name="state"></field>
        </tree>
    </field>
</record>

<record model="ir.actions.act_window" id="action_raizs_today_receipts">
    <field name="name">Recebimentos de hoje</field>
    <field name="res_pmodel">stock.picking</field>
    <field name="view_model">tree,form</field>
    <field name="view_ids" eval="[(5, 0, 0),
            (0, 0, {'view_mode': 'tree', 'view_id': ref('raizs_stock_picking_tree_view')}),
            (0, 0, {'view_mode': 'form', 'view_id': ref('raizs_stock_picking_form_view')})]"
    />
    <field name="domain">
        [
            ('scheduled_date','&gt;=',(context_today().strftime('%Y-%m-%d'))),
            ('location_dest_id','=',38)
        ]
    </field>
</record>
<menuitem
    id="raizs_today_receipts_menu"
    parent="raizs_receipt_root_menu"
    action="action_raizs_today_receipts"
/>

<record model="ir.actions.act_window" id="action_raizs_late_receipts">
    <field name="name">Recebimentos atrasados</field>
    <field name="res_model">stock.picking</field>
    <field name="view_model">tree,form</field>
    <field name="view_ids" eval="[(5, 0, 0),
        (0, 0, {'view_mode': 'tree', 'view_id': ref('raizs_stock_picking_tree_view')}),
        (0, 0, {'view_mode': 'form', 'view_id': ref('raizs_stock_picking_form_view')})]"
    />
    <field name="domain">
    [
        ('scheduled_date','&lt;=',(context_today().strftime('%Y-%m-%d'))),
        ('location_dest_id','=',38)
    ]
    </field>
</record>
<menuitem
    id="raizs_late_receipts_menu"
    parent="raizs_receipt_root_menu"
    action="action_raizs_late_receipts"
/>

</odoo> 


Avatar
Discard
Best Answer

solution for Point 1

edit="false"  you have to remove
create="false" if you use ting you can't able to add new lines only possible to edit the existing lines

<field name="move_lines" style="pointer-events:none;">
                            <tree create="false" editable="bottom" options="{'no_open': True}">
                                    <field name="state" invisible="True"/>
                                    <field name="is_initial_demand_editable" invisible="True"/>
                                    <field name="is_quantity_done_editable" invisible="True"/>
                                    <field name="has_move_lines" invisible="True"/>
                                    <field name="product_id" required="1" attrs="{'readonly': ['|', '&amp;', ('state', '!=', 'draft'),                                                 ('additional', '=', False), ('has_move_lines', '=', True)]}"/>
                                    <field name="product_uom_qty" string="Initial Demand" attrs="{'readonly':                                                 [('is_initial_demand_editable', '=', False)]}"/>
                                    <field name="quantity_done" string="Done" attrs="{'readonly': [('is_quantity_done_editable',                                                 '=', False)]}"/>
                                    <field name="product_uom" attrs="{'readonly': [('state', '!=', 'draft'), ('additional', '=', False)]}"                                             options="{'no_open': True, 'no_create': True}" string="Unit of Measure"                                            groups="product.group_uom"/>
                            </tree>
                    </field>


to reflect these changes you have inherit and add menu action of picking
form view_id = raizs_stock_picking_form_view
Avatar
Discard
Related Posts Replies Views Activity
1
Jan 23
1074
3
Dec 23
22180
1
Sep 23
3581
4
Dec 23
16127
1
Sep 16
6473