diff --git a/rma_repair/__manifest__.py b/rma_repair/__manifest__.py index fdc8ad43..c3f288cb 100644 --- a/rma_repair/__manifest__.py +++ b/rma_repair/__manifest__.py @@ -2,13 +2,13 @@ # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "RMA Repair", - "version": "15.0.1.0.0", + "version": "15.0.2.0.0", "license": "AGPL-3", "category": "RMA", "summary": "Links RMA with Repairs.", "author": "ForgeFlow", "website": "https://github.com/ForgeFlow/stock-rma", - "depends": ["rma_account", "repair_refurbish"], + "depends": ["rma_account", "repair"], "data": [ "security/ir.model.access.csv", "views/rma_order_view.xml", diff --git a/rma_repair/models/rma_operation.py b/rma_repair/models/rma_operation.py index 4c62ef20..c24d5345 100644 --- a/rma_repair/models/rma_operation.py +++ b/rma_repair/models/rma_operation.py @@ -24,11 +24,6 @@ class RmaOperation(models.Model): comodel_name="stock.location", help="Indicate here the source location of the product to be repaired", ) - repair_location_dest_id = fields.Many2one( - string="Repair Destination Location", - comodel_name="stock.location", - help="Indicate here the destination location of the repair", - ) repair_invoice_method = fields.Selection( selection=[ ("none", "No Invoice"), diff --git a/rma_repair/views/rma_operation_view.xml b/rma_repair/views/rma_operation_view.xml index 8c3ab9ed..10e29203 100644 --- a/rma_repair/views/rma_operation_view.xml +++ b/rma_repair/views/rma_operation_view.xml @@ -20,7 +20,6 @@ - diff --git a/rma_repair/wizards/rma_order_line_make_repair.py b/rma_repair/wizards/rma_order_line_make_repair.py index 17300779..26176052 100644 --- a/rma_repair/wizards/rma_order_line_make_repair.py +++ b/rma_repair/wizards/rma_order_line_make_repair.py @@ -17,11 +17,6 @@ class RmaLineMakeRepair(models.TransientModel): @api.model def _prepare_item(self, line): - if line.product_id.refurbish_product_id: - to_refurbish = True - refurbish_product_id = line.product_id.refurbish_product_id.id - else: - to_refurbish = refurbish_product_id = False return { "line_id": line.id, "product_id": line.product_id.id, @@ -30,12 +25,8 @@ class RmaLineMakeRepair(models.TransientModel): "out_route_id": line.out_route_id.id, "product_uom_id": line.uom_id.id, "partner_id": line.partner_id.id, - "to_refurbish": to_refurbish, - "refurbish_product_id": refurbish_product_id, "location_id": line.operation_id.repair_location_id.id or line.location_id.id, - "location_dest_id": line.operation_id.repair_location_dest_id.id - or line.location_id.id, "invoice_method": line.operation_id.repair_invoice_method or "after_repair", } @@ -86,13 +77,6 @@ class RmaLineMakeRepairItem(models.TransientModel): if rec.product_qty <= 0.0: raise ValidationError(_("Quantity must be positive.")) - @api.onchange("to_refurbish") - def _onchange_to_refurbish(self): - if self.to_refurbish: - self.refurbish_product_id = self.product_id.refurbish_product_id - else: - self.refurbish_product_id = False - wiz_id = fields.Many2one( comodel_name="rma.order.line.make.repair", string="Wizard", ondelete="cascade" ) @@ -124,13 +108,6 @@ class RmaLineMakeRepairItem(models.TransientModel): location_id = fields.Many2one( comodel_name="stock.location", string="Location", required=True ) - location_dest_id = fields.Many2one( - comodel_name="stock.location", string="Destination location", required=True - ) - to_refurbish = fields.Boolean(string="To Refurbish?") - refurbish_product_id = fields.Many2one( - comodel_name="product.product", string="Refurbished Product" - ) invoice_method = fields.Selection( selection=[ ("none", "No Invoice"), @@ -146,14 +123,6 @@ class RmaLineMakeRepairItem(models.TransientModel): def _prepare_repair_order(self, rma_line): self.ensure_one() - location_dest = ( - self.location_dest_id - if not self.to_refurbish - else rma_line.product_id.property_stock_refurbish - ) - refurbish_location_dest_id = ( - self.location_dest_id.id if self.to_refurbish else False - ) addr = rma_line.partner_id.address_get(["delivery", "invoice"]) return { "product_id": rma_line.product_id.id, @@ -164,10 +133,6 @@ class RmaLineMakeRepairItem(models.TransientModel): "product_uom": rma_line.product_id.uom_po_id.id, "company_id": rma_line.company_id.id, "location_id": self.location_id.id, - "location_dest_id": location_dest.id, - "refurbish_location_dest_id": refurbish_location_dest_id, - "refurbish_product_id": self.refurbish_product_id.id, - "to_refurbish": self.to_refurbish, "invoice_method": self.invoice_method, "address_id": addr["delivery"], "partner_invoice_id": addr["invoice"], diff --git a/rma_repair/wizards/rma_order_line_make_repair_view.xml b/rma_repair/wizards/rma_order_line_make_repair_view.xml index 0c9b8bf0..ca619669 100644 --- a/rma_repair/wizards/rma_order_line_make_repair_view.xml +++ b/rma_repair/wizards/rma_order_line_make_repair_view.xml @@ -17,18 +17,9 @@ - - - diff --git a/rma_repair_refurbish/README.rst b/rma_repair_refurbish/README.rst new file mode 100644 index 00000000..08f5bf83 --- /dev/null +++ b/rma_repair_refurbish/README.rst @@ -0,0 +1,49 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License AGPL-3 + +========== +RMA Repair +========== + +This module allows you to create repairs from one or more RMA lines. + +Installation +============ + +This module depends on ``repair_refurbish`` which is available at +`OCA/manufacture `_. + +Usage +===== + +To create repairs from RMA lines: + +#. Go to an approved RMA. +#. Click on *Create Repair Order*. +#. Fill the required information in the lines. +#. Hit *Create Repair Orders*. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. + +Credits +======= + +Contributors +------------ + +* Jordi Ballester Alomar +* Aaron Henriquez +* Lois Rilo +* Akim Juillerat +* Bhavesh Odedra + +Maintainer +---------- + +This module is maintained by ForgeFlow. diff --git a/rma_repair_refurbish/__init__.py b/rma_repair_refurbish/__init__.py new file mode 100644 index 00000000..aee8895e --- /dev/null +++ b/rma_repair_refurbish/__init__.py @@ -0,0 +1,2 @@ +from . import models +from . import wizards diff --git a/rma_repair_refurbish/__manifest__.py b/rma_repair_refurbish/__manifest__.py new file mode 100644 index 00000000..a0ed216f --- /dev/null +++ b/rma_repair_refurbish/__manifest__.py @@ -0,0 +1,17 @@ +# Copyright 2020-22 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "RMA Repair Refurbish", + "version": "15.0.1.0.0", + "license": "AGPL-3", + "category": "RMA", + "summary": "Links RMA with Repairs and Refurbish.", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "website": "https://github.com/ForgeFlow/stock-rma", + "depends": ["rma_repair", "repair_refurbish"], + "data": [ + "wizards/rma_order_line_make_repair_view.xml", + ], + "installable": True, + "auto_install": True, +} diff --git a/rma_repair_refurbish/models/__init__.py b/rma_repair_refurbish/models/__init__.py new file mode 100644 index 00000000..9fd5ac20 --- /dev/null +++ b/rma_repair_refurbish/models/__init__.py @@ -0,0 +1 @@ +from . import rma_operation diff --git a/rma_repair_refurbish/models/rma_operation.py b/rma_repair_refurbish/models/rma_operation.py new file mode 100644 index 00000000..60584270 --- /dev/null +++ b/rma_repair_refurbish/models/rma_operation.py @@ -0,0 +1,14 @@ +# Copyright 2020-22 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class RmaOperation(models.Model): + _inherit = "rma.operation" + + repair_location_dest_id = fields.Many2one( + string="Repair Destination Location", + comodel_name="stock.location", + help="Indicate here the destination location of the repair", + ) diff --git a/rma_repair_refurbish/wizards/__init__.py b/rma_repair_refurbish/wizards/__init__.py new file mode 100644 index 00000000..cad4c62a --- /dev/null +++ b/rma_repair_refurbish/wizards/__init__.py @@ -0,0 +1,4 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from . import rma_order_line_make_repair diff --git a/rma_repair_refurbish/wizards/rma_order_line_make_repair.py b/rma_repair_refurbish/wizards/rma_order_line_make_repair.py new file mode 100644 index 00000000..23398f70 --- /dev/null +++ b/rma_repair_refurbish/wizards/rma_order_line_make_repair.py @@ -0,0 +1,58 @@ +# Copyright 2020-22 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class RmaLineMakeRepair(models.TransientModel): + _inherit = "rma.order.line.make.repair" + + @api.model + def _prepare_item(self, line): + res = super(RmaLineMakeRepair, self)._prepare_item(line) + if line.product_id.refurbish_product_id: + to_refurbish = True + refurbish_product_id = line.product_id.refurbish_product_id.id + else: + to_refurbish = refurbish_product_id = False + res["to_refurbish"] = to_refurbish + if refurbish_product_id: + res["refurbish_product_id"] = refurbish_product_id + res["location_dest_id"] = ( + line.operation_id.repair_location_dest_id.id or line.location_id.id + ) + return res + + +class RmaLineMakeRepairItem(models.TransientModel): + _inherit = "rma.order.line.make.repair.item" + + @api.onchange("to_refurbish") + def _onchange_to_refurbish(self): + if self.to_refurbish: + self.refurbish_product_id = self.product_id.refurbish_product_id + else: + self.refurbish_product_id = False + + location_dest_id = fields.Many2one( + comodel_name="stock.location", string="Destination location", required=True + ) + to_refurbish = fields.Boolean(string="To Refurbish?") + refurbish_product_id = fields.Many2one( + comodel_name="product.product", string="Refurbished Product" + ) + + def _prepare_repair_order(self, rma_line): + res = super(RmaLineMakeRepairItem, self)._prepare_repair_order(rma_line) + location_dest = ( + self.location_dest_id + if not self.to_refurbish + else rma_line.product_id.property_stock_refurbish + ) + refurbish_location_dest_id = ( + self.location_dest_id.id if self.to_refurbish else False + ) + res["location_dest_id"] = location_dest.id + res["refurbish_location_dest_id"] = refurbish_location_dest_id + res["to_refurbish"] = self.to_refurbish + return res diff --git a/rma_repair_refurbish/wizards/rma_order_line_make_repair_view.xml b/rma_repair_refurbish/wizards/rma_order_line_make_repair_view.xml new file mode 100644 index 00000000..27ee73b8 --- /dev/null +++ b/rma_repair_refurbish/wizards/rma_order_line_make_repair_view.xml @@ -0,0 +1,24 @@ + + + + + RMA Line Make Repair - Refurbish + rma.order.line.make.repair + + + + + + + + + + + + diff --git a/setup/rma_repair_refurbish/odoo/addons/rma_repair_refurbish b/setup/rma_repair_refurbish/odoo/addons/rma_repair_refurbish new file mode 120000 index 00000000..2c09c6b6 --- /dev/null +++ b/setup/rma_repair_refurbish/odoo/addons/rma_repair_refurbish @@ -0,0 +1 @@ +../../../../rma_repair_refurbish \ No newline at end of file diff --git a/setup/rma_repair_refurbish/setup.py b/setup/rma_repair_refurbish/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/rma_repair_refurbish/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)