Files
stock-rma/rma/models/res_partner.py
2020-01-17 18:03:43 +01:00

24 lines
733 B
Python

# Copyright 2017 ForgeFlow
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class ResPartner(models.Model):
_inherit = "res.partner"
def _compute_rma_line_count(self):
for rec in self:
rec.rma_line_count = len(rec.rma_line_ids)
rma_line_ids = fields.One2many(
comodel_name="rma.order.line", string="RMAs", inverse_name="partner_id"
)
rma_line_count = fields.Integer(compute="_compute_rma_line_count")
def action_open_partner_rma(self):
action = self.env.ref("rma.action_rma_customer_lines")
result = action.read()[0]
result["context"] = {"search_default_partner_id": self.id}
return result