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,9 +83,11 @@ class RmaAddSale(models.TransientModel):
|
||||
}
|
||||
|
||||
def _prepare_rma_line_from_sale_order_line(self, line, lot=None):
|
||||
operation = line.product_id.rma_customer_operation_id
|
||||
operation = self.rma_id.operation_default_id
|
||||
if not operation:
|
||||
operation = line.product_id.categ_id.rma_customer_operation_id
|
||||
operation = line.product_id.rma_customer_operation_id
|
||||
if not operation:
|
||||
operation = line.product_id.categ_id.rma_customer_operation_id
|
||||
if not operation:
|
||||
operation = self.env["rma.operation"].search(
|
||||
[("type", "=", self.rma_id.type)], limit=1
|
||||
@@ -98,18 +100,27 @@ class RmaAddSale(models.TransientModel):
|
||||
)
|
||||
if not route:
|
||||
raise ValidationError(_("Please define an rma route"))
|
||||
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
||||
warehouse = self.env["stock.warehouse"].search(
|
||||
[
|
||||
("company_id", "=", self.rma_id.company_id.id),
|
||||
("lot_rma_id", "!=", False),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
if not warehouse:
|
||||
raise ValidationError(
|
||||
_("Please define a warehouse with a " "default rma location.")
|
||||
warehouse = self.rma_id.in_warehouse_id
|
||||
if not warehouse:
|
||||
if not operation.in_warehouse_id or not operation.out_warehouse_id:
|
||||
warehouse = self.env["stock.warehouse"].search(
|
||||
[
|
||||
("company_id", "=", self.rma_id.company_id.id),
|
||||
("lot_rma_id", "!=", False),
|
||||
],
|
||||
limit=1,
|
||||
)
|
||||
if not warehouse:
|
||||
raise ValidationError(
|
||||
_("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
|
||||
if line.product_id.tracking == "serial":
|
||||
product_qty = 1
|
||||
@@ -141,15 +152,11 @@ class RmaAddSale(models.TransientModel):
|
||||
"in_route_id": operation.in_route_id.id or route.id,
|
||||
"out_route_id": operation.out_route_id.id or route.id,
|
||||
"receipt_policy": operation.receipt_policy,
|
||||
"location_id": (
|
||||
operation.location_id.id
|
||||
or operation.in_warehouse_id.lot_rma_id.id
|
||||
or warehouse.lot_rma_id.id
|
||||
),
|
||||
"location_id": location.id,
|
||||
"refund_policy": operation.refund_policy,
|
||||
"delivery_policy": operation.delivery_policy,
|
||||
"in_warehouse_id": operation.in_warehouse_id.id or warehouse.id,
|
||||
"out_warehouse_id": operation.out_warehouse_id.id or warehouse.id,
|
||||
"in_warehouse_id": warehouse.id or operation.in_warehouse_id.id,
|
||||
"out_warehouse_id": warehouse.id or operation.out_warehouse_id.id,
|
||||
}
|
||||
return data
|
||||
|
||||
@@ -193,6 +200,7 @@ class RmaAddSale(models.TransientModel):
|
||||
# favor of (pre)computed stored editable fields for all policies
|
||||
# and configuration in the RMA operation.
|
||||
rec._onchange_operation_id()
|
||||
rec.price_unit = rec._get_price_unit()
|
||||
rma = self.rma_id
|
||||
data_rma = self._get_rma_data()
|
||||
rma.write(data_rma)
|
||||
|
||||
Reference in New Issue
Block a user