mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[IMP] rma: prevent the creation of zero qty moves
This commit is contained in:
committed by
DavidJForgeFlow
parent
2760f14ed0
commit
cdafac7a61
@@ -30,6 +30,7 @@ class StockRule(models.Model):
|
|||||||
)
|
)
|
||||||
if "rma_line_id" in values:
|
if "rma_line_id" in values:
|
||||||
line = values.get("rma_line_id")
|
line = values.get("rma_line_id")
|
||||||
|
line = self.env["rma.order.line"].browse([line])
|
||||||
res["rma_line_id"] = line.id
|
res["rma_line_id"] = line.id
|
||||||
if line.delivery_address_id:
|
if line.delivery_address_id:
|
||||||
res["partner_id"] = line.delivery_address_id.id
|
res["partner_id"] = line.delivery_address_id.id
|
||||||
|
|||||||
@@ -880,3 +880,18 @@ class TestRma(common.SavepointCase):
|
|||||||
self.assertTrue(new_line.product_id.categ_id.rma_customer_operation_id)
|
self.assertTrue(new_line.product_id.categ_id.rma_customer_operation_id)
|
||||||
new_line._onchange_product_id()
|
new_line._onchange_product_id()
|
||||||
self.assertEqual(new_line.operation_id, rma_operation)
|
self.assertEqual(new_line.operation_id, rma_operation)
|
||||||
|
|
||||||
|
def test_06_no_zero_qty_moves(self):
|
||||||
|
rma_lines = self.rma_customer_id.rma_line_ids
|
||||||
|
rma_lines.write({"receipt_policy": "delivered"})
|
||||||
|
self.assertEqual(sum(rma_lines.mapped("qty_to_receive")), 0)
|
||||||
|
wizard = self.rma_make_picking.with_context(
|
||||||
|
{
|
||||||
|
"active_ids": rma_lines.ids,
|
||||||
|
"active_model": "rma.order.line",
|
||||||
|
"picking_type": "incoming",
|
||||||
|
"active_id": 1,
|
||||||
|
}
|
||||||
|
).create({})
|
||||||
|
with self.assertRaisesRegex(ValidationError, "No quantity to transfer"):
|
||||||
|
wizard._create_picking()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import time
|
|||||||
|
|
||||||
from odoo import _, api, fields, models
|
from odoo import _, api, fields, models
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT
|
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT as DT_FORMAT, float_compare
|
||||||
|
|
||||||
|
|
||||||
class RmaMakePicking(models.TransientModel):
|
class RmaMakePicking(models.TransientModel):
|
||||||
@@ -148,7 +148,12 @@ class RmaMakePicking(models.TransientModel):
|
|||||||
else:
|
else:
|
||||||
qty = item.qty_to_deliver
|
qty = item.qty_to_deliver
|
||||||
values = self._get_procurement_data(item, group, qty, picking_type)
|
values = self._get_procurement_data(item, group, qty, picking_type)
|
||||||
values = dict(values, rma_line_id=item.line_id, rma_id=item.line_id.rma_id)
|
product = item.line_id.product_id
|
||||||
|
if float_compare(qty, 0, product.uom_id.rounding) != 1:
|
||||||
|
raise ValidationError(
|
||||||
|
_("No quantity to transfer on %s shipment of product %s.")
|
||||||
|
% (_(picking_type), product.default_code or product.name)
|
||||||
|
)
|
||||||
# create picking
|
# create picking
|
||||||
procurements = []
|
procurements = []
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user