mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[14.0][IMP] added default operation on rma group, easy setup before rma lines created (#452)
* [14.0][IMP] added default operation on rma group, easy setup before rma lines created * [IMP] added fields for default route created by wizard on rma group * fix: get right price after create rma order line
This commit is contained in:
committed by
JasminSForgeFlow
parent
a1d05720ee
commit
c4f94678ea
@@ -83,6 +83,8 @@ class RmaAddSale(models.TransientModel):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _prepare_rma_line_from_sale_order_line(self, line, lot=None):
|
def _prepare_rma_line_from_sale_order_line(self, line, lot=None):
|
||||||
|
operation = self.rma_id.operation_default_id
|
||||||
|
if not operation:
|
||||||
operation = line.product_id.rma_customer_operation_id
|
operation = line.product_id.rma_customer_operation_id
|
||||||
if not operation:
|
if not operation:
|
||||||
operation = line.product_id.categ_id.rma_customer_operation_id
|
operation = line.product_id.categ_id.rma_customer_operation_id
|
||||||
@@ -98,6 +100,8 @@ class RmaAddSale(models.TransientModel):
|
|||||||
)
|
)
|
||||||
if not route:
|
if not route:
|
||||||
raise ValidationError(_("Please define an rma route"))
|
raise ValidationError(_("Please define an rma route"))
|
||||||
|
warehouse = self.rma_id.in_warehouse_id
|
||||||
|
if not warehouse:
|
||||||
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
||||||
warehouse = self.env["stock.warehouse"].search(
|
warehouse = self.env["stock.warehouse"].search(
|
||||||
[
|
[
|
||||||
@@ -110,6 +114,13 @@ class RmaAddSale(models.TransientModel):
|
|||||||
raise ValidationError(
|
raise ValidationError(
|
||||||
_("Please define a warehouse with a " "default rma location.")
|
_("Please define a warehouse with a " "default rma location.")
|
||||||
)
|
)
|
||||||
|
location = self.rma_id.location_id
|
||||||
|
if not location:
|
||||||
|
location = (
|
||||||
|
operation.location_id
|
||||||
|
or operation.in_warehouse_id.lot_rma_id
|
||||||
|
or warehouse.lot_rma_id
|
||||||
|
)
|
||||||
product_qty = line.product_uom_qty
|
product_qty = line.product_uom_qty
|
||||||
if line.product_id.tracking == "serial":
|
if line.product_id.tracking == "serial":
|
||||||
product_qty = 1
|
product_qty = 1
|
||||||
@@ -141,15 +152,11 @@ class RmaAddSale(models.TransientModel):
|
|||||||
"in_route_id": operation.in_route_id.id or route.id,
|
"in_route_id": operation.in_route_id.id or route.id,
|
||||||
"out_route_id": operation.out_route_id.id or route.id,
|
"out_route_id": operation.out_route_id.id or route.id,
|
||||||
"receipt_policy": operation.receipt_policy,
|
"receipt_policy": operation.receipt_policy,
|
||||||
"location_id": (
|
"location_id": location.id,
|
||||||
operation.location_id.id
|
|
||||||
or operation.in_warehouse_id.lot_rma_id.id
|
|
||||||
or warehouse.lot_rma_id.id
|
|
||||||
),
|
|
||||||
"refund_policy": operation.refund_policy,
|
"refund_policy": operation.refund_policy,
|
||||||
"delivery_policy": operation.delivery_policy,
|
"delivery_policy": operation.delivery_policy,
|
||||||
"in_warehouse_id": operation.in_warehouse_id.id or warehouse.id,
|
"in_warehouse_id": warehouse.id or operation.in_warehouse_id.id,
|
||||||
"out_warehouse_id": operation.out_warehouse_id.id or warehouse.id,
|
"out_warehouse_id": warehouse.id or operation.out_warehouse_id.id,
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@@ -193,6 +200,7 @@ class RmaAddSale(models.TransientModel):
|
|||||||
# favor of (pre)computed stored editable fields for all policies
|
# favor of (pre)computed stored editable fields for all policies
|
||||||
# and configuration in the RMA operation.
|
# and configuration in the RMA operation.
|
||||||
rec._onchange_operation_id()
|
rec._onchange_operation_id()
|
||||||
|
rec.price_unit = rec._get_price_unit()
|
||||||
rma = self.rma_id
|
rma = self.rma_id
|
||||||
data_rma = self._get_rma_data()
|
data_rma = self._get_rma_data()
|
||||||
rma.write(data_rma)
|
rma.write(data_rma)
|
||||||
|
|||||||
Reference in New Issue
Block a user