[MIG] base_exception: Migration to 13.0

pull/2366/head
Jared Kipe 2020-03-13 09:32:40 -07:00 committed by Cesar Andres Sanchez
parent e02654082e
commit 0fb654831d
12 changed files with 111 additions and 84 deletions

View File

@ -14,13 +14,13 @@ Exception Rule
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github
:target: https://github.com/OCA/server-tools/tree/12.0/base_exception :target: https://github.com/OCA/server-tools/tree/13.0/base_exception
:alt: OCA/server-tools :alt: OCA/server-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_exception :target: https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_exception
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/149/12.0 :target: https://runbot.odoo-community.org/runbot/149/13.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -50,7 +50,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_exception%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/server-tools/issues/new?body=module:%20base_exception%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -77,6 +77,10 @@ Contributors
* Raphaël Reverdy <raphael.reverdy@akretion.com> * Raphaël Reverdy <raphael.reverdy@akretion.com>
* Iván Todorovich <ivan.todorovich@druidoo.io> * Iván Todorovich <ivan.todorovich@druidoo.io>
* Tecnativa <tecnativa.com>
* João Marques
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -90,6 +94,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/12.0/base_exception>`_ project on GitHub. This module is part of the `OCA/server-tools <https://github.com/OCA/server-tools/tree/13.0/base_exception>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -1,10 +1,11 @@
# Copyright 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis # Copyright 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis
# Copyright 2017 Akretion (http://www.akretion.com) # Copyright 2017 Akretion (http://www.akretion.com)
# Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com> # Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
# Copyright 2020 Hibou Corp.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
"name": "Exception Rule", "name": "Exception Rule",
"version": "12.0.3.0.1", "version": "13.0.1.0.0",
"category": "Generic Modules", "category": "Generic Modules",
"summary": """ "summary": """
This module provide an abstract model to manage customizable This module provide an abstract model to manage customizable

View File

