diff --git a/rma/README.rst b/rma/README.rst index 68a32563..fd8a338d 100644 --- a/rma/README.rst +++ b/rma/README.rst @@ -1,10 +1,11 @@ .. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg :alt: License LGPL-3 -RMA -=== +====================================== +RMA (Return Merchandise Authorization) +====================================== -A return merchandise authorization (RMA), is a part of the process of +A Return Merchandise Authorization (RMA), is a part of the process of returning a product in order to receive a refund, replacement, or repair during the product's warranty period. @@ -29,6 +30,7 @@ Configuration Security -------- + Go to Settings > Users and assign the appropiate permissions to users. Different security groups grant distinct levels of access to the RMA features. @@ -38,11 +40,25 @@ Different security groups grant distinct levels of access to the RMA features. * Users in group "RMA Manager" can access to, create, approve and process RMA's associated to both customers and suppliers. +RMA Approval Policy +------------------- +There are two RMA approval policies in product catogories: +* One step: Always auto-approve RMAs that only contain products within + categories with this policy. +* Two steps: A RMA order containing a product within a category with this + policy will request the RMA manager approval. + +In order to change the approval policy of a product category follow the next +steps: + +#. Go to *Inventory > Configuration > Products > Product Categories*. +#. Select one and change the field *RMA Approval Policy* to your convenience. + +Other Settings +-------------- -#. Go to Settings > Users and assign the appropiate permissions to users. - Users assigned to the group 'RMA #. Go to Inventory > Settings > Return Merchandising Authorization and select the option "Display 3 fields on rma: partner, invoice address, delivery address" if needed. @@ -51,16 +67,17 @@ Different security groups grant distinct levels of access to the RMA features. and suppliers RMA picking type. In case the warehouse is configured to use routes, you need to create at least one route per rma type with at least two push rules (one for inbound another for outbound) it's very - important to select the typeof operation supplier if we are moving in the + important to select the type of operation supplier if we are moving in the company and customer if we are moving out of the company. Usage ===== -RMA are accessible though Inventory menu. There's four menus, divided by type -. Users can access to the list of RMA or RMA lines. +RMA are accessible though Inventory menu. There's four menus, divided by type. +Users can access to the list of RMA or RMA lines. Create an RMA: + #. Select a partner. Enter RMA lines associated to an existing picking, or manually. #. Request approval and approve. @@ -87,10 +104,9 @@ Contributors * Jordi Ballester Alomar * Aaron Henriquez - +* Lois Rilo Maintainer ---------- This module is maintained by Eficent. - diff --git a/rma/__openerp__.py b/rma/__openerp__.py index 9fc1d7f8..80bc8f3f 100644 --- a/rma/__openerp__.py +++ b/rma/__openerp__.py @@ -3,7 +3,7 @@ # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) { - 'name': 'rma', + 'name': 'RMA (Return Merchandise Authorization)', 'version': '9.0.1.0.0', 'license': 'LGPL-3', 'category': 'RMA', @@ -18,19 +18,16 @@ ], 'data': ['security/rma.xml', 'security/ir.model.access.csv', - 'data/rma_sequence.xml', 'data/stock_data.xml', 'data/rma_operation.xml', 'views/rma_order_view.xml', 'views/rma_operation_view.xml', - 'views/rma_rule_view.xml', 'views/rma_order_line_view.xml', 'views/stock_view.xml', 'views/stock_warehouse.xml', 'views/product_view.xml', 'views/procurement_view.xml', - 'views/res_company_view.xml', 'wizards/rma_make_picking_view.xml', 'wizards/rma_add_stock_move_view.xml', 'wizards/stock_config_settings.xml', diff --git a/rma/data/rma_operation.xml b/rma/data/rma_operation.xml index ad39aff4..fea67f4f 100644 --- a/rma/data/rma_operation.xml +++ b/rma/data/rma_operation.xml @@ -72,10 +72,4 @@ - - Always - alw - always - - diff --git a/rma/models/__init__.py b/rma/models/__init__.py index ad034891..348fb2bf 100644 --- a/rma/models/__init__.py +++ b/rma/models/__init__.py @@ -5,9 +5,8 @@ from . import rma_order from . import rma_order_line from . import rma_operation -from . import rma_rule from . import stock from . import stock_warehouse from . import product +from . import product_category from . import procurement -from . import res_company diff --git a/rma/models/procurement.py b/rma/models/procurement.py index a55e8910..6838c5d1 100644 --- a/rma/models/procurement.py +++ b/rma/models/procurement.py @@ -16,7 +16,7 @@ class ProcurementOrder(models.Model): if procurement.rma_line_id: line = procurement.rma_line_id res['rma_line_id'] = line.id - if line.delivery_address_id and line.delivery_address_id.id: + if line.delivery_address_id: res['partner_id'] = line.delivery_address_id.id elif line.invoice_line_id.invoice_id.partner_id: res['partner_id'] = line.invoice_id.partner_id.id diff --git a/rma/models/product.py b/rma/models/product.py index 2a992b25..d7f878bc 100644 --- a/rma/models/product.py +++ b/rma/models/product.py @@ -5,15 +5,10 @@ from openerp import fields, models -class ProductCategory(models.Model): - _inherit = 'product.category' - - rma_operation_id = fields.Many2one( - comodel_name="rma.operation", string="RMA Operation") - - class ProductTemplate(models.Model): _inherit = 'product.template' rma_operation_id = fields.Many2one( comodel_name="rma.operation", string="RMA Operation") + rma_approval_policy = fields.Selection( + related="categ_id.rma_approval_policy", readonly=True) diff --git a/rma/models/product_category.py b/rma/models/product_category.py new file mode 100644 index 00000000..decfce28 --- /dev/null +++ b/rma/models/product_category.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Eficent Business and IT Consulting Services S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) + +from openerp import fields, models + + +class ProductCategory(models.Model): + _inherit = "product.category" + + rma_approval_policy = fields.Selection( + selection=[('one_step', 'One step'), ('two_step', 'Two steps')], + string="RMA Approval Policy", required=True, default='one_step', + help="Options: \n " + "* One step: Always auto-approve RMAs that only contain " + "products within categories with this policy.\n" + "* Two steps: A RMA containing a product within a category with " + "this policy will request the RMA manager approval.") + rma_operation_id = fields.Many2one( + comodel_name="rma.operation", string="RMA Operation") diff --git a/rma/models/res_company.py b/rma/models/res_company.py deleted file mode 100644 index efc8f43c..00000000 --- a/rma/models/res_company.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- 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 openerp import models, fields - - -class ResCompany(models.Model): - _inherit = 'res.company' - - rma_rule_id = fields.Many2one('rma.rule', 'Default RMA Approval Policy') diff --git a/rma/models/rma_order.py b/rma/models/rma_order.py index 9f99a636..e307b35c 100644 --- a/rma/models/rma_order.py +++ b/rma/models/rma_order.py @@ -14,12 +14,6 @@ class RmaOrder(models.Model): _name = "rma.order" _inherit = ['mail.thread'] - @api.model - def _compute_rule_id(self): - if self.company_id and self.company_id.id: - if self.company_id.rma_rule_id and self.company_id.rma_rule_id.id: - self.rule_id = self.company_id.rma_rule_id - @api.model def _get_default_type(self): if 'supplier' in self.env.context: @@ -79,8 +73,6 @@ class RmaOrder(models.Model): requested_by = fields.Many2one('res.users', 'Requested by', track_visibility='onchange', default=lambda self: self.env.user) - rule_id = fields.Many2one('rma.rule', string='Approval Criteria', - compute=_compute_rule_id) rma_line_ids = fields.One2many('rma.order.line', 'rma_id', string='RMA lines') in_shipment_count = fields.Integer(compute=_compute_in_shipment_count, @@ -163,12 +155,12 @@ class RmaOrder(models.Model): @api.multi def action_rma_to_approve(self): + self.write({'state': 'to_approve'}) for rec in self: - rec.state = 'to_approve' - if rec.rule_id and rec.rule_id.id: - if rec.rule_id.approval_policy == 'always': - rec.assigned_to = self.env.uid - rec.action_rma_approve() + pols = rec.mapped('rma_line_ids.product_id.rma_approval_policy') + if not any(x != 'one_step' for x in pols): + rec.write({'assigned_to': self.env.uid}) + rec.action_rma_approve() return True @api.multi @@ -180,8 +172,7 @@ class RmaOrder(models.Model): @api.multi def action_rma_approve(self): # pass the supplier address in case this is a customer RMA - for rec in self: - rec.state = 'approved' + self.write({'state': 'approved'}) return True @api.multi diff --git a/rma/models/rma_rule.py b/rma/models/rma_rule.py deleted file mode 100644 index ec3c9255..00000000 --- a/rma/models/rma_rule.py +++ /dev/null @@ -1,16 +0,0 @@ -# -*- 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 openerp import _, api, fields, models - - -class RmaRule(models.Model): - _name = 'rma.rule' - _description = 'RMA Approval Conditions' - - name = fields.Char('Description', required=True) - code = fields.Char('Code', required=True) - approval_policy = fields.Selection([ - ('always', 'Always')], string="Approval Policy", - required=True, default='always') diff --git a/rma/views/product_view.xml b/rma/views/product_view.xml index 74a9fd35..c14144a6 100644 --- a/rma/views/product_view.xml +++ b/rma/views/product_view.xml @@ -8,6 +8,7 @@ + @@ -20,6 +21,7 @@ + diff --git a/rma/views/res_company_view.xml b/rma/views/res_company_view.xml deleted file mode 100644 index a2f01d20..00000000 --- a/rma/views/res_company_view.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - base_phone.company.form - res.company - - - - - - - - - - - \ No newline at end of file diff --git a/rma/views/rma_rule_view.xml b/rma/views/rma_rule_view.xml deleted file mode 100644 index 788ffb6c..00000000 --- a/rma/views/rma_rule_view.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - rma.rule.tree - rma.rule - - - - - - - - - - rma.rule.form - rma.rule - -
- - - - - - - - - -
-
-
- - - Rules - rma.rule - form - tree,form - - - - - -
-