Hi all,
i'm trying to unlink sale order line items withing my custom onchange( ) function.
when i run my function it unlink the item with all saleorder details such as customer details and others.
so if you have any method to unlink only saleorder line item without deleting other details.please let me know.
bellow is my custom onchange function.
@api.onchange('order_line')
def onchange_product_id_check_availability(self):
for ordr_ln in self.order_line:
if ordr_ln['product_id']:
stock_qun_obj = self.env['stock.quant'].search([('location_id', '=', self.location_obj_id), ('product_id', '=', ordr_ln['product_id'].id)])
tot_quantity = 0
tot_reserved_quantity = 0
for qunt in stock_qun_obj:
if qunt.quantity < 0 and qunt.reserved_quantity < 0:
tot_quantity = tot_quantity
tot_reserved_quantity
else:
tot_quantity = tot_quantity + qunt.quantity
tot_reserved_quantity = tot_reserved_quantity + qunt.reserved_quantity
# self.qty_available = stock_qun_obj.quantity - stock_qun_obj.reserved_quantity
ordr_ln['qty_available'] = tot_quantity - tot_reserved_quantity
if ordr_ln.product_uom_qty:
# raise ValidationError(ordr_ln.id.name)
if ordr_ln['qty_available'] < ordr_ln.product_uom_qty:
warning_mess = {
'title': ('Opps! Not enough stock'),
'message': (
'Not enough Stock on This product')
}
ordr_ln.id.unlink()