mirror of
https://github.com/ForgeFlow/stock-rma.git
synced 2025-01-21 12:57:49 +02:00
Merge pull request #529 from ForgeFlow/14.0-add-rma_reason_code
[14.0][ADD] rma_reason_code
This commit is contained in:
@@ -145,4 +145,13 @@
|
|||||||
action="base.action_partner_supplier_form"
|
action="base.action_partner_supplier_form"
|
||||||
sequence="60"
|
sequence="60"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- Report menus-->
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
id="menu_rma_rma_report"
|
||||||
|
name="Report"
|
||||||
|
parent="menu_rma_root"
|
||||||
|
sequence="100"
|
||||||
|
/>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|||||||
47
rma_reason_code/README.rst
Normal file
47
rma_reason_code/README.rst
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||||
|
:alt: License LGPL-3
|
||||||
|
|
||||||
|
============
|
||||||
|
RMA Put Away
|
||||||
|
============
|
||||||
|
|
||||||
|
This module allows you to put away the products after you have received them.
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
=============
|
||||||
|
|
||||||
|
Go to *RMA / Configuration / Customer Operations* and define there:
|
||||||
|
|
||||||
|
#. The Put Away Policy
|
||||||
|
#. The route that you wish to use to put away the products.
|
||||||
|
#. The default destination location (optional).
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
#. Go to a Customer RMA.
|
||||||
|
#. Click on *Put Away*.
|
||||||
|
#. Indicate the quantity that you want to put away and destination location.
|
||||||
|
|
||||||
|
Bug Tracker
|
||||||
|
===========
|
||||||
|
|
||||||
|
Bugs are tracked on `GitHub Issues
|
||||||
|
<https://github.com/Eficent/stock-rma/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 <jordi.ballester@ForgeFlow.com>
|
||||||
|
* David Jimenez <david.jimenez@ForgeFlow.com>
|
||||||
|
|
||||||
|
|
||||||
|
Maintainer
|
||||||
|
----------
|
||||||
|
|
||||||
|
This module is maintained by ForgeFlow
|
||||||
4
rma_reason_code/__init__.py
Normal file
4
rma_reason_code/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
from . import models
|
||||||
|
from . import reports
|
||||||
20
rma_reason_code/__manifest__.py
Normal file
20
rma_reason_code/__manifest__.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
{
|
||||||
|
"name": "RMA Reason Code",
|
||||||
|
"version": "14.0.1.1.0",
|
||||||
|
"license": "AGPL-3",
|
||||||
|
"summary": "Reason code for RMA",
|
||||||
|
"author": "ForgeFlow",
|
||||||
|
"website": "https://github.com/ForgeFlow/stock-rma",
|
||||||
|
"category": "Warehouse Management",
|
||||||
|
"depends": ["rma"],
|
||||||
|
"data": [
|
||||||
|
"security/ir.model.access.csv",
|
||||||
|
"security/security.xml",
|
||||||
|
"views/reason_code_view.xml",
|
||||||
|
"views/rma_order_line_views.xml",
|
||||||
|
"reports/rma_reason_code_report_views.xml",
|
||||||
|
],
|
||||||
|
"installable": True,
|
||||||
|
}
|
||||||
4
rma_reason_code/models/__init__.py
Normal file
4
rma_reason_code/models/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
from . import reason_code
|
||||||
|
from . import rma_order_line
|
||||||
26
rma_reason_code/models/reason_code.py
Normal file
26
rma_reason_code/models/reason_code.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
from random import randint
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class RMAReasonCode(models.Model):
|
||||||
|
_name = "rma.reason.code"
|
||||||
|
_description = "RMA Reason Code"
|
||||||
|
|
||||||
|
def _get_default_color(self):
|
||||||
|
return randint(1, 11)
|
||||||
|
|
||||||
|
name = fields.Char("Code", required=True)
|
||||||
|
description = fields.Text("Description")
|
||||||
|
type = fields.Selection(
|
||||||
|
[
|
||||||
|
("customer", "Customer RMA"),
|
||||||
|
("supplier", "Supplier RTV"),
|
||||||
|
("both", "Both Customer and Supplier"),
|
||||||
|
],
|
||||||
|
default="both",
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
color = fields.Integer("Color", default=_get_default_color)
|
||||||
44
rma_reason_code/models/rma_order_line.py
Normal file
44
rma_reason_code/models/rma_order_line.py
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import _, api, fields, models
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
|
||||||
|
class RMAOrderLine(models.Model):
|
||||||
|
_inherit = "rma.order.line"
|
||||||
|
|
||||||
|
reason_code_ids = fields.Many2many(
|
||||||
|
"rma.reason.code",
|
||||||
|
"rma_order_line_reason_code_rel",
|
||||||
|
string="Reason Code",
|
||||||
|
domain="[('id', 'in', allowed_reason_code_ids)]",
|
||||||
|
)
|
||||||
|
allowed_reason_code_ids = fields.Many2many(
|
||||||
|
comodel_name="rma.reason.code",
|
||||||
|
compute="_compute_allowed_reason_code_ids",
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends("type")
|
||||||
|
def _compute_allowed_reason_code_ids(self):
|
||||||
|
for rec in self:
|
||||||
|
codes = self.env["rma.reason.code"]
|
||||||
|
if rec.type == "customer":
|
||||||
|
codes = codes.search([("type", "in", ["customer", "both"])])
|
||||||
|
else:
|
||||||
|
codes = codes.search([("type", "in", ["supplier", "both"])])
|
||||||
|
rec.allowed_reason_code_ids = codes
|
||||||
|
|
||||||
|
@api.constrains("reason_code_ids", "product_id")
|
||||||
|
def _check_reason_code_ids(self):
|
||||||
|
for rec in self:
|
||||||
|
if rec.reason_code_ids and not any(
|
||||||
|
rc in rec.allowed_reason_code_ids for rc in rec.reason_code_ids
|
||||||
|
):
|
||||||
|
raise ValidationError(
|
||||||
|
_(
|
||||||
|
"Any of the reason code selected is not allowed for "
|
||||||
|
"this type of RMA (%s)."
|
||||||
|
)
|
||||||
|
% rec.type
|
||||||
|
)
|
||||||
1
rma_reason_code/readme/CONTRIBUTORS.rst
Normal file
1
rma_reason_code/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* David Jiménez <david.jimenez@forgeflow.com>
|
||||||
1
rma_reason_code/readme/DESCRIPTION.rst
Normal file
1
rma_reason_code/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Adds a reason code for RMA operations and an interface for the user to create RMA codes
|
||||||
1
rma_reason_code/reports/__init__.py
Normal file
1
rma_reason_code/reports/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from . import rma_reason_code_report
|
||||||
55
rma_reason_code/reports/rma_reason_code_report.py
Normal file
55
rma_reason_code/reports/rma_reason_code_report.py
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# Copyright 2022 ForgeFlow S.L.
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class RmaReasonCodeReport(models.Model):
|
||||||
|
_name = "rma.reason.code.report"
|
||||||
|
_auto = False
|
||||||
|
_description = "Rma Reason Code Report"
|
||||||
|
|
||||||
|
rma_order_line_id = fields.Many2one(comodel_name="rma.order.line")
|
||||||
|
reason_code_id = fields.Many2one(comodel_name="rma.reason.code")
|
||||||
|
date_rma = fields.Datetime(string="Order Date")
|
||||||
|
type = fields.Selection([("customer", "Customer"), ("supplier", "Supplier")])
|
||||||
|
company_id = fields.Many2one(comodel_name="res.company")
|
||||||
|
|
||||||
|
def _select(self):
|
||||||
|
return """
|
||||||
|
SELECT
|
||||||
|
row_number() OVER () AS id,
|
||||||
|
rma.id as rma_order_line_id,
|
||||||
|
rma.type,
|
||||||
|
rrc.id as reason_code_id,
|
||||||
|
rma.date_rma,
|
||||||
|
rma.company_id
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _from(self):
|
||||||
|
return """
|
||||||
|
FROM
|
||||||
|
rma_order_line rma
|
||||||
|
INNER JOIN
|
||||||
|
rma_order_line_reason_code_rel rolr ON rma.id = rolr.rma_order_line_id
|
||||||
|
INNER JOIN
|
||||||
|
rma_reason_code rrc ON rolr.rma_reason_code_id = rrc.id
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def _order_by(self):
|
||||||
|
return """
|
||||||
|
ORDER BY
|
||||||
|
rma.id, rrc.id
|
||||||
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _table_query(self):
|
||||||
|
return """
|
||||||
|
{_select}
|
||||||
|
{_from}
|
||||||
|
{_order_by}
|
||||||
|
""".format(
|
||||||
|
_select=self._select(), _from=self._from(), _order_by=self._order_by()
|
||||||
|
)
|
||||||
122
rma_reason_code/reports/rma_reason_code_report_views.xml
Normal file
122
rma_reason_code/reports/rma_reason_code_report_views.xml
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<odoo>
|
||||||
|
<record id="rma_reason_code_report_tree_view" model="ir.ui.view">
|
||||||
|
<field name="name">rma.reason.code.report.tree</field>
|
||||||
|
<field name="model">rma.reason.code.report</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree>
|
||||||
|
<field name="rma_order_line_id" />
|
||||||
|
<field name="reason_code_id" />
|
||||||
|
<field name="date_rma" optional="show" />
|
||||||
|
<field name="type" optional="hide" />
|
||||||
|
<field name="company_id" optional="hide" />
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="rma_reason_code_report_graph_view" model="ir.ui.view">
|
||||||
|
<field name="name">rma.reason.code.report.graph</field>
|
||||||
|
<field name="model">rma.reason.code.report</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<graph type="bar" sample="1">
|
||||||
|
<field name="date_rma" interval="week" />
|
||||||
|
</graph>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="rma_reason_code_report_search_view" model="ir.ui.view">
|
||||||
|
<field name="name">rma.reason.code.report.search</field>
|
||||||
|
<field name="model">rma.reason.code.report</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search>
|
||||||
|
<field name="reason_code_id" />
|
||||||
|
<group name="rma_type">
|
||||||
|
<separator />
|
||||||
|
<filter
|
||||||
|
name="is_customer"
|
||||||
|
string="Customer"
|
||||||
|
domain="[('type', '=', 'customer')]"
|
||||||
|
/>
|
||||||
|
<filter
|
||||||
|
name="is_supplier"
|
||||||
|
string="Supplier"
|
||||||
|
domain="[('type', '=', 'supplier')]"
|
||||||
|
/>
|
||||||
|
</group>
|
||||||
|
<separator />
|
||||||
|
<separator />
|
||||||
|
<filter name="date_rma" string="Date" date="date_rma" />
|
||||||
|
<filter
|
||||||
|
name="group_rma_date"
|
||||||
|
string="RMA Date"
|
||||||
|
context="{'group_by':'date_rma:week'}"
|
||||||
|
/>
|
||||||
|
<filter
|
||||||
|
name="group_reason_code_id"
|
||||||
|
string="Reason Code"
|
||||||
|
context="{'group_by':'reason_code_id'}"
|
||||||
|
/>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="action_rma_reason_code_report" model="ir.actions.act_window">
|
||||||
|
<field name="name">RMA Reason Code Analysis</field>
|
||||||
|
<field name="res_model">rma.reason.code.report</field>
|
||||||
|
<field name="view_mode">graph,pivot,tree</field>
|
||||||
|
<field
|
||||||
|
name="search_view_id"
|
||||||
|
ref="rma_reason_code.rma_reason_code_report_search_view"
|
||||||
|
/>
|
||||||
|
<field name="context">{
|
||||||
|
'search_default_group_rma_date': 1,
|
||||||
|
'search_default_group_reason_code_id': 2,
|
||||||
|
'search_default_is_customer': 1,
|
||||||
|
}</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
No data yet!
|
||||||
|
</p><p>
|
||||||
|
Assign a Reason Code to a RMA
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_rtv_reason_code_report" model="ir.actions.act_window">
|
||||||
|
<field name="name">RTV Reason Code Analysis</field>
|
||||||
|
<field name="res_model">rma.reason.code.report</field>
|
||||||
|
<field name="view_mode">graph,pivot,tree</field>
|
||||||
|
<field
|
||||||
|
name="search_view_id"
|
||||||
|
ref="rma_reason_code.rma_reason_code_report_search_view"
|
||||||
|
/>
|
||||||
|
<field name="context">{
|
||||||
|
'search_default_group_rma_date': 1,
|
||||||
|
'search_default_group_reason_code_id': 2,
|
||||||
|
'search_default_is_supplier': 1,
|
||||||
|
}</field>
|
||||||
|
<field name="help" type="html">
|
||||||
|
<p class="o_view_nocontent_smiling_face">
|
||||||
|
No data yet!
|
||||||
|
</p><p>
|
||||||
|
Assign a Reason Code to a RTV
|
||||||
|
</p>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
action="action_rma_reason_code_report"
|
||||||
|
id="menu_rma_reason_code_report"
|
||||||
|
parent="rma.menu_rma_rma_report"
|
||||||
|
sequence="140"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
action="action_rtv_reason_code_report"
|
||||||
|
id="menu_rtv_reason_code_report"
|
||||||
|
parent="rma.menu_rma_rma_report"
|
||||||
|
sequence="141"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
4
rma_reason_code/security/ir.model.access.csv
Normal file
4
rma_reason_code/security/ir.model.access.csv
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
access_rma_reason_code_user,rma.reason.code,model_rma_reason_code,rma.group_rma_customer_user,1,0,0,0
|
||||||
|
access_rma_reason_code_manager,rma.reason.code,model_rma_reason_code,rma.group_rma_manager,1,1,1,1
|
||||||
|
access_rma_reason_code_report_user,rma.reason.code.report,model_rma_reason_code_report,rma.group_rma_customer_user,1,0,0,0
|
||||||
|
14
rma_reason_code/security/security.xml
Normal file
14
rma_reason_code/security/security.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!--
|
||||||
|
Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
<odoo>
|
||||||
|
<record id="rma_reason_code_report_comp_rule" model="ir.rule">
|
||||||
|
<field name="name">RMA Reason Code Report</field>
|
||||||
|
<field name="model_id" ref="model_rma_reason_code_report" />
|
||||||
|
<field
|
||||||
|
name="domain_force"
|
||||||
|
>['|',('company_id','=',False),('company_id', 'in', company_ids)]</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
BIN
rma_reason_code/static/description/icon.png
Normal file
BIN
rma_reason_code/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
451
rma_reason_code/static/description/index.html
Normal file
451
rma_reason_code/static/description/index.html
Normal file
@@ -0,0 +1,451 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||||
|
<title>Scrap Reason Code</title>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
/*
|
||||||
|
:Author: David Goodger (goodger@python.org)
|
||||||
|
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
|
||||||
|
:Copyright: This stylesheet has been placed in the public domain.
|
||||||
|
|
||||||
|
Default cascading style sheet for the HTML output of Docutils.
|
||||||
|
|
||||||
|
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
||||||
|
customize this style sheet.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* used to remove borders from tables and images */
|
||||||
|
.borderless, table.borderless td, table.borderless th {
|
||||||
|
border: 0 }
|
||||||
|
|
||||||
|
table.borderless td, table.borderless th {
|
||||||
|
/* Override padding for "table.docutils td" with "! important".
|
||||||
|
The right padding separates the table cells. */
|
||||||
|
padding: 0 0.5em 0 0 ! important }
|
||||||
|
|
||||||
|
.first {
|
||||||
|
/* Override more specific margin styles with "! important". */
|
||||||
|
margin-top: 0 ! important }
|
||||||
|
|
||||||
|
.last, .with-subtitle {
|
||||||
|
margin-bottom: 0 ! important }
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none }
|
||||||
|
|
||||||
|
.subscript {
|
||||||
|
vertical-align: sub;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
.superscript {
|
||||||
|
vertical-align: super;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
a.toc-backref {
|
||||||
|
text-decoration: none ;
|
||||||
|
color: black }
|
||||||
|
|
||||||
|
blockquote.epigraph {
|
||||||
|
margin: 2em 5em ; }
|
||||||
|
|
||||||
|
dl.docutils dd {
|
||||||
|
margin-bottom: 0.5em }
|
||||||
|
|
||||||
|
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||||
|
dl.docutils dt {
|
||||||
|
font-weight: bold }
|
||||||
|
*/
|
||||||
|
|
||||||
|
div.abstract {
|
||||||
|
margin: 2em 5em }
|
||||||
|
|
||||||
|
div.abstract p.topic-title {
|
||||||
|
font-weight: bold ;
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||||
|
div.hint, div.important, div.note, div.tip, div.warning {
|
||||||
|
margin: 2em ;
|
||||||
|
border: medium outset ;
|
||||||
|
padding: 1em }
|
||||||
|
|
||||||
|
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||||
|
div.important p.admonition-title, div.note p.admonition-title,
|
||||||
|
div.tip p.admonition-title {
|
||||||
|
font-weight: bold ;
|
||||||
|
font-family: sans-serif }
|
||||||
|
|
||||||
|
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||||
|
div.danger p.admonition-title, div.error p.admonition-title,
|
||||||
|
div.warning p.admonition-title, .code .error {
|
||||||
|
color: red ;
|
||||||
|
font-weight: bold ;
|
||||||
|
font-family: sans-serif }
|
||||||
|
|
||||||
|
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||||
|
compound paragraphs.
|
||||||
|
div.compound .compound-first, div.compound .compound-middle {
|
||||||
|
margin-bottom: 0.5em }
|
||||||
|
|
||||||
|
div.compound .compound-last, div.compound .compound-middle {
|
||||||
|
margin-top: 0.5em }
|
||||||
|
*/
|
||||||
|
|
||||||
|
div.dedication {
|
||||||
|
margin: 2em 5em ;
|
||||||
|
text-align: center ;
|
||||||
|
font-style: italic }
|
||||||
|
|
||||||
|
div.dedication p.topic-title {
|
||||||
|
font-weight: bold ;
|
||||||
|
font-style: normal }
|
||||||
|
|
||||||
|
div.figure {
|
||||||
|
margin-left: 2em ;
|
||||||
|
margin-right: 2em }
|
||||||
|
|
||||||
|
div.footer, div.header {
|
||||||
|
clear: both;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
div.line-block {
|
||||||
|
display: block ;
|
||||||
|
margin-top: 1em ;
|
||||||
|
margin-bottom: 1em }
|
||||||
|
|
||||||
|
div.line-block div.line-block {
|
||||||
|
margin-top: 0 ;
|
||||||
|
margin-bottom: 0 ;
|
||||||
|
margin-left: 1.5em }
|
||||||
|
|
||||||
|
div.sidebar {
|
||||||
|
margin: 0 0 0.5em 1em ;
|
||||||
|
border: medium outset ;
|
||||||
|
padding: 1em ;
|
||||||
|
background-color: #ffffee ;
|
||||||
|
width: 40% ;
|
||||||
|
float: right ;
|
||||||
|
clear: right }
|
||||||
|
|
||||||
|
div.sidebar p.rubric {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-size: medium }
|
||||||
|
|
||||||
|
div.system-messages {
|
||||||
|
margin: 5em }
|
||||||
|
|
||||||
|
div.system-messages h1 {
|
||||||
|
color: red }
|
||||||
|
|
||||||
|
div.system-message {
|
||||||
|
border: medium outset ;
|
||||||
|
padding: 1em }
|
||||||
|
|
||||||
|
div.system-message p.system-message-title {
|
||||||
|
color: red ;
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
div.topic {
|
||||||
|
margin: 2em }
|
||||||
|
|
||||||
|
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||||
|
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||||
|
margin-top: 0.4em }
|
||||||
|
|
||||||
|
h1.title {
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
h2.subtitle {
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
hr.docutils {
|
||||||
|
width: 75% }
|
||||||
|
|
||||||
|
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||||
|
clear: left ;
|
||||||
|
float: left ;
|
||||||
|
margin-right: 1em }
|
||||||
|
|
||||||
|
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||||
|
clear: right ;
|
||||||
|
float: right ;
|
||||||
|
margin-left: 1em }
|
||||||
|
|
||||||
|
img.align-center, .figure.align-center, object.align-center {
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.align-center {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.align-left {
|
||||||
|
text-align: left }
|
||||||
|
|
||||||
|
.align-center {
|
||||||
|
clear: both ;
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
.align-right {
|
||||||
|
text-align: right }
|
||||||
|
|
||||||
|
/* reset inner alignment in figures */
|
||||||
|
div.align-right {
|
||||||
|
text-align: inherit }
|
||||||
|
|
||||||
|
/* div.align-center * { */
|
||||||
|
/* text-align: left } */
|
||||||
|
|
||||||
|
.align-top {
|
||||||
|
vertical-align: top }
|
||||||
|
|
||||||
|
.align-middle {
|
||||||
|
vertical-align: middle }
|
||||||
|
|
||||||
|
.align-bottom {
|
||||||
|
vertical-align: bottom }
|
||||||
|
|
||||||
|
ol.simple, ul.simple {
|
||||||
|
margin-bottom: 1em }
|
||||||
|
|
||||||
|
ol.arabic {
|
||||||
|
list-style: decimal }
|
||||||
|
|
||||||
|
ol.loweralpha {
|
||||||
|
list-style: lower-alpha }
|
||||||
|
|
||||||
|
ol.upperalpha {
|
||||||
|
list-style: upper-alpha }
|
||||||
|
|
||||||
|
ol.lowerroman {
|
||||||
|
list-style: lower-roman }
|
||||||
|
|
||||||
|
ol.upperroman {
|
||||||
|
list-style: upper-roman }
|
||||||
|
|
||||||
|
p.attribution {
|
||||||
|
text-align: right ;
|
||||||
|
margin-left: 50% }
|
||||||
|
|
||||||
|
p.caption {
|
||||||
|
font-style: italic }
|
||||||
|
|
||||||
|
p.credits {
|
||||||
|
font-style: italic ;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
p.label {
|
||||||
|
white-space: nowrap }
|
||||||
|
|
||||||
|
p.rubric {
|
||||||
|
font-weight: bold ;
|
||||||
|
font-size: larger ;
|
||||||
|
color: maroon ;
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
p.sidebar-title {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-weight: bold ;
|
||||||
|
font-size: larger }
|
||||||
|
|
||||||
|
p.sidebar-subtitle {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
p.topic-title {
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
pre.address {
|
||||||
|
margin-bottom: 0 ;
|
||||||
|
margin-top: 0 ;
|
||||||
|
font: inherit }
|
||||||
|
|
||||||
|
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||||
|
margin-left: 2em ;
|
||||||
|
margin-right: 2em }
|
||||||
|
|
||||||
|
pre.code .ln { color: grey; } /* line numbers */
|
||||||
|
pre.code, code { background-color: #eeeeee }
|
||||||
|
pre.code .comment, code .comment { color: #5C6576 }
|
||||||
|
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||||
|
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||||
|
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||||
|
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||||
|
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||||
|
|
||||||
|
span.classifier {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-style: oblique }
|
||||||
|
|
||||||
|
span.classifier-delimiter {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
span.interpreted {
|
||||||
|
font-family: sans-serif }
|
||||||
|
|
||||||
|
span.option {
|
||||||
|
white-space: nowrap }
|
||||||
|
|
||||||
|
span.pre {
|
||||||
|
white-space: pre }
|
||||||
|
|
||||||
|
span.problematic {
|
||||||
|
color: red }
|
||||||
|
|
||||||
|
span.section-subtitle {
|
||||||
|
/* font-size relative to parent (h1..h6 element) */
|
||||||
|
font-size: 80% }
|
||||||
|
|
||||||
|
table.citation {
|
||||||
|
border-left: solid 1px gray;
|
||||||
|
margin-left: 1px }
|
||||||
|
|
||||||
|
table.docinfo {
|
||||||
|
margin: 2em 4em }
|
||||||
|
|
||||||
|
table.docutils {
|
||||||
|
margin-top: 0.5em ;
|
||||||
|
margin-bottom: 0.5em }
|
||||||
|
|
||||||
|
table.footnote {
|
||||||
|
border-left: solid 1px black;
|
||||||
|
margin-left: 1px }
|
||||||
|
|
||||||
|
table.docutils td, table.docutils th,
|
||||||
|
table.docinfo td, table.docinfo th {
|
||||||
|
padding-left: 0.5em ;
|
||||||
|
padding-right: 0.5em ;
|
||||||
|
vertical-align: top }
|
||||||
|
|
||||||
|
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||||
|
font-weight: bold ;
|
||||||
|
text-align: left ;
|
||||||
|
white-space: nowrap ;
|
||||||
|
padding-left: 0 }
|
||||||
|
|
||||||
|
/* "booktabs" style (no vertical lines) */
|
||||||
|
table.docutils.booktabs {
|
||||||
|
border: 0px;
|
||||||
|
border-top: 2px solid;
|
||||||
|
border-bottom: 2px solid;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
table.docutils.booktabs * {
|
||||||
|
border: 0px;
|
||||||
|
}
|
||||||
|
table.docutils.booktabs th {
|
||||||
|
border-bottom: thin solid;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||||
|
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||||
|
font-size: 100% }
|
||||||
|
|
||||||
|
ul.auto-toc {
|
||||||
|
list-style-type: none }
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="document" id="scrap-reason-code">
|
||||||
|
<h1 class="title">Scrap Reason Code</h1>
|
||||||
|
|
||||||
|
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
|
!! changes will be overwritten. !!
|
||||||
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
|
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/14.0/scrap_reason_code"><img alt="OCA/stock-logistics-warehouse" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--warehouse-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-14-0/stock-logistics-warehouse-14-0-scrap_reason_code"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/153/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||||
|
<p>Adds a reason code for scrapping operations and an interface for the user
|
||||||
|
to create scrap codes</p>
|
||||||
|
<p><strong>Table of contents</strong></p>
|
||||||
|
<div class="contents local topic" id="contents">
|
||||||
|
<ul class="simple">
|
||||||
|
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
|
||||||
|
<li><a class="reference internal" href="#usage" id="id2">Usage</a></li>
|
||||||
|
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
|
||||||
|
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
|
||||||
|
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
|
||||||
|
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
|
||||||
|
<li><a class="reference internal" href="#other-credits" id="id7">Other credits</a></li>
|
||||||
|
<li><a class="reference internal" href="#maintainers" id="id8">Maintainers</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="configuration">
|
||||||
|
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
|
||||||
|
<p>Go to Inventory > Configuration > Scrap Reason Codes</p>
|
||||||
|
<p>Create a required scrap reason code and provide scrap location.</p>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="usage">
|
||||||
|
<h1><a class="toc-backref" href="#id2">Usage</a></h1>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>Go to Inventory > Operations > Scrap</li>
|
||||||
|
<li>Create a scarp order and select reason code.</li>
|
||||||
|
<li>A scrap location will be readonly and auto fill based on selected reason
|
||||||
|
code.</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="bug-tracker">
|
||||||
|
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
|
||||||
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues">GitHub Issues</a>.
|
||||||
|
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
|
||||||
|
<a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20scrap_reason_code%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="credits">
|
||||||
|
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
|
||||||
|
<div class="section" id="authors">
|
||||||
|
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>Open Source Integrators</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="contributors">
|
||||||
|
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>Michael Allen <<a class="reference external" href="mailto:mallen@opensourceintegrators.com">mallen@opensourceintegrators.com</a>></li>
|
||||||
|
<li>Bhavesh Odedra <<a class="reference external" href="mailto:bodedra@opensourceintegrators.com">bodedra@opensourceintegrators.com</a>></li>
|
||||||
|
<li>Balaji Kannan <<a class="reference external" href="mailto:bkannan@opensourceintegrators.com">bkannan@opensourceintegrators.com</a>></li>
|
||||||
|
<li>Serpent Consulting Services Pvt. Ltd. <<a class="reference external" href="mailto:support@serpentcs.com">support@serpentcs.com</a>></li>
|
||||||
|
<li>Chandresh Thakkar <<a class="reference external" href="mailto:cthakkar@opensourceintegrators.com">cthakkar@opensourceintegrators.com</a>></li>
|
||||||
|
<li>Lois Rilo <<a class="reference external" href="mailto:lois.rilo@forgeflow.com">lois.rilo@forgeflow.com</a>></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="other-credits">
|
||||||
|
<h2><a class="toc-backref" href="#id7">Other credits</a></h2>
|
||||||
|
<p>The development of this module has been financially supported by:</p>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>Open Source Integrators</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="maintainers">
|
||||||
|
<h2><a class="toc-backref" href="#id8">Maintainers</a></h2>
|
||||||
|
<p>This module is maintained by the OCA.</p>
|
||||||
|
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
|
||||||
|
<p>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.</p>
|
||||||
|
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
|
||||||
|
<p><a class="reference external" href="https://github.com/bodedra"><img alt="bodedra" src="https://github.com/bodedra.png?size=40px" /></a></p>
|
||||||
|
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/stock-logistics-warehouse/tree/14.0/scrap_reason_code">OCA/stock-logistics-warehouse</a> project on GitHub.</p>
|
||||||
|
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
3
rma_reason_code/tests/__init__.py
Normal file
3
rma_reason_code/tests/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
from . import test_scrap_reason_code
|
||||||
160
rma_reason_code/tests/test_scrap_reason_code.py
Normal file
160
rma_reason_code/tests/test_scrap_reason_code.py
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
# Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import api
|
||||||
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.tests import common
|
||||||
|
|
||||||
|
|
||||||
|
class RMAOrderLine(common.SavepointCase):
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls):
|
||||||
|
super(RMAOrderLine, cls).setUpClass()
|
||||||
|
cls.user_admin = cls.env.ref("base.user_admin")
|
||||||
|
cls.env = api.Environment(cls.cr, cls.user_admin.id, {})
|
||||||
|
cls.user_admin.tz = False # Make sure there's no timezone in user
|
||||||
|
cls.warehouse = cls.env.ref("stock.warehouse0")
|
||||||
|
cls.location = cls.env.ref("rma.location_rma")
|
||||||
|
cls.cust_location = cls.env.ref("stock.stock_location_customers")
|
||||||
|
cls.vend_location = cls.env.ref("stock.stock_location_suppliers")
|
||||||
|
cls.product = cls.env["product.product"].create(
|
||||||
|
{
|
||||||
|
"name": "TEST Product",
|
||||||
|
"type": "product",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
cls.partner = cls.env["res.partner"].create({"name": "Test partner"})
|
||||||
|
|
||||||
|
cls.route = cls.env.ref("rma.route_rma_customer")
|
||||||
|
|
||||||
|
cls.operation1 = cls.env["rma.operation"].create(
|
||||||
|
{
|
||||||
|
"code": "TEST1",
|
||||||
|
"name": "Replace after receive",
|
||||||
|
"type": "customer",
|
||||||
|
"receipt_policy": "ordered",
|
||||||
|
"delivery_policy": "received",
|
||||||
|
"in_route_id": cls.route.id,
|
||||||
|
"out_route_id": cls.route.id,
|
||||||
|
"location_id": cls.location.id,
|
||||||
|
"in_warehouse_id": cls.warehouse.id,
|
||||||
|
"out_warehouse_id": cls.warehouse.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
cls.operation2 = cls.env["rma.operation"].create(
|
||||||
|
{
|
||||||
|
"code": "TEST2",
|
||||||
|
"name": "Refund after receive",
|
||||||
|
"type": "supplier",
|
||||||
|
"receipt_policy": "ordered",
|
||||||
|
"delivery_policy": "no",
|
||||||
|
"in_route_id": cls.route.id,
|
||||||
|
"out_route_id": cls.route.id,
|
||||||
|
"location_id": cls.location.id,
|
||||||
|
"in_warehouse_id": cls.warehouse.id,
|
||||||
|
"out_warehouse_id": cls.warehouse.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
cls.rma_line_1 = cls.env["rma.order.line"].create(
|
||||||
|
{
|
||||||
|
"partner_id": cls.partner.id,
|
||||||
|
"requested_by": False,
|
||||||
|
"assigned_to": False,
|
||||||
|
"type": "customer",
|
||||||
|
"product_id": cls.product.id,
|
||||||
|
"uom_id": cls.product.uom_id.id,
|
||||||
|
"product_qty": 1,
|
||||||
|
"price_unit": 10,
|
||||||
|
"operation_id": cls.operation1.id,
|
||||||
|
"delivery_address_id": cls.partner.id,
|
||||||
|
"receipt_policy": cls.operation1.receipt_policy,
|
||||||
|
"delivery_policy": cls.operation1.delivery_policy,
|
||||||
|
"in_warehouse_id": cls.operation1.in_warehouse_id.id,
|
||||||
|
"out_warehouse_id": cls.operation1.out_warehouse_id.id,
|
||||||
|
"in_route_id": cls.operation1.in_route_id.id,
|
||||||
|
"out_route_id": cls.operation1.out_route_id.id,
|
||||||
|
"location_id": cls.operation1.location_id.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
cls.rma_line_2 = cls.env["rma.order.line"].create(
|
||||||
|
{
|
||||||
|
"partner_id": cls.partner.id,
|
||||||
|
"requested_by": False,
|
||||||
|
"assigned_to": False,
|
||||||
|
"type": "supplier",
|
||||||
|
"product_id": cls.product.id,
|
||||||
|
"uom_id": cls.product.uom_id.id,
|
||||||
|
"product_qty": 1,
|
||||||
|
"price_unit": 10,
|
||||||
|
"operation_id": cls.operation2.id,
|
||||||
|
"delivery_address_id": cls.partner.id,
|
||||||
|
"receipt_policy": cls.operation2.receipt_policy,
|
||||||
|
"delivery_policy": cls.operation2.delivery_policy,
|
||||||
|
"in_warehouse_id": cls.operation2.in_warehouse_id.id,
|
||||||
|
"out_warehouse_id": cls.operation2.out_warehouse_id.id,
|
||||||
|
"in_route_id": cls.operation2.in_route_id.id,
|
||||||
|
"out_route_id": cls.operation2.out_route_id.id,
|
||||||
|
"location_id": cls.operation2.location_id.id,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
cls.env["rma.reason.code"].search([]).unlink()
|
||||||
|
cls.reason_code_both = cls.env["rma.reason.code"].create(
|
||||||
|
{
|
||||||
|
"name": "Test Code 1",
|
||||||
|
"description": "Test description",
|
||||||
|
"type": "both",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
cls.reason_code_customer = cls.env["rma.reason.code"].create(
|
||||||
|
{
|
||||||
|
"name": "Test Code 2",
|
||||||
|
"description": "Test description",
|
||||||
|
"type": "customer",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
cls.reason_code_supplier = cls.env["rma.reason.code"].create(
|
||||||
|
{
|
||||||
|
"name": "Test Code 3",
|
||||||
|
"description": "Test description",
|
||||||
|
"type": "supplier",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_01_reason_code_customer(self):
|
||||||
|
self.rma_line_1.action_rma_to_approve()
|
||||||
|
self.assertEqual(
|
||||||
|
self.rma_line_1.allowed_reason_code_ids.ids,
|
||||||
|
[self.reason_code_both.id, self.reason_code_customer.id],
|
||||||
|
)
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
self.rma_line_1.write(
|
||||||
|
{
|
||||||
|
"reason_code_ids": [self.reason_code_supplier.id],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.rma_line_1.write(
|
||||||
|
{
|
||||||
|
"reason_code_ids": [self.reason_code_customer.id],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_02_reason_code_supplier(self):
|
||||||
|
self.rma_line_2.action_rma_to_approve()
|
||||||
|
self.assertEqual(
|
||||||
|
self.rma_line_2.allowed_reason_code_ids.ids,
|
||||||
|
[self.reason_code_both.id, self.reason_code_supplier.id],
|
||||||
|
)
|
||||||
|
with self.assertRaises(ValidationError):
|
||||||
|
self.rma_line_2.write(
|
||||||
|
{
|
||||||
|
"reason_code_ids": [self.reason_code_customer.id],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
self.rma_line_2.write(
|
||||||
|
{
|
||||||
|
"reason_code_ids": [self.reason_code_supplier.id],
|
||||||
|
}
|
||||||
|
)
|
||||||
55
rma_reason_code/views/reason_code_view.xml
Normal file
55
rma_reason_code/views/reason_code_view.xml
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!--
|
||||||
|
Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
<odoo>
|
||||||
|
<!-- RMA Reason Code Type -->
|
||||||
|
<record id="view_rma_reason_code_form" model="ir.ui.view">
|
||||||
|
<field name="name">rma.reason.code.form</field>
|
||||||
|
<field name="model">rma.reason.code</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Reason Code">
|
||||||
|
<sheet>
|
||||||
|
<div class="oe_title">
|
||||||
|
<h1><field name="name" nolabel="1" /></h1>
|
||||||
|
</div>
|
||||||
|
<group>
|
||||||
|
<field
|
||||||
|
name="description"
|
||||||
|
placeholder="Add a description..."
|
||||||
|
nolabel="1"
|
||||||
|
colspan="2"
|
||||||
|
/>
|
||||||
|
<field name="type" />
|
||||||
|
<field name="color" widget="color_picker" />
|
||||||
|
</group>
|
||||||
|
</sheet>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="view_rma_reason_code_list" model="ir.ui.view">
|
||||||
|
<field name="name">rma.reason.code.list</field>
|
||||||
|
<field name="model">rma.reason.code</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="Reason Codes">
|
||||||
|
<field name="name" />
|
||||||
|
<field name="description" />
|
||||||
|
<field name="type" />
|
||||||
|
<field name="color" widget="color_picker" />
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="open_view_rma_reason_code_form" model="ir.actions.act_window">
|
||||||
|
<field name="name">RMA Reason Codes</field>
|
||||||
|
<field name="res_model">rma.reason.code</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
</record>
|
||||||
|
<menuitem
|
||||||
|
action="open_view_rma_reason_code_form"
|
||||||
|
id="menu_view_rma_reason_code_form"
|
||||||
|
parent="rma.menu_rma_config"
|
||||||
|
sequence="55"
|
||||||
|
groups="rma.group_rma_manager"
|
||||||
|
/>
|
||||||
|
</odoo>
|
||||||
74
rma_reason_code/views/rma_order_line_views.xml
Normal file
74
rma_reason_code/views/rma_order_line_views.xml
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!--
|
||||||
|
Copyright 2024 ForgeFlow S.L. (https://www.forgeflow.com)
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="view_rma_line_tree" model="ir.ui.view">
|
||||||
|
<field name="name">rma.order.line.tree - rma_reason_code</field>
|
||||||
|
<field name="model">rma.order.line</field>
|
||||||
|
<field name="inherit_id" ref="rma.view_rma_line_tree" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="operation_id" position='after'>
|
||||||
|
<field
|
||||||
|
name="reason_code_ids"
|
||||||
|
widget="many2many_tags"
|
||||||
|
options="{'color_field': 'color', 'no_create': True}"
|
||||||
|
/>
|
||||||
|
<field name="allowed_reason_code_ids" invisible="1" />
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_rma_line_supplier_tree" model="ir.ui.view">
|
||||||
|
<field name="name">rma.order.line.supplier.tree - rma_reason_code</field>
|
||||||
|
<field name="model">rma.order.line</field>
|
||||||
|
<field name="inherit_id" ref="rma.view_rma_line_supplier_tree" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="operation_id" position='after'>
|
||||||
|
<field
|
||||||
|
name="reason_code_ids"
|
||||||
|
widget="many2many_tags"
|
||||||
|
options="{'color_field': 'color', 'no_create': True}"
|
||||||
|
/>
|
||||||
|
<field name="allowed_reason_code_ids" invisible="1" />
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_rma_line_form" model="ir.ui.view">
|
||||||
|
<field name="name">rma.order.line.form - rma_reason_code</field>
|
||||||
|
<field name="model">rma.order.line</field>
|
||||||
|
<field name="inherit_id" ref="rma.view_rma_line_form" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="assigned_to" position='after'>
|
||||||
|
<field
|
||||||
|
name="reason_code_ids"
|
||||||
|
widget="many2many_tags"
|
||||||
|
options="{'color_field': 'color', 'no_create': True}"
|
||||||
|
/>
|
||||||
|
<field name="allowed_reason_code_ids" invisible="1" />
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_rma_rma_line_filter" model="ir.ui.view">
|
||||||
|
<field name="name">rma.order.line.search - rma_reason_code</field>
|
||||||
|
<field name="model">rma.order.line</field>
|
||||||
|
<field name="inherit_id" ref="rma.view_rma_rma_line_filter" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<filter name="operation" position='after'>
|
||||||
|
<field name="reason_code_ids" />
|
||||||
|
<separator />
|
||||||
|
<filter
|
||||||
|
name="group_reason_code_ids"
|
||||||
|
string="Reason Code"
|
||||||
|
context="{'group_by':'reason_code_ids'}"
|
||||||
|
/>
|
||||||
|
<field name="allowed_reason_code_ids" invisible="1" />
|
||||||
|
<field name="allowed_reason_code_ids" invisible="1" />
|
||||||
|
</filter>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
1
setup/rma_reason_code/odoo/addons/rma_reason_code
Symbolic link
1
setup/rma_reason_code/odoo/addons/rma_reason_code
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../../rma_reason_code
|
||||||
6
setup/rma_reason_code/setup.py
Normal file
6
setup/rma_reason_code/setup.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import setuptools
|
||||||
|
|
||||||
|
setuptools.setup(
|
||||||
|
setup_requires=['setuptools-odoo'],
|
||||||
|
odoo_addon=True,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user