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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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,
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
1
lis 24
|
2101 | ||
Can you regenerate the stock_quant table
Rozwiązane
|
|
2
kwi 23
|
7543 | |
|
1
lut 22
|
3460 | ||
Quantity on Hand Calculated Wrong?
Rozwiązane
|
|
1
wrz 21
|
3925 | |
Quantity Value Error in Tree View
Rozwiązane
|
|
1
maj 23
|
1907 |