mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
[14.0][ADD] rma_scrap
This commit is contained in:
committed by
JasminSForgeFlow
parent
14401983a8
commit
a98271f31a
31
rma_scrap/models/rma_order.py
Normal file
31
rma_scrap/models/rma_order.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# Copyright 2022 ForgeFlow S.L.
|
||||
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class RmaOrder(models.Model):
|
||||
_inherit = "rma.order"
|
||||
|
||||
def _compute_scrap_count(self):
|
||||
for order in self:
|
||||
moves = (
|
||||
order.mapped("rma_line_ids.move_ids")
|
||||
.filtered(lambda m: m.is_rma_scrap)
|
||||
.move_line_ids
|
||||
)
|
||||
order.scrap_count = len(moves)
|
||||
|
||||
scrap_count = fields.Integer(compute="_compute_scrap_count", string="# Scrap")
|
||||
|
||||
def action_view_scrap_transfers(self):
|
||||
self.ensure_one()
|
||||
action = self.env.ref("stock.action_stock_scrap")
|
||||
result = action.sudo().read()[0]
|
||||
scraps = self.env["stock.scrap"].search([("origin", "=", self.name)])
|
||||
if len(scraps) > 1:
|
||||
result["domain"] = [("id", "in", scraps.ids)]
|
||||
elif len(scraps) == 1:
|
||||
res = self.env.ref("stock.stock_scrap_form_view", False)
|
||||
result["views"] = [(res and res.id or False, "form")]
|
||||
result["res_id"] = scraps.ids[0]
|
||||
return result
|
||||
Reference in New Issue
Block a user