diff --git a/repair_refurbish/README.rst b/repair_refurbish/README.rst new file mode 100644 index 00000000..dcef9303 --- /dev/null +++ b/repair_refurbish/README.rst @@ -0,0 +1,102 @@ +================ +Repair Refurbish +================ + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:eeff0befa49ee907aa917391a2395e78beec94385105d04df2085f26a297d876 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Frepair-lightgray.png?logo=github + :target: https://github.com/OCA/repair/tree/18.0/repair_refurbish + :alt: OCA/repair +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/repair-18-0/repair-18-0-repair_refurbish + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/repair&target_branch=18.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module adds the ability to obtain refurbished product as a +consequence of the repair of a product that was defective. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +1. For each product that can potentially be refurbished, define the + refurbished version in the product form. +2. A default 'Refurbished' virtual location is created during module + install, and proposed by default on each product. + +Usage +===== + +1. Create a repair. +2. Indicate a product to repair, check the box *to refurbish*. If the + product has a proposed refurbished version, it will be proposed to be + used. +3. Add operations if needed. +4. Complete the repair. + +The initial product will be moved to the 'Refurbish' location, and the +refurbished product will be moved from a 'Refurbish' location to the +desired destination location. + +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 to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* ForgeFlow + +Contributors +------------ + +- Jordi Ballester Alomar +- Lois Rilo +- Akim Juillerat +- Bhavesh Odedra + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/repair `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/repair_refurbish/__init__.py b/repair_refurbish/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/repair_refurbish/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/repair_refurbish/__manifest__.py b/repair_refurbish/__manifest__.py new file mode 100644 index 00000000..efd120f1 --- /dev/null +++ b/repair_refurbish/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2020-25 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +{ + "name": "Repair Refurbish", + "summary": "Create refurbished products during repair", + "version": "18.0.1.0.0", + "category": "Manufacturing", + "website": "https://github.com/OCA/repair", + "author": "ForgeFlow, Odoo Community Association (OCA)", + "license": "AGPL-3", + "installable": True, + "depends": ["repair"], + "data": [ + "views/repair_view.xml", + "data/stock_data.xml", + "views/product_template_view.xml", + "views/product_product_view.xml", + ], +} diff --git a/repair_refurbish/data/stock_data.xml b/repair_refurbish/data/stock_data.xml new file mode 100644 index 00000000..613aeae5 --- /dev/null +++ b/repair_refurbish/data/stock_data.xml @@ -0,0 +1,9 @@ + + + + Refurbish + + production + + + diff --git a/repair_refurbish/i18n/de.po b/repair_refurbish/i18n/de.po new file mode 100644 index 00000000..c1814d54 --- /dev/null +++ b/repair_refurbish/i18n/de.po @@ -0,0 +1,118 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_refurbish +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2018-12-09 10:43+0000\n" +"Last-Translator: Maria Sparenberg \n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.3\n" + +#. module: repair_refurbish +#: model:ir.model.fields,help:repair_refurbish.field_repair_order__refurbish_tracking +msgid "Ensure the traceability of a storable product in your warehouse." +msgstr "" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_product_template +msgid "Product" +msgstr "Produkt" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: repair_refurbish +#: model_terms:ir.ui.view,arch_db:repair_refurbish.product_normal_form_view +#: model_terms:ir.ui.view,arch_db:repair_refurbish.product_template_only_form_view +msgid "Refurbish" +msgstr "Wiederaufbereiten" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_product_product__property_stock_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_product_template__property_stock_refurbish +msgid "Refurbish Location" +msgstr "Lagerort für Wiederaufbereitung" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_location_dest_id +msgid "Refurbished Delivery Location" +msgstr "Auslieferungslagerort" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_move_id +msgid "Refurbished Inventory Move" +msgstr "Lagerbewegung" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_lot_id +msgid "Refurbished Lot" +msgstr "Wiederaufbereitetes Los" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_product_product__refurbish_product_id +#: model:ir.model.fields,field_description:repair_refurbish.field_product_template__refurbish_product_id +msgid "Refurbished Product" +msgstr "Wiederaufbereitetes Produkt" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_tracking +msgid "Refurbished Product Tracking" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_product_id +msgid "Refurbished product" +msgstr "Wiederaufbereitetes Produkt" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_repair_order +msgid "Repair Order" +msgstr "Reparaturauftrag" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,help:repair_refurbish.field_product_product__property_stock_refurbish +#: model:ir.model.fields,help:repair_refurbish.field_product_template__property_stock_refurbish +msgid "" +"This stock location will be used, instead of the default one, as the source " +"location for stock moves generated by repair orders when refurbishing takes " +"place." +msgstr "" +"Dieser Lagerort wird anstatt des Standardlagerortes als Quelllager für " +"Lagerbewegungen verwendet, die durch Reparaturaufträge bei der " +"Wiederaufbereitung erzeugt werden." + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__to_refurbish +msgid "To Refurbish" +msgstr "Wiederaufbereiten" + +#, fuzzy +#~ msgid "Delivery Location" +#~ msgstr "Auslieferungslagerort" + +#, fuzzy +#~ msgid "Repair Line (parts)" +#~ msgstr "Instandsetzungslinie" + +#~ msgid "Product Template" +#~ msgstr "Produktvorlage" diff --git a/repair_refurbish/i18n/it.po b/repair_refurbish/i18n/it.po new file mode 100644 index 00000000..35d06462 --- /dev/null +++ b/repair_refurbish/i18n/it.po @@ -0,0 +1,116 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_refurbish +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2025-05-27 09:26+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.10.4\n" + +#. module: repair_refurbish +#: model:ir.model.fields,help:repair_refurbish.field_repair_order__refurbish_tracking +msgid "Ensure the traceability of a storable product in your warehouse." +msgstr "Assicura la tracciabilità di un prodotto stoccabile nel magazzino." + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_product_template +msgid "Product" +msgstr "Prodotto" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "Movimenti prodotto (riga movimento di magazzino)" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_product_product +msgid "Product Variant" +msgstr "Variante prodotto" + +#. module: repair_refurbish +#: model_terms:ir.ui.view,arch_db:repair_refurbish.product_normal_form_view +#: model_terms:ir.ui.view,arch_db:repair_refurbish.product_template_only_form_view +msgid "Refurbish" +msgstr "Ricondizionato" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_product_product__property_stock_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_product_template__property_stock_refurbish +msgid "Refurbish Location" +msgstr "Ubicazione ricondizionato" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_location_dest_id +msgid "Refurbished Delivery Location" +msgstr "Ubicazione consegna ricondizionato" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_move_id +msgid "Refurbished Inventory Move" +msgstr "Movimento di magazzino del ricondizionato" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_lot_id +msgid "Refurbished Lot" +msgstr "Lotto ricondizionato" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_product_product__refurbish_product_id +#: model:ir.model.fields,field_description:repair_refurbish.field_product_template__refurbish_product_id +msgid "Refurbished Product" +msgstr "Prodotto ricondizionato" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_tracking +msgid "Refurbished Product Tracking" +msgstr "Tracciamento prodotto ricondizionato" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_product_id +msgid "Refurbished product" +msgstr "Prodotto ricondizionato" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_repair_order +msgid "Repair Order" +msgstr "Ordine di riparazione" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_stock_move +msgid "Stock Move" +msgstr "Movimento di magazzino" + +#. module: repair_refurbish +#: model:ir.model.fields,help:repair_refurbish.field_product_product__property_stock_refurbish +#: model:ir.model.fields,help:repair_refurbish.field_product_template__property_stock_refurbish +msgid "" +"This stock location will be used, instead of the default one, as the source " +"location for stock moves generated by repair orders when refurbishing takes " +"place." +msgstr "" +"Questa ubicazione di magazzino verrà utilizzata, al posto della predefinita, " +"come ubicazione origine per i movimenti di magazzino generati da ordini di " +"riparazione con rigenerati." + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__to_refurbish +msgid "To Refurbish" +msgstr "Da ricondizionare" + +#~ msgid "Delivery Location" +#~ msgstr "Ubicazione consegna" + +#~ msgid "This is the location where the repaired product is located." +#~ msgstr "Questa è l'ubicazione dove è posizionato il prpdotto riparato." + +#~ msgid "Repair Line (parts)" +#~ msgstr "Riga riparazione (componenti)" diff --git a/repair_refurbish/i18n/mrp_repair_refurbish.pot b/repair_refurbish/i18n/mrp_repair_refurbish.pot new file mode 100644 index 00000000..7f331e05 --- /dev/null +++ b/repair_refurbish/i18n/mrp_repair_refurbish.pot @@ -0,0 +1,85 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * mrp_repair_refurbish +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: mrp_repair_refurbish +#: model:ir.model,name:mrp_repair_refurbish.model_product_product +msgid "Product" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model,name:mrp_repair_refurbish.model_product_template +msgid "Product Template" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.ui.view,arch_db:mrp_repair_refurbish.product_normal_form_view +#: model:ir.ui.view,arch_db:mrp_repair_refurbish.product_template_only_form_view +#: model:stock.location,name:mrp_repair_refurbish.stock_location_refurbish +msgid "Refurbish" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model.fields,field_description:mrp_repair_refurbish.field_product_product_property_stock_refurbish +#: model:ir.model.fields,field_description:mrp_repair_refurbish.field_product_template_property_stock_refurbish +msgid "Refurbish Location" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model.fields,field_description:mrp_repair_refurbish.field_mrp_repair_refurbish_location_dest_id +msgid "Refurbished Delivery Location" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model.fields,field_description:mrp_repair_refurbish.field_mrp_repair_refurbish_move_id +msgid "Refurbished Inventory Move" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model.fields,field_description:mrp_repair_refurbish.field_mrp_repair_refurbish_lot_id +msgid "Refurbished Lot" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model.fields,field_description:mrp_repair_refurbish.field_product_product_refurbish_product_id +#: model:ir.model.fields,field_description:mrp_repair_refurbish.field_product_template_refurbish_product_id +msgid "Refurbished Product" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model.fields,field_description:mrp_repair_refurbish.field_mrp_repair_refurbish_product_id +msgid "Refurbished product" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model,name:mrp_repair_refurbish.model_mrp_repair_line +msgid "Repair Line" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model,name:mrp_repair_refurbish.model_mrp_repair +msgid "Repair Order" +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model.fields,help:mrp_repair_refurbish.field_product_product_property_stock_refurbish +#: model:ir.model.fields,help:mrp_repair_refurbish.field_product_template_property_stock_refurbish +msgid "This stock location will be used, instead of the default one, as the source location for stock moves generated by repair orders when refurbishing takes place." +msgstr "" + +#. module: mrp_repair_refurbish +#: model:ir.model.fields,field_description:mrp_repair_refurbish.field_mrp_repair_to_refurbish +msgid "To Refurbish" +msgstr "" + diff --git a/repair_refurbish/i18n/repair_refurbish.pot b/repair_refurbish/i18n/repair_refurbish.pot new file mode 100644 index 00000000..d5e01cd2 --- /dev/null +++ b/repair_refurbish/i18n/repair_refurbish.pot @@ -0,0 +1,101 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * repair_refurbish +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: repair_refurbish +#: model:ir.model.fields,help:repair_refurbish.field_repair_order__refurbish_tracking +msgid "Ensure the traceability of a storable product in your warehouse." +msgstr "" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_product_template +msgid "Product" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_stock_move_line +msgid "Product Moves (Stock Move Line)" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: repair_refurbish +#: model_terms:ir.ui.view,arch_db:repair_refurbish.product_normal_form_view +#: model_terms:ir.ui.view,arch_db:repair_refurbish.product_template_only_form_view +msgid "Refurbish" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_product_product__property_stock_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_product_template__property_stock_refurbish +msgid "Refurbish Location" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_location_dest_id +msgid "Refurbished Delivery Location" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_move_id +msgid "Refurbished Inventory Move" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_lot_id +msgid "Refurbished Lot" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_product_product__refurbish_product_id +#: model:ir.model.fields,field_description:repair_refurbish.field_product_template__refurbish_product_id +msgid "Refurbished Product" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_tracking +msgid "Refurbished Product Tracking" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__refurbish_product_id +msgid "Refurbished product" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_repair_order +msgid "Repair Order" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model,name:repair_refurbish.model_stock_move +msgid "Stock Move" +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,help:repair_refurbish.field_product_product__property_stock_refurbish +#: model:ir.model.fields,help:repair_refurbish.field_product_template__property_stock_refurbish +msgid "" +"This stock location will be used, instead of the default one, as the source " +"location for stock moves generated by repair orders when refurbishing takes " +"place." +msgstr "" + +#. module: repair_refurbish +#: model:ir.model.fields,field_description:repair_refurbish.field_repair_order__to_refurbish +msgid "To Refurbish" +msgstr "" diff --git a/repair_refurbish/models/__init__.py b/repair_refurbish/models/__init__.py new file mode 100644 index 00000000..a9873dfe --- /dev/null +++ b/repair_refurbish/models/__init__.py @@ -0,0 +1,5 @@ +from . import product_product +from . import product_template +from . import repair +from . import stock_move +from . import stock_move_line diff --git a/repair_refurbish/models/product_product.py b/repair_refurbish/models/product_product.py new file mode 100644 index 00000000..7b138dc4 --- /dev/null +++ b/repair_refurbish/models/product_product.py @@ -0,0 +1,14 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models + + +class ProductProduct(models.Model): + _inherit = "product.product" + + refurbish_product_id = fields.Many2one( + comodel_name="product.product", + string="Refurbished Product", + domain="[('type', '=', 'consu')]", + ) diff --git a/repair_refurbish/models/product_template.py b/repair_refurbish/models/product_template.py new file mode 100644 index 00000000..8e361d9e --- /dev/null +++ b/repair_refurbish/models/product_template.py @@ -0,0 +1,49 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + refurbish_product_id = fields.Many2one( + comodel_name="product.product", + string="Refurbished Product", + compute="_compute_refurbish_product", + inverse="_inverse_refurbish_product", + search="_search_refurbish_product", + domain="[('type', '=', 'consu')]", + ) + + property_stock_refurbish = fields.Many2one( + comodel_name="stock.location", + string="Refurbish Location", + company_dependent=True, + domain=[("usage", "like", "production")], + help="This stock location will be used, instead of the " + "default one, as the source location for " + "stock moves generated by repair orders when refurbishing takes " + "place.", + ) + + @api.depends("product_variant_ids", "product_variant_ids.refurbish_product_id") + def _compute_refurbish_product(self): + unique_variants = self.filtered( + lambda template: len(template.product_variant_ids) == 1 + ) + for template in unique_variants: + template.refurbish_product_id = ( + template.product_variant_ids.refurbish_product_id + ) + + def _inverse_refurbish_product(self): + for rec in self: + if len(rec.product_variant_ids) == 1: + rec.product_variant_ids.refurbish_product_id = rec.refurbish_product_id + + def _search_refurbish_product(self, operator, value): + products = self.env["product.product"].search( + [("refurbish_product_id", operator, value)], limit=None + ) + return [("id", "in", products.mapped("product_tmpl_id").ids)] diff --git a/repair_refurbish/models/repair.py b/repair_refurbish/models/repair.py new file mode 100644 index 00000000..e835f22d --- /dev/null +++ b/repair_refurbish/models/repair.py @@ -0,0 +1,94 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import Command, api, fields, models + + +class RepairOrder(models.Model): + _inherit = "repair.order" + + to_refurbish = fields.Boolean() + refurbish_location_dest_id = fields.Many2one( + string="Refurbished Delivery Location", comodel_name="stock.location" + ) + refurbish_product_id = fields.Many2one( + string="Refurbished Product", comodel_name="product.product" + ) + refurbish_tracking = fields.Selection( + string="Refurbished Product Tracking", + related="refurbish_product_id.tracking", + readonly=False, + ) + refurbish_lot_id = fields.Many2one( + string="Refurbished Lot", comodel_name="stock.lot" + ) + refurbish_move_id = fields.Many2one( + string="Refurbished Inventory Move", comodel_name="stock.move" + ) + + @api.onchange("to_refurbish", "product_id") + def _onchange_to_refurbish(self): + if self.to_refurbish: + self.refurbish_product_id = self.product_id.refurbish_product_id + self.refurbish_location_dest_id = self.location_id + else: + self.refurbish_product_id = False + self.refurbish_location_dest_id = False + + def _get_virtual_refurbish_location(self): + self.ensure_one() + if self.product_id.property_stock_refurbish: + return self.product_id.property_stock_refurbish + return self.env.ref("repair_refurbish.stock_location_refurbish") + + def _get_refurbish_stock_move_dict(self): + refurbish_loc = self._get_virtual_refurbish_location() + return { + "name": self.name, + "product_id": self.refurbish_product_id.id, + "product_uom": self.product_uom.id or self.refurbish_product_id.uom_id.id, + "product_uom_qty": self.product_qty, + "partner_id": self.partner_id and self.partner_id.id or False, + "location_id": refurbish_loc.id, + "repair_id": self.id, + "location_dest_id": self.refurbish_location_dest_id.id, + "move_line_ids": [ + Command.create( + { + "product_id": self.refurbish_product_id.id, + "lot_id": self.refurbish_lot_id.id, + "quantity_product_uom": self.product_qty, + "product_uom_id": self.product_uom.id + or self.refurbish_product_id.uom_id.id, + "quantity": self.product_qty, + "package_id": False, + "result_package_id": False, + "location_id": refurbish_loc.id, + "location_dest_id": self.refurbish_location_dest_id.id, + }, + ) + ], + } + + def action_repair_done(self): + to_refurbish_orders = self.filtered("to_refurbish") + res = super(RepairOrder, (self - to_refurbish_orders)).action_repair_done() + for repair in to_refurbish_orders: + refurbish_loc = self._get_virtual_refurbish_location() + super( + RepairOrder, + repair.with_context( + force_refurbish_location_dest_id=refurbish_loc.id, + to_refurbish=repair.to_refurbish, + ), + ).action_repair_done() + if repair.to_refurbish: + move = self.env["stock.move"].create( + repair._get_refurbish_stock_move_dict() + ) + move._action_confirm() + move.quantity = repair.product_qty + move.picked = True + move._action_done() + repair.refurbish_move_id = move.id + return res diff --git a/repair_refurbish/models/stock_move.py b/repair_refurbish/models/stock_move.py new file mode 100644 index 00000000..56932ba0 --- /dev/null +++ b/repair_refurbish/models/stock_move.py @@ -0,0 +1,17 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, models + + +class StockMove(models.Model): + _inherit = "stock.move" + + @api.model_create_multi + def create(self, vals_list): + if self.env.context.get("to_refurbish"): + if "force_refurbish_location_dest_id" in self.env.context: + for vals in vals_list: + vals["location_dest_id"] = self.env.context[ + "force_refurbish_location_dest_id" + ] + return super().create(vals_list) diff --git a/repair_refurbish/models/stock_move_line.py b/repair_refurbish/models/stock_move_line.py new file mode 100644 index 00000000..e9d697dc --- /dev/null +++ b/repair_refurbish/models/stock_move_line.py @@ -0,0 +1,17 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from odoo import api, models + + +class StockMoveLine(models.Model): + _inherit = "stock.move.line" + + @api.model_create_multi + def create(self, vals_list): + if "to_refurbish" in self.env.context and self.env.context["to_refurbish"]: + if "force_refurbish_location_dest_id" in self.env.context: + for vals in vals_list: + vals["location_dest_id"] = self.env.context[ + "force_refurbish_location_dest_id" + ] + return super().create(vals_list) diff --git a/repair_refurbish/pyproject.toml b/repair_refurbish/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/repair_refurbish/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/repair_refurbish/readme/CONFIGURE.md b/repair_refurbish/readme/CONFIGURE.md new file mode 100644 index 00000000..8477a399 --- /dev/null +++ b/repair_refurbish/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +1. For each product that can potentially be refurbished, define the + refurbished version in the product form. +2. A default 'Refurbished' virtual location is created during module + install, and proposed by default on each product. diff --git a/repair_refurbish/readme/CONTRIBUTORS.md b/repair_refurbish/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..4199f29c --- /dev/null +++ b/repair_refurbish/readme/CONTRIBUTORS.md @@ -0,0 +1,4 @@ +- Jordi Ballester Alomar \<\> +- Lois Rilo \<\> +- Akim Juillerat \<\> +- Bhavesh Odedra \<\> diff --git a/repair_refurbish/readme/DESCRIPTION.md b/repair_refurbish/readme/DESCRIPTION.md new file mode 100644 index 00000000..d63d3f51 --- /dev/null +++ b/repair_refurbish/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module adds the ability to obtain refurbished product as a +consequence of the repair of a product that was defective. diff --git a/repair_refurbish/readme/USAGE.md b/repair_refurbish/readme/USAGE.md new file mode 100644 index 00000000..e5dfecba --- /dev/null +++ b/repair_refurbish/readme/USAGE.md @@ -0,0 +1,10 @@ +1. Create a repair. +2. Indicate a product to repair, check the box *to refurbish*. + If the product has a proposed refurbished version, it will be proposed + to be used. +3. Add operations if needed. +4. Complete the repair. + +The initial product will be moved to the 'Refurbish' location, and the +refurbished product will be moved from a 'Refurbish' location to the +desired destination location. diff --git a/repair_refurbish/static/description/icon.png b/repair_refurbish/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/repair_refurbish/static/description/icon.png differ diff --git a/repair_refurbish/static/description/index.html b/repair_refurbish/static/description/index.html new file mode 100644 index 00000000..b9516c56 --- /dev/null +++ b/repair_refurbish/static/description/index.html @@ -0,0 +1,452 @@ + + + + + +Repair Refurbish + + + +
+

