跳至内容
菜单
此问题已终结
1 回复
964 查看

Currently iam building custom module for odoo 14, and found view "mrp.view_stock_move_operations_finished" that inherited from "stock.view_stock_move_operations". Inside "stock.view_stock_move_operations" i found a one2many field "move_line_ids" and inside that one2many field theres a field called "package_id" and i want to put a new field after that field. but when i see the xml of  stock.view_stock_move_operations i only found this code   


  


i am really confused of how to put the xpath, i tried to xpath like this   

<xpathexpr="//field[@name='package_id']"position="before"><fieldname="smam_panjang"/>

<fieldname="smam_lebar"/>

<fieldname="smam_tebal"/>

xpath>   


but i got error that say it cant find a field called 'package_id'  and while i am at it, how do i call the new field too? can i call it like this   

   

do note that new field is created inside the model refered by one2many field. I would be really thankfull if you help me. Thanks!

形象
丢弃
编写者

<field name="move_line_ids" attrs="{'readonly': ['|', ('state', '=', 'cancel'), '&amp;', ('state', '=', 'done'), ('is_locked', '=', True)]}" context="{'tree_view_ref': 'stock.view_stock_move_line_operation_tree', 'default_product_uom_id': product_uom, 'default_picking_id': picking_id, 'default_move_id': id, 'default_product_id': product_id, 'default_location_id': location_id, 'default_location_dest_id': location_dest_id, 'default_company_id': company_id}"/>

编写者

This is the code i found at stock.view_stock_move_operations. i dont know why when i tried to post this code, i got some error so i put this in the comment. point is it just call the one2many field and not call any field inside the one2many field

最佳答案

The package_id belong to move_line_ids model and its shown using this tree view  stock.view_stock_move_line_operation_tree so you need to inherit this tree view:

   <record id="view_stock_move_line_operation_tree_inherit_custom" model="ir.ui.view">


            <field name="name">stock.move.line.operations.tree.inherit.custom</field>


            <field name="model">stock.move.line</field>


            <field name="inherit_id" ref="stock.view_stock_move_line_operation_tree"/>


            <field name="arch" type="xml">


                <field name="package_id" position="before">


                    <fieldname="smam_panjang"/>


                    <fieldname="smam_lebar"/>


                    <fieldname="smam_tebal"/>


                </field>


            </field>


    </record>


形象
丢弃
编写者

Thanks you for answering my question, it seems changing that tree view will add my field. but do you know how to add my custom spesific field on spesific view only? in my case i only want to add it to this view :

mrp.view_stock_move_operations_finished