Is there a method to prevent a user to create a sales order if the populated items in the lines are not found in stock?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi,
To prevent sale order creation if an item is not in stock in Odoo, you can use the Sale Stock Restrict module from the Odoo App Store.This module is helps to restrict out of stock products.
Here is the link to the app:
https://apps.odoo.com/apps/modules/16.0/sale_stock_restrict/
Hope it helps
Hi
You can use validation error or UserError for preventing the creation of a sale order with onchange or within the create function of Sale Order
Try with following code
class SaleOrderInherit(models.Model):
_inherit = 'sale.order'
@api.onchange('order_line')
def _onchange_check_lines(self):
for rec in self:
for line in rec.order_line:
if line.product_id.qty_available == 0:
raise ValidationError("Item is not in Stock")
Use this example too
class SaleOrderInherit(models.Model):
_inherit = 'sale.order'
@api.model
def create(self, vals_list):
res = super(SaleOrderInherit, self).create(vals_list)
order_id = res.order_line
for rec in order_id:
if rec.product_id.qty_available == 0:
raise ValidationError("Item is not in Stock")
return res
Regards
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 6 22
|
5187 | ||
|
2
thg 2 21
|
2283 | ||
|
0
thg 5 20
|
3587 | ||
|
0
thg 9 19
|
4377 | ||
|
1
thg 8 16
|
3594 |