Repair Refurbish

+ + +

Beta License: AGPL-3 OCA/repair Translate me on Weblate Try me on Runboat

+

This module adds the ability to obtain refurbished product as a +consequence of the repair of a product that was defective.

+

Table of contents

+ +
+

Configuration

+
    +
  1. For each product that can potentially be refurbished, define the +refurbished version in the product form.
  2. +
  3. A default ‘Refurbished’ virtual location is created during module +install, and proposed by default on each product.
  4. +
+
+
+

Usage

+
    +
  1. Create a repair.
  2. +
  3. Indicate a product to repair, check the box to refurbish. If the +product has a proposed refurbished version, it will be proposed to be +used.
  4. +
  5. Add operations if needed.
  6. +
  7. Complete the repair.
  8. +
+

The initial product will be moved to the ‘Refurbish’ location, and the +refurbished product will be moved from a ‘Refurbish’ location to the +desired destination location.

+
+
+

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 to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/repair project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/repair_refurbish/tests/__init__.py b/repair_refurbish/tests/__init__.py new file mode 100644 index 00000000..4e9f9ec0 --- /dev/null +++ b/repair_refurbish/tests/__init__.py @@ -0,0 +1 @@ +from . import test_repair_refurbish diff --git a/repair_refurbish/tests/test_repair_refurbish.py b/repair_refurbish/tests/test_repair_refurbish.py new file mode 100644 index 00000000..45242ff2 --- /dev/null +++ b/repair_refurbish/tests/test_repair_refurbish.py @@ -0,0 +1,140 @@ +# Copyright 2020 ForgeFlow S.L. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import Command +from odoo.tests.common import TransactionCase + + +class TestMrpMtoWithStock(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.repair_obj = cls.env["repair.order"] + cls.product_obj = cls.env["product.product"] + cls.move_obj = cls.env["stock.move"] + + cls.warehouse = cls.env.ref("stock.warehouse0") + cls.stock_location_stock = cls.env.ref("stock.stock_location_stock") + cls.customer_location = cls.env.ref("stock.stock_location_customers") + cls.refurbish_loc = cls.env.ref("repair_refurbish.stock_location_refurbish") + + cls.refurbish_product = cls.product_obj.create( + {"name": "Refurbished Awesome Screen", "type": "consu", "is_storable": True} + ) + cls.product = cls.product_obj.create( + { + "name": "Awesome Screen", + "type": "consu", + "refurbish_product_id": cls.refurbish_product.id, + "is_storable": True, + } + ) + cls.material = cls.product_obj.create( + {"name": "Materials", "type": "consu", "is_storable": True} + ) + cls.material2 = cls.product_obj.create( + {"name": "Materials", "type": "consu", "is_storable": True} + ) + cls._update_product_qty(cls, cls.product, cls.stock_location_stock, 10.0) + cls._update_product_qty(cls, cls.material2, cls.stock_location_stock, 10.0) + + def _update_product_qty(self, product, location, quantity): + self.env["stock.quant"].create( + { + "location_id": location.id, + "product_id": product.id, + "inventory_quantity": quantity, + } + ).action_apply_inventory() + return quantity + + def test_01_repair_refurbish(self): + """Tests that locations are properly set with a product to + refurbish, then complete repair.""" + repair = self.repair_obj.create( + { + "product_id": self.product.id, + "product_qty": 3.0, + "product_uom": self.product.uom_id.id, + "picking_type_id": self.warehouse.repair_type_id.id, + } + ) + self.assertFalse(repair.to_refurbish) + repair.to_refurbish = True + repair._onchange_to_refurbish() + self.assertEqual(repair.location_id, self.stock_location_stock) + self.assertEqual(repair.refurbish_location_dest_id, self.stock_location_stock) + + # Complete repair: + repair.action_validate() + repair.action_repair_start() + repair.action_repair_end() + moves = self.move_obj.search([("repair_id", "=", repair.id)]) + self.assertEqual(len(moves), 2) + for m in moves: + self.assertEqual(m.state, "done") + if m.product_id == self.product: + self.assertEqual(m.location_id, self.stock_location_stock) + self.assertEqual(m.location_dest_id, self.refurbish_loc) + self.assertEqual( + m.mapped("move_line_ids.location_id"), self.stock_location_stock + ) + self.assertEqual( + m.mapped("move_line_ids.location_dest_id"), self.refurbish_loc + ) + elif m.product_id == self.refurbish_product: + self.assertEqual(m.location_id, self.refurbish_loc) + self.assertEqual(m.location_dest_id, self.stock_location_stock) + self.assertEqual( + m.mapped("move_line_ids.location_id"), self.refurbish_loc + ) + self.assertEqual( + m.mapped("move_line_ids.location_dest_id"), + self.stock_location_stock, + ) + else: + self.assertTrue(False, "Unexpected move.") + + def test_02_repair_no_refurbish(self): + """Tests normal repairs does not fail and normal location for consumed + material""" + repair = self.repair_obj.create( + { + "product_id": self.product.id, + "product_qty": 3.0, + "product_uom": self.product.uom_id.id, + "picking_type_id": self.warehouse.repair_type_id.id, + "to_refurbish": False, + "move_ids": [ + Command.create( + { + "product_id": self.material2.id, + "product_uom_qty": 1.0, + "state": "draft", + "repair_line_type": "add", + "location_id": self.stock_location_stock.id, + }, + ) + ], + } + ) + + # Complete repair: + repair.action_validate() + repair.action_repair_start() + # Component + move = self.move_obj.search( + [("product_id", "=", self.material2.id), ("repair_id", "=", repair.id)], + ) + self.assertEqual(len(move), 1) + self.assertEqual(move.location_dest_id.name, repair.location_dest_id.name) + move.move_line_ids.picked = True + # Repaired product: + res = repair.action_repair_end() + self.assertFalse(isinstance(res, dict), "action_repair_end has failed") + repaired_move = self.move_obj.search( + [("product_id", "=", self.product.id), ("repair_id", "=", repair.id)], + ) + self.assertEqual(len(repaired_move), 1) + self.assertEqual(repaired_move.location_id, self.stock_location_stock) + self.assertEqual(repaired_move.location_dest_id, self.stock_location_stock) diff --git a/repair_refurbish/views/product_product_view.xml b/repair_refurbish/views/product_product_view.xml new file mode 100644 index 00000000..8565366f --- /dev/null +++ b/repair_refurbish/views/product_product_view.xml @@ -0,0 +1,15 @@ + + + + product.product.form + product.product + + + + + + + + + + diff --git a/repair_refurbish/views/product_template_view.xml b/repair_refurbish/views/product_template_view.xml new file mode 100644 index 00000000..18c09efa --- /dev/null +++ b/repair_refurbish/views/product_template_view.xml @@ -0,0 +1,32 @@ + + + + product.template.product.form + product.template + + + + + + + + + + + product.template.stock.property.form.inherit + product.template + + + + + + + + diff --git a/repair_refurbish/views/repair_view.xml b/repair_refurbish/views/repair_view.xml new file mode 100644 index 00000000..f943eafb --- /dev/null +++ b/repair_refurbish/views/repair_view.xml @@ -0,0 +1,80 @@ + + + + repair.order.tree + repair.order + + + + + + + + + + repair.order.form + repair.order + + + + + + + + + + + + + + + + + + {'default_repair_id': id, 'default_product_uom_qty': 1, + 'default_company_id': company_id, 'default_date': schedule_date, + 'default_repair_line_type': 'add','to_refurbish': to_refurbish} + + + + + + repair.order.select.inherit.refurbish + repair.order + + + + + + + + + +