[FIX] rma_scrap: various fixes

This commit is contained in:
Jordi Ballester Alomar
2022-11-03 18:13:52 +01:00
committed by SergiCForgeFlow
parent 70289bdadd
commit 0f59a8048f
9 changed files with 83 additions and 32 deletions

View File

@@ -21,3 +21,21 @@ class StockScrap(models.Model):
if self.is_rma_scrap:
self.move_id.is_rma_scrap = True
self.rma_line_id.move_ids |= self.move_id
def _prepare_move_values(self):
res = super(StockScrap, self)._prepare_move_values()
res["rma_line_id"] = self.rma_line_id.id
return res
def action_view_rma_line(self):
if self.rma_line_id.type == "customer":
action = self.env.ref("rma.action_rma_customer_lines")
res = self.env.ref("rma.view_rma_line_form", False)
else:
action = self.env.ref("rma.action_rma_supplier_lines")
res = self.env.ref("rma.view_rma_line_supplier_form", False)
result = action.sudo().read()[0]
# choose the view_mode accordingly
result["views"] = [(res and res.id or False, "form")]
result["res_id"] = self.rma_line_id.id
return result