forked from OCA/sale-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstock_move.py
More file actions
22 lines (18 loc) · 783 Bytes
/
stock_move.py
File metadata and controls
22 lines (18 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Copyright 2023 ACSONE SA/NV
# Copyright 2024 Jacques-Etienne Baudoux (BCIM) <je@bcim.be>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import models
class StockMove(models.Model):
_inherit = "stock.move"
def _action_cancel(self):
sale_moves = self.filtered(
lambda m: m.sale_line_id and m.state not in ("done", "cancel")
)
res = super()._action_cancel()
sale_lines = sale_moves.filtered(lambda m: m.state == "cancel").sale_line_id
for line in sale_lines:
# Update SO line qty canceled only when all remaining moves are canceled
if line._get_moves_to_cancel():
continue
line.product_qty_canceled = line.qty_to_deliver
return res