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

Hi everybody,


im new at odoo development so please help me a litle with this:

i already have the lot selection working in the sale order, but lot with i need to remove of the selection lot with 0 on quantity


im tried filtering in the domain, but is not working


the code is the next


.py

from odoo import api, fields, models, _

class SaleOrderLine(models.Model):    _inherit = 'sale.order.line'
    x_lot_id = fields.Many2one('stock.production.lot', 'Lot', copy=False)
  

    def _prepare_procurement_values(self, group_id=False):       

        res = super(SaleOrderLine, self)._prepare_procurement_values(group_id=group_id)        

        res['x_lot_id'] = self.x_lot_id.id        

        return res



and the views is the next


<?xml version="1.0" encoding="utf-8"?><odoo>    

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

<field name="model">sale.order</field>        

<field name="inherit_id" ref="sale.view_order_form"/>        

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

 <xpath expr="//field[@name='order_line']/tree/field[@name='product_id']" position="after">               

 <field name="x_lot_id" domain="[('product_id','=', product_id),('product_qty.quantity', '&gt;', 0.0)]"  context="{'default_product_id': product_id}" groups="stock.group_production_lot"/>            

</xpath> <xpath expr="//field[@name='order_line']/form/group/group/field[@name='product_id']" position="after"> <field name="x_lot_id" domain="[('product_id','=', product_id),('product_qty.quantity', '&gt;', 0.0)]" context="{'default_product_id': product_id}" groups="stock.group_production_lot"/> </xpath> </field>

 </record>    



Please give me an advice

Thank you


Avatar
Discard

Thank you for the quick answer, i tried make the change but odoo give me the next error

ERROR odootest odoo.osv.expression: Non-stored field stock.production.lot.product_qty cannot be searched.

any ideas?


thank you again

[["quant_ids.quantity",">",0]]

Best Answer

https://apps.odoo.com/apps/modules/15.0/ts_tracking_sale_by_unique_sno/


This will help you to select lot of serial no on sale order 

Avatar
Discard
Best Answer

Can you try changing product_qty.quantity to quant_ids.quantity

[Original answer was product_qty]

Avatar
Discard