Skip to content
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
6 changes: 1 addition & 5 deletions scrap_reason_code/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=================
Scrap Reason Code
=================
Expand All @@ -17,7 +13,7 @@ Scrap Reason Code
.. |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/license-AGPL--3-blue.png
.. |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%2Fstock--logistics--workflow-lightgray.png?logo=github
Expand Down
1 change: 1 addition & 0 deletions scrap_reason_code/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"views/reason_code_view.xml",
"views/stock_scrap_views.xml",
"views/stock_move_views.xml",
"views/stock_config_settings_views.xml",
],
"maintainers": ["bodedra"],
"installable": True,
Expand Down
1 change: 1 addition & 0 deletions scrap_reason_code/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from . import reason_code
from . import stock_move
from . import stock_scrap
from . import res_config_settings
11 changes: 11 additions & 0 deletions scrap_reason_code/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

scrap_reason_code_required = fields.Boolean(
config_parameter="scrap_order.scrap_reason_code_required",
)
14 changes: 14 additions & 0 deletions scrap_reason_code/models/stock_scrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools.safe_eval import safe_eval


class StockScrap(models.Model):
Expand All @@ -19,6 +20,19 @@ class StockScrap(models.Model):
compute="_compute_allowed_reason_code_ids",
)
scrap_location_id = fields.Many2one(readonly=True)
scrap_reason_code_required = fields.Boolean(
compute="_compute_scrap_reason_code_required"
)

# Depend on scrap_qty to make its value triggered when onchange
@api.depends("scrap_qty")
def _compute_scrap_reason_code_required(self):
icp_sudo = self.env["ir.config_parameter"].sudo()
scrap_reason_code_required = safe_eval(
icp_sudo.get_param("scrap_order.scrap_reason_code_required", "False")
)
for rec in self:
rec.scrap_reason_code_required = scrap_reason_code_required

@api.depends("product_id", "product_id.categ_id")
def _compute_allowed_reason_code_ids(self):
Expand Down
32 changes: 13 additions & 19 deletions scrap_reason_code/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
<title>README.rst</title>
<title>Scrap Reason Code</title>
<style type="text/css">

/*
Expand Down Expand Up @@ -360,21 +360,16 @@
</style>
</head>
<body>
<div class="document">
<div class="document" id="scrap-reason-code">
<h1 class="title">Scrap Reason Code</h1>


<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
</a>
<div class="section" id="scrap-reason-code">
<h1>Scrap Reason Code</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:06dd7e006450f61daa0a0bc65686a74480b20acf23e74a1b76e7ade02b6149b6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" 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 image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/stock-logistics-workflow/tree/18.0/scrap_reason_code"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-18-0/stock-logistics-workflow-18-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" 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 image-reference" 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 image-reference" href="https://github.com/OCA/stock-logistics-workflow/tree/18.0/scrap_reason_code"><img alt="OCA/stock-logistics-workflow" src="https://img.shields.io/badge/github-OCA%2Fstock--logistics--workflow-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-workflow-18-0/stock-logistics-workflow-18-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/stock-logistics-workflow&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-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>
Expand All @@ -394,12 +389,12 @@ <h1>Scrap Reason Code</h1>
</ul>
</div>
<div class="section" id="configuration">
<h2><a class="toc-backref" href="#toc-entry-1">Configuration</a></h2>
<h1><a class="toc-backref" href="#toc-entry-1">Configuration</a></h1>
<p>Go to Inventory &gt; Configuration &gt; Scrap Reason Codes</p>
<p>Create a required scrap reason code and provide scrap location.</p>
</div>
<div class="section" id="usage">
<h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
<ul class="simple">
<li>Go to Inventory &gt; Operations &gt; Scrap</li>
<li>Create a scarp order and select reason code.</li>
Expand All @@ -408,26 +403,26 @@ <h2><a class="toc-backref" href="#toc-entry-2">Usage</a></h2>
</ul>
</div>
<div class="section" id="known-issues-roadmap">
<h2><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h2>
<h1><a class="toc-backref" href="#toc-entry-3">Known issues / Roadmap</a></h1>
</div>
<div class="section" id="bug-tracker">
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/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 to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/stock-logistics-workflow/issues/new?body=module:%20scrap_reason_code%0Aversion:%2018.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">
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
<div class="section" id="authors">
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<ul class="simple">
<li>Open Source Integrators</li>
</ul>
</div>
<div class="section" id="contributors">
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li>Michael Allen &lt;<a class="reference external" href="mailto:mallen&#64;opensourceintegrators.com">mallen&#64;opensourceintegrators.com</a>&gt;</li>
<li>Bhavesh Odedra &lt;<a class="reference external" href="mailto:bodedra&#64;opensourceintegrators.com">bodedra&#64;opensourceintegrators.com</a>&gt;</li>
Expand All @@ -439,14 +434,14 @@ <h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
</ul>
</div>
<div class="section" id="other-credits">
<h3><a class="toc-backref" href="#toc-entry-8">Other credits</a></h3>
<h2><a class="toc-backref" href="#toc-entry-8">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">
<h3><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h3>
<h2><a class="toc-backref" href="#toc-entry-9">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" />
Expand All @@ -461,6 +456,5 @@ <h3><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h3>
</div>
</div>
</div>
</div>
</body>
</html>
22 changes: 22 additions & 0 deletions scrap_reason_code/views/stock_config_settings_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="stock_config_settings_view_form_inherit" model="ir.ui.view">
<field name="name">stock.config.settings.inherit</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="stock.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath
expr="//block[@name='operations_setting_container']"
position="inside"
>
<setting
id="scrap_reason_code_required"
title="Make the Scrap Reason Code is required on Scrap Order form view"
help="Make the Scrap Reason Code is required on Scrap Order form view"
>
<field name="scrap_reason_code_required" />
</setting>
</xpath>
</field>
</record>
</odoo>
18 changes: 15 additions & 3 deletions scrap_reason_code/views/stock_scrap_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
<field name="inherit_id" ref="stock.stock_scrap_form_view" />
<field name="arch" type="xml">
<xpath expr="//group/group" position='inside'>
<field name="reason_code_id" readonly="state == 'done'" />
<field
name="reason_code_id"
readonly="state == 'done'"
required="scrap_reason_code_required"
/>
<field name="allowed_reason_code_ids" invisible="True" />
</xpath>
</field>
Expand All @@ -19,7 +23,11 @@
<field name="inherit_id" ref="stock.stock_scrap_tree_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='product_uom_id']" position='after'>
<field name="reason_code_id" readonly="state == 'done'" />
<field
name="reason_code_id"
readonly="state == 'done'"
required="scrap_reason_code_required"
/>
<field name="allowed_reason_code_ids" invisible="True" />
</xpath>
</field>
Expand All @@ -30,7 +38,11 @@
<field name="inherit_id" ref="stock.stock_scrap_form_view2" />
<field name="arch" type="xml">
<xpath expr="//group/group" position='inside'>
<field name="reason_code_id" readonly="state == 'done'" />
<field
name="reason_code_id"
readonly="state == 'done'"
required="scrap_reason_code_required"
/>
<field name="allowed_reason_code_ids" invisible="True" />
</xpath>
</field>
Expand Down