diff --git a/rma_kanban_stage/README.rst b/rma_kanban_stage/README.rst new file mode 100644 index 000000000..8bd5d8463 --- /dev/null +++ b/rma_kanban_stage/README.rst @@ -0,0 +1,59 @@ +.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 + +========== +RMA Kanban +========== + +Currently RMA just provides a status for Draft/open/paid status which is not +enough to follow the full administrative process. + +This administrative process can be sometimes quite complex with workflow that +might be different by customers. + +Some are usual stages: + +* RMA receiving +* RMA quoting +* RMA refunding +* RMA repairing +* Any custom stage + +Configuration +============= +Stage are set up in the Settings Menu of Odoo application (after switching to +Developer Mode): + +#. go to Settings > Technical > Kanban > Stages. +#. Create a new stage + +Usage +===== +#. Go to Invoicing menu --> Customers --> Customer rmas +#. Enjoy the new kanban view +#. Drag and drop the rmas from stage to stage +#. In the form view, click on any new stage to change it + +Roadmap / Known Issues +====================== + +* rma stages and status are currently not synchronized: this is so since + every organization might have different needs and stages. Nevertheless, they + can be easily sync'ed (at least from status to Stages) via server actions. + + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/rma_kanban_stage/__init__.py b/rma_kanban_stage/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/rma_kanban_stage/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/rma_kanban_stage/__manifest__.py b/rma_kanban_stage/__manifest__.py new file mode 100644 index 000000000..705a3b34a --- /dev/null +++ b/rma_kanban_stage/__manifest__.py @@ -0,0 +1,19 @@ +# Copyright 2019-23 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) +{ + "name": "RMA Kanban Stages", + "summary": "Stages on RMA", + "version": "16.0.1.0.0", + "website": "https://github.com/ForgeFlow/stock-rma", + "author": "ForgeFlow", + "depends": [ + "rma", + "base_kanban_stage", + ], + "data": [ + "data/rma_kanban_stage.xml", + "views/rma_order_line_view.xml", + ], + "license": "AGPL-3", + "installable": True, +} diff --git a/rma_kanban_stage/data/rma_kanban_stage.xml b/rma_kanban_stage/data/rma_kanban_stage.xml new file mode 100644 index 000000000..3eeebff07 --- /dev/null +++ b/rma_kanban_stage/data/rma_kanban_stage.xml @@ -0,0 +1,28 @@ + + + + New + + + + + Confirmed + + + + + Under Repair + + + + + Repaired + + + + + Scrapped + + + + diff --git a/rma_kanban_stage/models/__init__.py b/rma_kanban_stage/models/__init__.py new file mode 100644 index 000000000..0ec42a97c --- /dev/null +++ b/rma_kanban_stage/models/__init__.py @@ -0,0 +1 @@ +from . import rma_order_line diff --git a/rma_kanban_stage/models/rma_order_line.py b/rma_kanban_stage/models/rma_order_line.py new file mode 100644 index 000000000..80dadc2ae --- /dev/null +++ b/rma_kanban_stage/models/rma_order_line.py @@ -0,0 +1,33 @@ +# Copyright 2019-23 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) +from odoo import api, fields, models + + +class RmaOrderLine(models.Model): + _name = "rma.order.line" + _inherit = ["rma.order.line", "base.kanban.abstract"] + + user_id = fields.Many2one(comodel_name="res.users", related="assigned_to") + kanban_color = fields.Integer( + compute="_compute_color", + string="Base - Background Color", + help="Default color for the background.", + ) + + def copy(self, default=None): + self.ensure_one() + default = default or {} + stage = self.stage_id.search([], order="sequence asc", limit=1) + default.update({"stage_id": stage.id}) + return super(RmaOrderLine, self).copy(default=default) + + @api.depends("state") + def _compute_color(self): + for rec in self.filtered(lambda l: l.state == "draft"): + rec.kanban_color = 1 + for rec in self.filtered(lambda l: l.state == "approved"): + rec.kanban_color = 2 + for rec in self.filtered(lambda l: l.state == "to_approve"): + rec.kanban_color = 5 + for rec in self.filtered(lambda l: l.state == "done"): + rec.kanban_color = 7 diff --git a/rma_kanban_stage/tests/__init__.py b/rma_kanban_stage/tests/__init__.py new file mode 100644 index 000000000..d4ecb9556 --- /dev/null +++ b/rma_kanban_stage/tests/__init__.py @@ -0,0 +1 @@ +from . import test_rma_kanban diff --git a/rma_kanban_stage/tests/test_rma_kanban.py b/rma_kanban_stage/tests/test_rma_kanban.py new file mode 100644 index 000000000..19240e5c9 --- /dev/null +++ b/rma_kanban_stage/tests/test_rma_kanban.py @@ -0,0 +1,32 @@ +# Copyright 2019-23 ForgeFlow S.L. +# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html) +from odoo.tests import common + + +class TestRmaKanban(common.TransactionCase): + def setUp(self): + super(TestRmaKanban, self).setUp() + + self.rma_obj = self.env["rma.order"] + self.partner_obj = self.env["res.partner"] + self.rma_line_obj = self.env["rma.order.line"] + self.kanban_stage_model = self.env["base.kanban.stage"] + + # Create partners + customer1 = self.partner_obj.create({"name": "Customer 1"}) + # Create RMA group and operation: + self.rma_group_customer = self.rma_obj.create( + { + "partner_id": customer1.id, + "type": "customer", + } + ) + + def test_read_group_stage_ids(self): + self.assertEqual( + self.rma_line_obj._read_group_stage_ids(self.kanban_stage_model, [], "id"), + self.kanban_stage_model.search([], order="id"), + ) + + def test_copy_method(self): + self.rma_group_customer.copy() diff --git a/rma_kanban_stage/views/rma_order_line_view.xml b/rma_kanban_stage/views/rma_order_line_view.xml new file mode 100644 index 000000000..67e778c2f --- /dev/null +++ b/rma_kanban_stage/views/rma_order_line_view.xml @@ -0,0 +1,75 @@ + + + + + + rma.order.line.kanban + rma.order.line + + primary + + + + + + Partner: + + + + Origin: + + oe_kanban_text_red + + Date: + + + + Product: + + QTY: + + + + Operation - + + + + + + + + rma.order.line.select + rma.order.line + + + + + + + + + + + + kanban,tree,form + + + + + kanban,tree,form + + + + diff --git a/setup/rma_kanban_stage/odoo/addons/rma_kanban_stage b/setup/rma_kanban_stage/odoo/addons/rma_kanban_stage new file mode 120000 index 000000000..d116c5ae9 --- /dev/null +++ b/setup/rma_kanban_stage/odoo/addons/rma_kanban_stage @@ -0,0 +1 @@ +../../../../rma_kanban_stage \ No newline at end of file diff --git a/setup/rma_kanban_stage/setup.py b/setup/rma_kanban_stage/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/rma_kanban_stage/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)