@ -1,6 +1,7 @@
# Copyright 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis # Copyright 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis
# Copyright 2017 Akretion (http://www.akretion.com) # Copyright 2017 Akretion (http://www.akretion.com)
# Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com> # Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
# Copyright 2020 Hibou Corp.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import html import html
@ -55,7 +56,6 @@ class ExceptionRule(models.Model):
) )
) )
@api.multi
def _get_domain(self): def _get_domain(self):
""" override me to customize domains according exceptions cases """ """ override me to customize domains according exceptions cases """
self.ensure_one() self.ensure_one()
@ -66,7 +66,6 @@ class BaseExceptionMethod(models.AbstractModel):
_name = "base.exception.method" _name = "base.exception.method"
_description = "Exception Rule Methods" _description = "Exception Rule Methods"
@api.multi
def _get_main_records(self): def _get_main_records(self):
""" """
Used in case we check exceptions on a record but write these Used in case we check exceptions on a record but write these
@ -76,7 +75,6 @@ class BaseExceptionMethod(models.AbstractModel):
""" """
return self return self
@api.multi
def _reverse_field(self): def _reverse_field(self):
raise NotImplementedError() raise NotImplementedError()
@ -87,7 +85,6 @@ class BaseExceptionMethod(models.AbstractModel):
""" """
return [("model", "=", self._name)] return [("model", "=", self._name)]
@api.multi
def detect_exceptions(self): def detect_exceptions(self):
"""List all exception_ids applied on self """List all exception_ids applied on self
Exception ids are also written on records Exception ids are also written on records
@ -160,18 +157,15 @@ class BaseExceptionMethod(models.AbstractModel):
) )
return space.get("failed", False) return space.get("failed", False)
@api.multi
def _detect_exceptions(self, rule): def _detect_exceptions(self, rule):
if rule.exception_type == "by_py_code": if rule.exception_type == "by_py_code":
return self._detect_exceptions_by_py_code(rule) return self._detect_exceptions_by_py_code(rule)
elif rule.exception_type == "by_domain": elif rule.exception_type == "by_domain":
return self._detect_exceptions_by_domain(rule) return self._detect_exceptions_by_domain(rule)
@api.multi
def _get_base_domain(self): def _get_base_domain(self):
return [("ignore_exception", "=", False), ("id", "in", self.ids)] return [("ignore_exception", "=", False), ("id", "in", self.ids)]
@api.multi
def _detect_exceptions_by_py_code(self, rule): def _detect_exceptions_by_py_code(self, rule):
""" """
Find exceptions found on self. Find exceptions found on self.
@ -184,7 +178,6 @@ class BaseExceptionMethod(models.AbstractModel):
records_with_exception |= record records_with_exception |= record
return records_with_exception return records_with_exception
@api.multi
def _detect_exceptions_by_domain(self, rule): def _detect_exceptions_by_domain(self, rule):
""" """
Find exceptions found on self. Find exceptions found on self.
@ -195,7 +188,7 @@ class BaseExceptionMethod(models.AbstractModel):
return self.search(domain) return self.search(domain)
class BaseException(models.AbstractModel): class BaseExceptionModel(models.AbstractModel):
_inherit = "base.exception.method" _inherit = "base.exception.method"
_name = "base.exception" _name = "base.exception"
_order = "main_exception_id asc" _order = "main_exception_id asc"
@ -213,7 +206,6 @@ class BaseException(models.AbstractModel):
exception_ids = fields.Many2many("exception.rule", string="Exceptions", copy=False) exception_ids = fields.Many2many("exception.rule", string="Exceptions", copy=False)
ignore_exception = fields.Boolean("Ignore Exceptions", copy=False) ignore_exception = fields.Boolean("Ignore Exceptions", copy=False)
@api.multi
def action_ignore_exceptions(self): def action_ignore_exceptions(self):
self.write({"ignore_exception": True}) self.write({"ignore_exception": True})
return True return True
@ -237,8 +229,9 @@ class BaseException(models.AbstractModel):
for e in rec.exception_ids for e in rec.exception_ids
] ]
) )
else:
rec.exceptions_summary = False
@api.multi
def _popup_exceptions(self): def _popup_exceptions(self):
action = self._get_popup_action().read()[0] action = self._get_popup_action().read()[0]
action.update( action.update(
@ -256,7 +249,6 @@ class BaseException(models.AbstractModel):
def _get_popup_action(self): def _get_popup_action(self):
return self.env.ref("base_exception.action_exception_rule_confirm") return self.env.ref("base_exception.action_exception_rule_confirm")
@api.multi
def _check_exception(self): def _check_exception(self):
""" """
This method must be used in a constraint that must be created in the This method must be used in a constraint that must be created in the

View File

@ -7,3 +7,7 @@
* Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com> * Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
* Raphaël Reverdy <raphael.reverdy@akretion.com> * Raphaël Reverdy <raphael.reverdy@akretion.com>
* Iván Todorovich <ivan.todorovich@druidoo.io> * Iván Todorovich <ivan.todorovich@druidoo.io>
* Tecnativa <tecnativa.com>
* João Marques

View File

@ -1,9 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<odoo> <odoo>
<record id="group_exception_rule_manager" model="res.groups"> <record id="group_exception_rule_manager" model="res.groups">
<field name="name">Exception manager</field> <field name="name">Exception manager</field>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/> <field name="implied_ids" eval="[(4, ref('base.group_user'))]" />
</record> </record>
</odoo> </odoo>

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! 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/server-tools/tree/12.0/base_exception"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-12-0/server-tools-12-0-base_exception"><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/149/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <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/server-tools/tree/13.0/base_exception"><img alt="OCA/server-tools" src="https://img.shields.io/badge/github-OCA%2Fserver--tools-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/server-tools-13-0/server-tools-13-0-base_exception"><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/149/13.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module provide an abstract model to manage customizable <p>This module provide an abstract model to manage customizable
exceptions to be applied on different models (sale order, invoice, …).</p> exceptions to be applied on different models (sale order, invoice, …).</p>
<p>It is not useful for itself. You can see an example of implementation <p>It is not useful for itself. You can see an example of implementation
@ -396,7 +396,7 @@ in the sale_exception module. (sale-workflow repository) or
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-tools/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_exception%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/server-tools/issues/new?body=module:%20base_exception%0Aversion:%2013.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> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -421,6 +421,10 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Mourad EL HADJ MIMOUNE &lt;<a class="reference external" href="mailto:mourad.elhadj.mimoune&#64;akretion.com">mourad.elhadj.mimoune&#64;akretion.com</a>&gt;</li> <li>Mourad EL HADJ MIMOUNE &lt;<a class="reference external" href="mailto:mourad.elhadj.mimoune&#64;akretion.com">mourad.elhadj.mimoune&#64;akretion.com</a>&gt;</li>
<li>Raphaël Reverdy &lt;<a class="reference external" href="mailto:raphael.reverdy&#64;akretion.com">raphael.reverdy&#64;akretion.com</a>&gt;</li> <li>Raphaël Reverdy &lt;<a class="reference external" href="mailto:raphael.reverdy&#64;akretion.com">raphael.reverdy&#64;akretion.com</a>&gt;</li>
<li>Iván Todorovich &lt;<a class="reference external" href="mailto:ivan.todorovich&#64;druidoo.io">ivan.todorovich&#64;druidoo.io</a>&gt;</li> <li>Iván Todorovich &lt;<a class="reference external" href="mailto:ivan.todorovich&#64;druidoo.io">ivan.todorovich&#64;druidoo.io</a>&gt;</li>
<li>Tecnativa &lt;tecnativa.com&gt;<ul>
<li>João Marques</li>
</ul>
</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@ -430,7 +434,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/12.0/base_exception">OCA/server-tools</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-tools/tree/13.0/base_exception">OCA/server-tools</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> <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> </div>

View File

@ -1,4 +1,5 @@
# Copyright 2017 ACSONE SA/NV (<http://acsone.eu>) # Copyright 2017 ACSONE SA/NV (<http://acsone.eu>)
# Copyright 2020 Hibou Corp.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

View File

@ -1,4 +1,5 @@
# Copyright 2016 Akretion Mourad EL HADJ MIMOUNE # Copyright 2016 Akretion Mourad EL HADJ MIMOUNE
# Copyright 2020 Hibou Corp.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models from odoo import api, fields, models
@ -28,37 +29,32 @@ class PurchaseTest(models.Model):
amount_total = fields.Float(compute="_compute_amount_total", store=True) amount_total = fields.Float(compute="_compute_amount_total", store=True)
@api.depends("line_ids") @api.depends("line_ids")
def _compute_amount_total(cls): def _compute_amount_total(self):
for record in cls: for record in self:
for line in record.line_ids: for line in record.line_ids:
record.amount_total += line.amount * line.qty record.amount_total += line.amount * line.qty
@api.constrains("ignore_exception", "line_ids", "state") @api.constrains("ignore_exception", "line_ids", "state")
def test_purchase_check_exception(cls): def test_purchase_check_exception(self):
orders = cls.filtered(lambda s: s.state == "purchase") orders = self.filtered(lambda s: s.state == "purchase")
if orders: if orders:
orders._check_exception() orders._check_exception()
@api.multi def button_approve(self, force=False):
def button_approve(cls, force=False): self.write({"state": "to approve"})
cls.write({"state": "to approve"})
return {} return {}
@api.multi def button_draft(self):
def button_draft(cls): self.write({"state": "draft"})
cls.write({"state": "draft"})
return {} return {}
@api.multi def button_confirm(self):
def button_confirm(cls): self.write({"state": "purchase"})
cls.write({"state": "purchase"})
return True return True
@api.multi def button_cancel(self):
def button_cancel(cls): self.write({"state": "cancel"})
cls.write({"state": "cancel"})
@api.multi
def _reverse_field(self): def _reverse_field(self):
return "test_purchase_ids" return "test_purchase_ids"

View File

@ -1,4 +1,5 @@
# Copyright 2016 Akretion Mourad EL HADJ MIMOUNE # Copyright 2016 Akretion Mourad EL HADJ MIMOUNE
# Copyright 2020 Hibou Corp.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import logging import logging

View File

@ -1,60 +1,86 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<odoo> <odoo>
<record id="view_exception_rule_tree" model="ir.ui.view"> <record id="view_exception_rule_tree" model="ir.ui.view">
<field name="name">exception.rule.tree</field> <field name="name">exception.rule.tree</field>
<field name="model">exception.rule</field> <field name="model">exception.rule</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Exception Rule"> <tree string="Exception Rule">
<field name="sequence" widget="handle"/> <field name="sequence" widget="handle" />
<field name="name"/> <field name="name" />
<field name="description"/> <field name="description" />
<field name="model"/> <field name="model" />
<field name="active" widget="boolean_toggle"/> <field name="active" widget="boolean_toggle" />
</tree> </tree>
</field> </field>
</record> </record>
<record id="view_exception_rule_form" model="ir.ui.view"> <record id="view_exception_rule_form" model="ir.ui.view">
<field name="name">exception.rule.form</field> <field name="name">exception.rule.form</field>
<field name="model">exception.rule</field> <field name="model">exception.rule</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Exception Rule Setup" name="exception_rule"> <form string="Exception Rule Setup" name="exception_rule">
<sheet> <sheet>
<widget
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
/>
<div class="oe_button_box" name="button_box"> <div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object" class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"/>
</button>
</div> </div>
<div class="oe_title"> <div class="oe_title">
<label for="name" class="oe_edit_only"/> <label for="name" class="oe_edit_only" />
<h1><field name="name"/></h1> <h1>
<field name="name" />
</h1>
</div> </div>
<group> <group>
<group> <group>
<field name="description"/> <field name="active" invisible="1" />
<field name="description" />
</group> </group>
</group> </group>
<group> <group>
<group colspan="4" groups="base.group_system"> <group colspan="4" groups="base.group_system">
<field name="model"/> <field name="model" />
<field name="exception_type" widget="radio"/> <field name="exception_type" widget="radio" />
<field name="domain" attrs="{'invisible': [('exception_type','!=','by_domain')], 'required': [('exception_type','=','by_domain')]}"/> <field
name="domain"
attrs="{'invisible': [('exception_type','!=','by_domain')], 'required': [('exception_type','=','by_domain')]}"
widget="domain"
options="{'model': 'model'}"
/>
</group> </group>
</group> </group>
<notebook> <notebook>
<page name="code" string="Python Code" attrs="{'invisible': [('exception_type','!=','by_py_code')], 'required': [('exception_type','=','by_py_code')]}"> <page
<field name="code" widget="ace" options="{'mode': 'python'}" placeholder="Enter Python code here. Help about Python expression is available in the help tab of this document."/> name="code"
string="Python Code"
attrs="{'invisible': [('exception_type','!=','by_py_code')], 'required': [('exception_type','=','by_py_code')]}"
>
<field
name="code"
widget="ace"
options="{'mode': 'python'}"
placeholder="Enter Python code here. Help about Python expression is available in the help tab of this document."
/>
</page> </page>
<page name="help" string="Help" attrs="{'invisible': [('exception_type','!=','by_py_code')]}"> <page
name="help"
string="Help"
attrs="{'invisible': [('exception_type','!=','by_py_code')]}"
>
<group> <group>
<div style="margin-top: 4px;"> <div style="margin-top: 4px;">
<h3>Help with Python expressions</h3> <h3>Help with Python expressions</h3>
<p>Various fields may use Python code or Python expressions. The following variables can be used:</p> <p
>Various fields may use Python code or Python expressions. The following variables can be used:</p>
<ul> <ul>
<li><code>self</code>: Record on which the rule is evaluated.</li> <li><code
<li><code>time</code>: useful Python libraries</li> >self</code>: Record on which the rule is evaluated.</li>
<li>To block the exception use: <code>failed = True</code></li> <li><code
>time</code>: useful Python libraries</li>
<li>To block the exception use: <code
>failed = True</code></li>
</ul> </ul>
</div> </div>
</group> </group>
@ -64,16 +90,13 @@
</form> </form>
</field> </field>
</record> </record>
<record id="action_exception_rule_tree" model="ir.actions.act_window"> <record id="action_exception_rule_tree" model="ir.actions.act_window">
<field name="name">Exception Rules</field> <field name="name">Exception Rules</field>
<field name="res_model">exception.rule</field> <field name="res_model">exception.rule</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
<field name="view_id" ref="view_exception_rule_tree"/> <field name="view_id" ref="view_exception_rule_tree" />
<field name="context">{'active_test': False}</field> <field name="context">{'active_test': False}</field>
</record> </record>
<menuitem <menuitem
action="action_exception_rule_tree" action="action_exception_rule_tree"
id="menu_action_exception" id="menu_action_exception"
@ -81,5 +104,4 @@
sequence="90" sequence="90"
groups="base_exception.group_exception_rule_manager" groups="base_exception.group_exception_rule_manager"
/> />
</odoo> </odoo>

View File

@ -1,6 +1,7 @@
# Copyright 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis # Copyright 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis
# Copyright 2017 Akretion (http://www.akretion.com) # Copyright 2017 Akretion (http://www.akretion.com)
# Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com> # Mourad EL HADJ MIMOUNE <mourad.elhadj.mimoune@akretion.com>
# Copyright 2020 Hibou Corp.
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models from odoo import _, api, fields, models
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
@ -18,7 +19,7 @@ class ExceptionRuleConfirm(models.AbstractModel):
@api.model @api.model
def default_get(self, field_list): def default_get(self, field_list):
res = super(ExceptionRuleConfirm, self).default_get(field_list) res = super().default_get(field_list)
current_model = self.env.context.get("active_model") current_model = self.env.context.get("active_model")
model_except_obj = self.env[current_model] model_except_obj = self.env[current_model]
active_ids = self.env.context.get("active_ids") active_ids = self.env.context.get("active_ids")
@ -31,7 +32,6 @@ class ExceptionRuleConfirm(models.AbstractModel):
res.update({"related_model_id": active_id}) res.update({"related_model_id": active_id})
return res return res
@api.multi
def action_confirm(self): def action_confirm(self):
self.ensure_one() self.ensure_one()
return {"type": "ir.actions.act_window_close"} return {"type": "ir.actions.act_window_close"}

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8" ?>
<odoo> <odoo>
<record id="view_exception_rule_confirm" model="ir.ui.view"> <record id="view_exception_rule_confirm" model="ir.ui.view">
<field name="name">Exceptions Rules</field> <field name="name">Exceptions Rules</field>
<field name="model">exception.rule.confirm</field> <field name="model">exception.rule.confirm</field>
@ -9,31 +8,36 @@
<group> <group>
<field name="exception_ids" nolabel="1" colspan="4"> <field name="exception_ids" nolabel="1" colspan="4">
<tree string="Exceptions Rules"> <tree string="Exceptions Rules">
<field name="name"/> <field name="name" />
<field name="description"/> <field name="description" />
</tree> </tree>
</field> </field>
<newline/> <newline />
</group> </group>
<group> <group>
<field name="ignore" groups='base_exception.group_exception_rule_manager'/> <field
name="ignore"
groups='base_exception.group_exception_rule_manager'
/>
</group> </group>
<footer> <footer>
<button name="action_confirm" string="_Close" <button
colspan="1" type="object" class="btn-primary"/> name="action_confirm"
string="_Close"
colspan="1"
type="object"
class="btn-primary"
/>
</footer> </footer>
</form> </form>
</field> </field>
</record> </record>
<record id="action_exception_rule_confirm" model="ir.actions.act_window"> <record id="action_exception_rule_confirm" model="ir.actions.act_window">
<field name="name">Outstanding exceptions to manage</field> <field name="name">Outstanding exceptions to manage</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">exception.rule.confirm</field> <field name="res_model">exception.rule.confirm</field>
<field name="view_type">form</field>
<field name="view_mode">form</field> <field name="view_mode">form</field>
<field name="view_id" ref="view_exception_rule_confirm"/> <field name="view_id" ref="view_exception_rule_confirm" />
<field name="target">new</field> <field name="target">new</field>
</record> </record>
</odoo> </odoo>