Hello, I'm trying to create a domain in stock operation form for products serial numbers to choose the positive ones only.
the code in the comment doesn't change anything. any one has any idea why?
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello, I'm trying to create a domain in stock operation form for products serial numbers to choose the positive ones only.
the code in the comment doesn't change anything. any one has any idea why?
Thanks
the problem is that we can't filter depending on non stored fields and we can't store computed fields and the quantity field is computed and non stored.
So I solved it this way, Finally:
in the model:
_inherit = 'stock.production.lot'in the view:
available_to_choose = fields.Boolean('Available', store=True, compute='_available')
@api.depends('quant_ids', 'quant_ids.reserved_quantity', 'quant_ids.quantity', 'product_qty')
def _available(self):
for lot in self:
if lot.product_qty <= 0:
lot.available_to_choose = False
elif lot.product_qty > 0:
quants = lot.quant_ids.filtered(lambda q: q.location_id.usage in ['internal', 'transit'])
for q in quants:
if q.quantity - q.reserved_quantity > 0:
lot.available_to_choose = True
elif q.quantity - q.reserved_quantity < 0:
lot.available_to_choose = False
@api.onchange('product_qty')
def _onchange_usage(self):
if self.product_qty > 0:
self.available_to_choose = True
else:
self.available_to_choose = False
domain="[('product_id', '=', product_id), ('available_to_choose','>', 0)]"/>
domain="[('product_id', '=', product_id), ('available_to_choose','>', 0)]"/>
available_to_choose : is boolean fields
i think you want to say that
domain="[('product_id', '=', product_id), ('available_to_choose','!=', False)]"/>
Hi Mr.Ali,
In odoo 13 inventory_quantity field is defined and used in stock.quant model for viewing the current inventory of the products in specific location.
You have used that field in domain for lot which is stock_production_lot and i dont know why you didn't get an error for specifying in view.
Correct me please if am wrong.
Thanks
yeah, I discovered that and changed the code but still it's not working:
<record id="view_stock_move_line_operation_tree" model="ir.ui.view">
<field name="name">stock.move.line.operations.tree - stock_picking_filter_lot</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">
<xpath expr="//tree/field[@name='lot_id']" position="replace">
<field name="lot_id" groups="stock.group_production_lot"
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), ('product_qty','>', .0)]"
context="{
'active_picking_id': picking_id,
'default_company_id': parent.company_id,
'default_product_id': parent.product_id,
}"
/>
</xpath>
</field>
</record>
<record id="view_stock_move_line_detailed_operation_tree" model="ir.ui.view">
<field name="name">stock.move.line.detailed.operations.tree - stock_picking_filter_lot</field>
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_stock_move_line_detailed_operation_tree"/>
<field name="arch" type="xml">
<xpath expr="//tree/field[@name='lot_id']" position="replace">
<field name="lot_id" groups="stock.group_production_lot"
attrs="{'column_invisible': [('parent.show_lots_text', '=', True)], 'invisible': [('lots_visible', '=', False)]}"
domain="['&', ('product_id', '=', product_id), ('product_qty','>', 1.0)]"
context="{'default_product_id': product_id, 'default_company_id': company_id, 'active_picking_id': picking_id}"/>
</xpath>
</field>
</record>
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
InscribirsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
1
oct 20
|
5519 | ||
naked domain set up
Resuelto
|
|
3
jul 25
|
3914 | |
|
0
may 25
|
750 | ||
|
2
mar 24
|
1958 | ||
|
1
jul 23
|
1762 |