diff --git a/rma/__openerp__.py b/rma/__openerp__.py index c4e25162..574a2858 100644 --- a/rma/__openerp__.py +++ b/rma/__openerp__.py @@ -26,6 +26,7 @@ 'views/stock_warehouse.xml', 'views/product_view.xml', 'views/procurement_view.xml', + 'views/res_partner_view.xml', 'wizards/rma_make_picking_view.xml', 'wizards/rma_add_stock_move_view.xml', 'wizards/stock_config_settings.xml', diff --git a/rma/models/__init__.py b/rma/models/__init__.py index 348fb2bf..06c86f1e 100644 --- a/rma/models/__init__.py +++ b/rma/models/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -# © 2017 Eficent Business and IT Consulting Services S.L. # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) from . import rma_order @@ -10,3 +9,4 @@ from . import stock_warehouse from . import product from . import product_category from . import procurement +from . import res_partner diff --git a/rma/models/res_partner.py b/rma/models/res_partner.py new file mode 100644 index 00000000..1ce4885f --- /dev/null +++ b/rma/models/res_partner.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from openerp import api, fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + @api.multi + 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") + + @api.multi + 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 diff --git a/rma/views/res_partner_view.xml b/rma/views/res_partner_view.xml new file mode 100644 index 00000000..97ec12b7 --- /dev/null +++ b/rma/views/res_partner_view.xml @@ -0,0 +1,23 @@ + + + + + res.partner.form - rma + res.partner + + +
+ +
+
+
+ +