Skip to content

Commit

Permalink
Merge PR #3085 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by dreispt
  • Loading branch information
OCA-git-bot committed Apr 28, 2024
2 parents 9a9eaa2 + 2281aac commit b9c1246
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
13 changes: 7 additions & 6 deletions sale_auto_remove_zero_quantity_lines/models/sale_order.py
Expand Up @@ -14,14 +14,15 @@ def _should_auto_remove_zero_quantity_lines(self):
def action_confirm(self):
for order in self:
if order._should_auto_remove_zero_quantity_lines():
zero_lines = order.order_line.filtered(
lambda line: line.product_id and line.product_uom_qty == 0
zero_or_empty_lines = order.order_line.filtered(
lambda line: (line.product_id and line.product_uom_qty == 0)
or (line.display_type == "line_note" and not line.name.strip())
)
if zero_lines:
if zero_or_empty_lines:
body = _(
"Some sale order lines with zero quantities were removed upon "
"confirmation."
"Some lines with zero quantities or empty notes were "
"removed upon confirmation."
)
order.message_post(body=body)
zero_lines.unlink()
zero_or_empty_lines.unlink()
return super().action_confirm()
Expand Up @@ -50,9 +50,25 @@ def test_sale_auto_remove_zero_quantity_lines(self):
"display_type": "line_note",
},
),
(
0,
0,
{
"name": " ",
"display_type": "line_note",
},
),
(
0,
0,
{
"name": " ",
"display_type": "line_section",
},
),
],
"pricelist_id": self.env.ref("product.list0").id,
}
)
so.action_confirm()
self.assertEqual(len(so.order_line), 2)
self.assertEqual(len(so.order_line), 3)

0 comments on commit b9c1246

Please sign in to comment.