Skip to Content
Menu
This question has been flagged
1 Reply
1156 Views

Hi,

I am developing with odoo 14. I would like to allow the user to select production lot from a dropdown menu when creating the delivery note but I only want to show production lot with non-zero quantity (postive qty).

 

 

Here's my code for the view:

 

   

      stock.move.line.detailed.operation.tree.inherited

      stock.move.line

     

     

     

             

                 

                     

                         

                               

                                       

     

   

 

I got the following error:

 

Unsearchable field "stock.production.lot.product_qty" in path 'product_qty' in domain of ="[('product_qty','>',0)]"

 

Please advise how I can correct this. Thanks.

 

Regards,

Simon Lee


Avatar
Discard
Author

Hi,

 

My recent post cannot show some of the code but I cannot edit it. Below is the complete post. Can you please help repost it. Thanks.

 

Hi,

 

I am developing with odoo 14. I would like to allow the user to select production lot from a dropdown menu when creating the delivery note but I only want to show production lot with non-zero quantity (postive qty).

 

 

Here's my code for the view:

 

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

        <field name="name">stock.move.line.detailed.operation.tree.inherited</field>

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

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

        <field name="priority" eval="15"/>

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

                <xpath expr="//field[@name='lot_id']" position="replace">

                        <field name="lot_id" domain="[('product_qty','>',0)]" groups="stock.group_production_lot" attrs="{'column_invisible': [('parent.show_lots_text', '=', True)],

                                'invisible': [('lots_visible', '=', False)]}" context="{'default_product_id': product_id,

                                'default_company_id': company_id, 'active_picking_id': picking_id, 'display_qty': True}" optional="show"/>

                </xpath>

                <xpath expr="//field[@name='product_uom_id']" position="after"> 

                        <field name="no_of_outer" />

               </xpath>         

        </field>

    </record>

 

I got the following error:

 

Unsearchable field "stock.production.lot.product_qty" in path 'product_qty' in domain of <field name="lot_id"> ="[('product_qty','>',0)]"

 

Please advise how I can correct this. Thanks.

 

Regards,

Simon Lee

 

 

From: Balagopal R <r.balagopal22@gmail.com>
Sent: Wednesday, September 29, 2021 5:06 PM
To: Simon Lee <simonlee@hago-group.com>
Subject: How to show production lot with non-zero qty

 

A new question How to show production lot with non-zero qty on Help has been posted. Click here to access the question :

See question

Sent by Odoo S.A. using Odoo.

Best Answer

"product_qty" in stock.product.lot object is an auto-compute field and it doesn't store and that's why you cannot use it in the domain.

You should overwrite the field and add "store=True" attribute in py file:

class Lot(...):
_inherit = 'stock.production.lot'

product_qty = fields.Float('Quantity', compute='_product_qty', store=True)


Avatar
Discard
Author

It works. Thank you for your advise.

Regards,
Simon