Skip to Content
Menu
This question has been flagged
1 Atsakyti
2219 Rodiniai

So i am using odoo version 14 and using this code below :

Code in github for better view : https://github.com/SMAMHTN/test1/blob/main/stock_move.xml



" rel="ugc">ir.ui.view">
smam.request.plt
stock.move















attrs="{'readonly': ['&', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_m2o')"
domain="[('product_id', '=', parent.product_id), ('company_id', '=', company_id)]"
context="{
'active_picking_id': picking_id,
'default_company_id': parent.company_id,
'default_product_id': parent.product_id,
}"
/>
placeholder="Write your SN/LN one by one or copy paste a list."
attrs="{'readonly': ['&', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_text')"/>



























attrs="{'readonly': ['&', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_m2o')"
domain="[('product_id', '=', parent.product_id), ('company_id', '=', company_id)]"
context="{
'active_picking_id': picking_id,
'default_company_id': parent.company_id,
'default_product_id': parent.product_id,
}"
/>
placeholder="Write your SN/LN one by one or copy paste a list."
attrs="{'readonly': ['&', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_text')"/>
















I dont understand the behaviour of the code, its just show 2 same one2many field of move_line_ids without regarding the if else command. I tried to delete the else and only one showing (the if command one). I would be really thankfull if someone can fix my code. Thanks!

Portretas
Atmesti
Autorius

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="smam_request_plt" model="ir.ui.view">
<field name="name">smam.request.plt</field>
<field name="model">stock.move</field>
<field name="inherit_id" ref="mrp.view_stock_move_operations_finished"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='move_line_ids']" position="inside">
<field name="smam_warehouse_name" invisible="1"/>
<t t-if="smam_warehouse_name == 'RAWMAT'">
<field name="move_line_ids">
<tree editable="bottom" decoration-muted="state == 'done' and is_locked == True" decoration-success="product_uom_qty==qty_done" decoration-danger="qty_done &gt; product_uom_qty and state != 'done' and picking_code != 'incoming'">
<field name="company_id" invisible="1" force_save="1"/>
<field name="picking_id" invisible="1" force_save="1"/>
<field name="move_id" invisible="1" force_save="1" />
<field name="product_uom_category_id" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="package_level_id" invisible="1"/>
<field name="location_id" options="{'no_create': True}" attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" invisible="not context.get('show_source_location')" domain="[('id', 'child_of', parent.location_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" groups="stock.group_stock_multi_locations"/>
<field name="location_dest_id" width="0.75" attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" invisible="not context.get('show_destination_location')" domain="[('id', 'child_of', parent.location_dest_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" groups="stock.group_stock_multi_locations"/>
<field name="lot_id" groups="stock.group_production_lot"
attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_m2o')"
domain="[('product_id', '=', parent.product_id), ('company_id', '=', company_id)]"
context="{
'active_picking_id': picking_id,
'default_company_id': parent.company_id,
'default_product_id': parent.product_id,
}"
/>
<field name="lot_name" widget="text" groups="stock.group_production_lot"
placeholder="Write your SN/LN one by one or copy paste a list."
attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_text')"/>
<field name="smam_panjang"/>
<field name="smam_lebar"/>
<field name="smam_tebal"/>
<field name="package_id" attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" invisible="not context.get('show_package')" groups="stock.group_tracking_lot"/>
<field name="result_package_id" attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" groups="stock.group_tracking_lot"/>
<field name="owner_id" attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" invisible="not context.get('show_owner')" groups="stock.group_tracking_owner"/>
<field name="product_uom_qty" invisible="not context.get('show_reserved_quantity')" readonly="1"/>
<field name="state" invisible="1"/>
<field name="is_locked" invisible="1"/>
<field name="picking_code" invisible="1"/>
<field name="qty_done" invisible="1"/>
<field name="smam_done"/>
<field name="product_uom_id" options="{'no_open': True, 'no_create': True}" attrs="{'readonly': ['|', ('product_uom_qty', '!=', 0.0), '&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" string="Unit of Measure" groups="uom.group_uom"/>
</tree>
</field>
</t>
<t t-if="smam_warehouse_name != 'RAWMAT'">
<field name="move_line_ids">
<tree editable="bottom" decoration-muted="state == 'done' and is_locked == True" decoration-success="product_uom_qty==qty_done" decoration-danger="qty_done &gt; product_uom_qty and state != 'done' and picking_code != 'incoming'">
<field name="company_id" invisible="1" force_save="1"/>
<field name="picking_id" invisible="1" force_save="1"/>
<field name="move_id" invisible="1" force_save="1" />
<field name="product_uom_category_id" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="package_level_id" invisible="1"/>
<field name="location_id" options="{'no_create': True}" attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" invisible="not context.get('show_source_location')" domain="[('id', 'child_of', parent.location_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" groups="stock.group_stock_multi_locations"/>
<field name="location_dest_id" width="0.75" attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" invisible="not context.get('show_destination_location')" domain="[('id', 'child_of', parent.location_dest_id), '|', ('company_id', '=', False), ('company_id', '=', company_id)]" groups="stock.group_stock_multi_locations"/>
<field name="lot_id" groups="stock.group_production_lot"
attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_m2o')"
domain="[('product_id', '=', parent.product_id), ('company_id', '=', company_id)]"
context="{
'active_picking_id': picking_id,
'default_company_id': parent.company_id,
'default_product_id': parent.product_id,
}"
/>
<field name="lot_name" widget="text" groups="stock.group_production_lot"
placeholder="Write your SN/LN one by one or copy paste a list."
attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}"
invisible="not context.get('show_lots_text')"/>
<field name="package_id" attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" invisible="not context.get('show_package')" groups="stock.group_tracking_lot"/>
<field name="result_package_id" attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" groups="stock.group_tracking_lot"/>
<field name="owner_id" attrs="{'readonly': ['&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" invisible="not context.get('show_owner')" groups="stock.group_tracking_owner"/>
<field name="product_uom_qty" invisible="not context.get('show_reserved_quantity')" readonly="1"/>
<field name="state" invisible="1"/>
<field name="is_locked" invisible="1"/>
<field name="picking_code" invisible="1"/>
<field name="qty_done"/>
<field name="product_uom_id" options="{'no_open': True, 'no_create': True}" attrs="{'readonly': ['|', ('product_uom_qty', '!=', 0.0), '&amp;', ('package_level_id', '!=', False), ('parent.picking_type_entire_packs', '=', True)]}" string="Unit of Measure" groups="uom.group_uom"/>
</tree>
</field>
</t>
</xpath>
</field>
</record>
</odoo>

Autorius

here is the code, i dont know why i cant put it above

Best Answer

Hi,

You cannot use t-if inside the form view, instead you have to add div or groups inside the form view and make it hidden and visible using invisible attribute.

Sample:

<div attrs="{'invisible': ['|', ('is_email','=', False), ('invoice_without_email', '=', False)]}">


Thanks

Portretas
Atmesti
Autorius

its still not working, it only show the 2nd div, if i delete the 2nd div then it will show the 1st div . do you have any other solution?

Related Posts Replies Rodiniai Veikla
1
rugs. 24
1471
1
rugs. 21
4895
1
rugp. 23
3025
2
saus. 23
11192
1
rugp. 22
2816