Skip to content

Commit

Permalink
[FIX] rma_account and rma_sale: following the comments that were made…
Browse files Browse the repository at this point in the history
… during the review
  • Loading branch information
chafique-delli committed Sep 10, 2024
1 parent d11d79f commit ab99e40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
13 changes: 3 additions & 10 deletions rma_account/wizards/rma_refund.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def default_get(self, fields_list):
items = []
if active_model == "rma.order":
rma = rma_obj.browse(active_ids)
lines = rma.rma_line_ids
lines = rma.rma_line_ids.filtered(lambda x: x.qty_to_refund > 0)
else:
lines = rma_line_obj.browse(active_ids)
if len(lines.mapped("partner_id")) > 1:
Expand Down Expand Up @@ -105,16 +105,9 @@ def compute_refund(self):
return new_refund

def invoice_refund(self):
rma_line_obj = self.env["rma.order.line"]
rma_obj = self.env["rma.order"]
active_ids = self.env.context.get("active_ids") or []
active_model = self.env.context.get("active_model")
if active_model == "rma.order":
rma = rma_obj.browse(active_ids)
lines = rma.rma_line_ids
else:
lines = rma_line_obj.browse(active_ids)
lines = self.item_ids.line_id
for line in lines:

if line.state != "approved":
raise ValidationError(_("RMA %s is not approved") % line.name)
new_invoice = self.compute_refund()
Expand Down
21 changes: 2 additions & 19 deletions rma_sale/wizards/rma_make_sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def default_get(self, fields_list):
items = []
if active_model == "rma.order":
rma = rma_obj.browse(active_ids)
lines = rma.rma_line_ids
lines = rma.rma_line_ids.filtered(lambda x: x.qty_to_sell > 0)
else:
lines = rma_line_obj.browse(active_ids)
for line in lines:
Expand Down Expand Up @@ -161,9 +161,7 @@ class RmaLineMakeSaleOrderItem(models.TransientModel):
_description = "RMA Line Make Sale Order Item"

wiz_id = fields.Many2one(comodel_name="rma.make.sale.order", string="Wizard")
line_id = fields.Many2one(
comodel_name="rma.order.line", string="RMA Line", compute="_compute_line_id"
)
line_id = fields.Many2one(comodel_name="rma.order.line", string="RMA Line")
rma_id = fields.Many2one(
comodel_name="rma.order", related="line_id.rma_id", readonly=False
)
Expand All @@ -176,21 +174,6 @@ class RmaLineMakeSaleOrderItem(models.TransientModel):
)
free_of_charge = fields.Boolean(string="Free of Charge")

def _compute_line_id(self):
rma_line_obj = self.env["rma.order.line"]
rma_obj = self.env["rma.order"]
active_ids = self.env.context.get("active_ids") or []
active_model = self.env.context.get("active_model")
for rec in self:
if not active_ids:
return
if active_model == "rma.order":
rma = rma_obj.browse(active_ids)
lines = rma.rma_line_ids
else:
lines = rma_line_obj.browse(active_ids)
rec.line_id = lines[0]

@api.onchange("product_id")
def onchange_product_id(self):
if self.product_id:
Expand Down

0 comments on commit ab99e40

Please sign in to comment.