تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
4992 أدوات العرض

How can I update stock quantities with scheduled actions, I want to set stock to zero automatically after 1 week. Have tried with change quantity and I still can get get it to work.

or Is there any best method to archive it.

الصورة الرمزية
إهمال
أفضل إجابة

Hello Kanda,

I have managed to figure out how this would work, here is the code:

# get all products which are products
products = env["product.product"].search([("type", "=", "product")])

for product in products:
    template = product.product_tmpl_id
    new_quantity = 0
    stock_change = env["stock.change.product.qty"].create(
    [
        {
            "new_quantity": new_quantity,
            "product_id": product.id,
            "product_tmpl_id": template.id
            }
        ]
    )
    stock_change.change_product_qty()

This hasn't been fully tested but seems to work on products which have a product and uses the same algorithm when you click the "Update Quantity" button.

All the best,

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
نوفمبر 24
2090
2
أبريل 23
7537
1
فبراير 22
3456
1
سبتمبر 21
3914
1
مايو 23
1883