Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] rma_kanban_stage: migration to v16 #478

Open
wants to merge 7 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions rma_kanban_stage/README.rst
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions rma_kanban_stage/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions rma_kanban_stage/__manifest__.py
Original file line number Diff line number Diff line change
@@ -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,
}
28 changes: 28 additions & 0 deletions rma_kanban_stage/data/rma_kanban_stage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record id="repair_kanban_stage_quarantine" model="base.kanban.stage">
<field name="name">New</field>
<field name="sequence" eval="10" />
<field name="res_model_id" ref="rma.model_rma_order_line" />
</record>
<record id="repair_kanban_stage_confirmed" model="base.kanban.stage">
<field name="name">Confirmed</field>
<field name="sequence" eval="15" />
<field name="res_model_id" ref="rma.model_rma_order_line" />
</record>
<record id="repair_kanban_stage_under_repair" model="base.kanban.stage">
<field name="name">Under Repair</field>
<field name="sequence" eval="20" />
<field name="res_model_id" ref="rma.model_rma_order_line" />
</record>
<record id="repair_kanban_stage_repaired" model="base.kanban.stage">
<field name="name">Repaired</field>
<field name="sequence" eval="25" />
<field name="res_model_id" ref="rma.model_rma_order_line" />
</record>
<record id="repair_kanban_stage_scrapped" model="base.kanban.stage">
<field name="name">Scrapped</field>
<field name="sequence" eval="30" />
<field name="res_model_id" ref="rma.model_rma_order_line" />
</record>
</odoo>
1 change: 1 addition & 0 deletions rma_kanban_stage/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import rma_order_line
33 changes: 33 additions & 0 deletions rma_kanban_stage/models/rma_order_line.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions rma_kanban_stage/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_rma_kanban
32 changes: 32 additions & 0 deletions rma_kanban_stage/tests/test_rma_kanban.py
Original file line number Diff line number Diff line change
@@ -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()
75 changes: 75 additions & 0 deletions rma_kanban_stage/views/rma_order_line_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<!-- Inherit base kanban abstract view Kanban View -->
<record id="rma_order_line_kanban" model="ir.ui.view">
<field name="name">rma.order.line.kanban</field>
<field name="model">rma.order.line</field>
<field
name="inherit_id"
ref="base_kanban_stage.base_kanban_abstract_view_kanban"
/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="//div[@name='card_body']">
<div name="main">
<strong><field name="name" /></strong>
<br />
<strong>Partner</strong>:<field name="partner_id" />
<br />
<t t-if="origin">
<br />
<strong>Origin</strong>: <field name="origin" />
</t>
<t
t-if="record.create_date.raw_value and record.create_date.raw_value &lt; (new Date())"
t-set="red"
>oe_kanban_text_red</t>
<span t-attf-class="#{red || ''}">
<strong>Date</strong>: <field name="create_date" />
</span>
<span name="product">
<br />
<strong>Product</strong>: <field name="product_id" />
<br />
<strong>QTY</strong>:<field name="product_qty" /> <field
name="uom_id"
/>
</span>
<br />
<span style='background-color:#EBEC6D' name="operation">
Operation - <field name="operation_id" /><br />
</span>
</div>
</xpath>
</field>
</record>

<record id="view_rma_rma_line_filter" model="ir.ui.view">
<field name="name">rma.order.line.select</field>
<field name="model">rma.order.line</field>
<field name="inherit_id" ref="rma.view_rma_rma_line_filter" />
<field name="arch" type="xml">
<group name="stock_quantities" position="after">
<group name="rma_stages" groups="stock.group_stock_user">
<filter
string="Stage"
name="stage"
context="{'group_by':'stage_id'}"
/>
</group>
</group>
</field>
</record>

<record id="rma.action_rma_customer_lines" model="ir.actions.act_window">
<field name="view_mode">kanban,tree,form</field>
<field name="view_id" ref="rma_kanban_stage.rma_order_line_kanban" />
</record>

<record id="rma.action_rma_supplier_lines" model="ir.actions.act_window">
<field name="view_mode">kanban,tree,form</field>
<field name="view_id" ref="rma_kanban_stage.rma_order_line_kanban" />
</record>

</odoo>
1 change: 1 addition & 0 deletions setup/rma_kanban_stage/odoo/addons/rma_kanban_stage
6 changes: 6 additions & 0 deletions setup/rma_kanban_stage/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
Loading