Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
3245 Lượt xem

Hello.

Is there any way to automatically cancel deliveries when a sales order is generated without having to uninstall any module? Is it possible from some server action?

Whenever I create a sales order automatically, the deliveries are created, but I want them to be canceled when the sales order is generated.

Thank you! Odoo 16 community

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can try with an automated action, go to setting -> technical -> automated actions.

create an action and try it like this,


deliveries = env['stock.picking'].search([('origin', '=', self.name)])

for delivery in deliveries:

​delivery.action_cancel()


Note: Install the base_automation module if you couldn't find the automated actions menu inside settings.

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

I get this error when confirming the quote:
<class 'NameError'>: "name 'self' is not defined" while evaluating
"deliveries = self.env['stock.picking'].search([('sale_id', '=', self.id)])\nfor delivery in deliveries:\n delivery.action_cancel()"

I have updated the answer, remove the self and try.

Tác giả

Thanks for taking the time to help me, it didn't work either, now it shows me an error in self.id, I'll keep looking for more options..
Thank you!

please try this,
self.env['stock.picking'].search([('origin', '=', self.name)])

Tác giả

thanks!

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
3625
2
thg 5 24
15556
1
thg 5 25
1128
1
thg 4 24
3579
1
thg 12 22
1109