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

[IMP] stock_exception: method exception #2172

Open
wants to merge 1 commit 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ addon | version | maintainers | summary
[stock_cycle_count](stock_cycle_count/) | 16.0.1.1.0 | [![LoisRForgeFlow](https://github.com/LoisRForgeFlow.png?size=30px)](https://github.com/LoisRForgeFlow) | Adds the capability to schedule cycle counts in a warehouse through different rules defined by the user.
[stock_demand_estimate](stock_demand_estimate/) | 16.0.1.2.0 | | Allows to create demand estimates.
[stock_demand_estimate_matrix](stock_demand_estimate_matrix/) | 16.0.1.0.0 | | Allows to create demand estimates.
[stock_exception](stock_exception/) | 16.0.1.0.0 | | Custom exceptions on stock picking
[stock_exception](stock_exception/) | 16.0.1.1.0 | | Custom exceptions on stock picking
[stock_helper](stock_helper/) | 16.0.1.1.0 | | Add methods shared between various stock modules
[stock_inventory](stock_inventory/) | 16.0.2.5.0 | | Allows to do an easier follow up of the Inventory Adjustments
[stock_inventory_count_to_zero](stock_inventory_count_to_zero/) | 16.0.1.0.0 | | Request an inventory count filling the quantities to zero as default
Expand Down
2 changes: 1 addition & 1 deletion stock_exception/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Stock Exception
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9b8183c2a60002050aaae57962c63dba0c1d30762d8cc7f0f8273f52c62135a3
!! source digest: sha256:3a8f0942ab573333c7f92bf4966bc4d210489d20b8e0aa3d3b5acf382a60d622
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
1 change: 1 addition & 0 deletions stock_exception/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"data/stock_exception_data.xml",
"wizard/stock_exception_confirm_view.xml",
"views/stock_view.xml",
"views/base_exception_view.xml",
],
"installable": True,
}
6 changes: 6 additions & 0 deletions stock_exception/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ msgstr "Chequear al Confirmar"
#: model:ir.model.fields,field_description:stock_exception.field_exception_rule__check_on_validate
msgid "Check On Validate"
msgstr "Chequear al Validar"

#. module: stock_exception
#: model:ir.actions.act_window,name:stock_exception.action_stock_test_tree
#: model:ir.ui.menu,name:stock_exception.menu_stock_test
msgid "Stock Exception Rules"
msgstr "Reglas de Excepción de Stock"
8 changes: 8 additions & 0 deletions stock_exception/models/exception_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ class ExceptionRule(models.Model):
],
ondelete={"stock.picking": "cascade", "stock.move": "cascade"},
)
method = fields.Selection(
selection_add=[
("button_validate", "Validation"),
("action_confirm", "Confirmation"),
],
readonly=False,
mav-adhoc marked this conversation as resolved.
Show resolved Hide resolved
ondelete="cascade",
)
16 changes: 14 additions & 2 deletions stock_exception/models/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,25 @@ def onchange_ignore_exception(self):

def action_confirm(self):
for rec in self:
if rec.detect_exceptions() and not rec.ignore_exception:
exception = self.env["exception.rule"].search(
[("model", "=", "stock.picking"), ("method", "=", "action_confirm")]
)
if exception and not rec.ignore_exception:
rec.exception_ids = [(4, exception.id)]
return rec._popup_exceptions()
elif rec.detect_exceptions() and not rec.ignore_exception:
return rec._popup_exceptions()
return super().action_confirm()

def button_validate(self):
for rec in self:
if rec.detect_exceptions() and not rec.ignore_exception:
exception = self.env["exception.rule"].search(
[("model", "=", "stock.picking"), ("method", "=", "button_validate")]
)
if exception and not rec.ignore_exception:
rec.exception_ids = [(4, exception.id)]
return rec._popup_exceptions()
elif rec.detect_exceptions() and not rec.ignore_exception:
return rec._popup_exceptions()
return super().button_validate()

Expand Down
14 changes: 8 additions & 6 deletions stock_exception/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?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>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* 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 }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Stock Exception</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:9b8183c2a60002050aaae57962c63dba0c1d30762d8cc7f0f8273f52c62135a3
!! source digest: sha256:3a8f0942ab573333c7f92bf4966bc4d210489d20b8e0aa3d3b5acf382a60d622
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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-warehouse/tree/16.0/stock_exception"><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 image-reference" href="https://translation.odoo-community.org/projects/stock-logistics-warehouse-16-0/stock-logistics-warehouse-16-0-stock_exception"><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-warehouse&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows you attach several customizable exceptions to your
Expand Down Expand Up @@ -412,7 +412,9 @@ <h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">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>
<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>
Expand Down
24 changes: 24 additions & 0 deletions stock_exception/views/base_exception_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<odoo>
<record id="view_exception_rule_form_inherit" model="ir.ui.view">
<field name="name">exception.rule.form.inherit</field>
<field name="model">exception.rule</field>
<field name="inherit_id" ref="base_exception.view_exception_rule_form" />
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page
name="method"
string="Method"
attrs="{'invisible': [('exception_type','!=','by_method')], 'required': [('exception_type','=','by_method')]}"
>
<group>
<field
name="method"
widget="selection"
options="{'model': 'ir.model.methods'}"
/>
</group>
</page>
</xpath>
</field>
</record>
</odoo>
Loading