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

Hii,

There are two Warehouses,

1. Main WH  (stock is for sale in sales orders)

2. Under Sale WH (stock is not for sale in sales orders)

Under Sale Warehouse stock is not for Sale. 

Product OnHand it shows total stock from both Warehouses and its OK and required.

Sales Order Line we want to show stock available from Main Warehouse only.

On Sales Orders how we can stop  selling stock from Under Sale WH?

 Odoo 12 EE


Avatar
Discard
Author Best Answer

Following solution working with us.

1. Added a new custom selection(internal, under sale) field in store.warehouse
2. Added a custom calculated field to sale.order.line 
3. Showed new calculated field on sales order lines form view

It will give the idea to salesperson how much stock we have on hand in warehouse of type internal.

class SaleOrderLine(models.Model):
    _inherit = "sale.order.line"

    internal_available = fields.Float(compute="_compute_internal_available", string='Internal OnHand')

    @api.depends('product_uom_qty', 'product_id')
    def _compute_internal_available(self):
        for rec in self.filtered(lambda sol: sol.order_id.state not in ['cancel']):
            qty = 0
            warehouses = self.env['stock.warehouse'].sudo().search([('warehouse_type', '=', 'internal')])
            for wh in warehouses:
                qty += rec.product_id.with_context(warehouse=wh.id).qty_available
            rec.internal_available = qty
Avatar
Discard