[MIG] base_exception: Migration to 15.0

pull/2463/head
Cesar Andres Sanchez 2022-06-29 00:04:00 +02:00 committed by matiasperalta1
parent 15f1c01227
commit 9810c79870
7 changed files with 79 additions and 212 deletions

View File

@ -5,7 +5,8 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
"name": "Exception Rule",
"version": "14.0.2.1.0",
"version": "15.0.1.0.0",
"development_status": "Mature",
"category": "Generic Modules",
"summary": """
This module provide an abstract model to manage customizable

View File

@ -4,8 +4,10 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-28 22:06+0000\n"
"PO-Revision-Date: 2022-06-28 22:06+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -68,38 +70,6 @@ msgid ""
"By method: allow to select an existing check method"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__changeset_change_ids
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__changeset_change_ids
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__changeset_change_ids
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__changeset_change_ids
msgid "Changeset Changes"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__changeset_ids
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__changeset_ids
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__changeset_ids
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__changeset_ids
msgid "Changesets"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__count_pending_changeset_changes
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__count_pending_changeset_changes
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__count_pending_changeset_changes
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__count_pending_changeset_changes
msgid "Count Pending Changeset Changes"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__count_pending_changesets
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__count_pending_changesets
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__count_pending_changesets
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__count_pending_changesets
msgid "Count Pending Changesets"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__create_uid
msgid "Created by"
@ -116,10 +86,7 @@ msgid "Description"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__display_name
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__display_name
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__display_name
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__display_name
msgid "Display Name"
msgstr ""
@ -140,8 +107,8 @@ msgstr ""
#, python-format
msgid ""
"Error when evaluating the exception.rule rule:\n"
" %s \n"
"(%s)"
" %(rule_name)s \n"
"(%(error)s)"
msgstr ""
#. module: base_exception
@ -156,7 +123,6 @@ msgstr ""
#. module: base_exception
#: model:ir.model,name:base_exception.model_exception_rule
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_tree
msgid "Exception Rule"
msgstr ""
@ -196,11 +162,6 @@ msgstr ""
msgid "Exceptions"
msgstr ""
#. module: base_exception
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_confirm
msgid "Exceptions Rules"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__exceptions_summary
msgid "Exceptions Summary"
@ -227,10 +188,7 @@ msgid "Help with Python expressions"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__id
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__id
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__id
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__id
msgid "ID"
msgstr ""
@ -242,14 +200,11 @@ msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__is_blocking
msgid "Is blocking"
msgid "Is Blocking"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception____last_update
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method____last_update
#: model:ir.model.fields,field_description:base_exception.field_exception_rule____last_update
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm____last_update
msgid "Last Modified on"
msgstr ""
@ -312,14 +267,6 @@ msgstr ""
msgid "Sequence"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__smart_search
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__smart_search
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__smart_search
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__smart_search
msgid "Smart Search"
msgstr ""
#. module: base_exception
#: code:addons/base_exception/models/base_exception.py:0
#, python-format
@ -339,14 +286,6 @@ msgstr ""
msgid "To block the exception use: <code>failed = True</code>"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__user_can_see_changeset
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__user_can_see_changeset
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__user_can_see_changeset
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__user_can_see_changeset
msgid "User Can See Changeset"
msgstr ""
#. module: base_exception
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_form
msgid ""

View File

@ -2,22 +2,18 @@
# This file contains the translation of the following modules:
# * base_exception
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2017
# enjolras <yo@miguelrevilla.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-03-03 10:08+0000\n"
"PO-Revision-Date: 2018-03-03 10:08+0000\n"
"Last-Translator: enjolras <yo@miguelrevilla.com>, 2018\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"Language: es\n"
"POT-Creation-Date: 2022-06-28 22:06+0000\n"
"PO-Revision-Date: 2022-06-28 22:06+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Plural-Forms: \n"
#. module: base_exception
#: code:addons/base_exception/models/base_exception.py:0
@ -62,7 +58,6 @@ msgstr ""
#. module: base_exception
#: model:ir.model.fields.selection,name:base_exception.selection__exception_rule__exception_type__by_py_code
#, fuzzy
msgid "By python code"
msgstr "Código python"
@ -71,43 +66,10 @@ msgstr "Código python"
msgid ""
"By python code: allow to define any arbitrary check\n"
"By domain: limited to a selection by an odoo domain:\n"
" performance can be better when exceptions are evaluated "
"with several records\n"
" performance can be better when exceptions are evaluated with several records\n"
"By method: allow to select an existing check method"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__changeset_change_ids
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__changeset_change_ids
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__changeset_change_ids
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__changeset_change_ids
msgid "Changeset Changes"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__changeset_ids
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__changeset_ids
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__changeset_ids
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__changeset_ids
msgid "Changesets"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__count_pending_changeset_changes
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__count_pending_changeset_changes
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__count_pending_changeset_changes
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__count_pending_changeset_changes
msgid "Count Pending Changeset Changes"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__count_pending_changesets
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__count_pending_changesets
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__count_pending_changesets
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__count_pending_changesets
msgid "Count Pending Changesets"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__create_uid
msgid "Created by"
@ -124,10 +86,7 @@ msgid "Description"
msgstr "Descripción"
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__display_name
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__display_name
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__display_name
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__display_name
msgid "Display Name"
msgstr "Nombre a mostrar"
@ -145,19 +104,15 @@ msgstr ""
#. module: base_exception
#: code:addons/base_exception/models/base_exception.py:0
#, fuzzy, python-format
#, python-format
msgid ""
"Error when evaluating the exception.rule rule:\n"
" %s \n"
"(%s)"
" %(rule_name)s \n"
"(%(error)s)"
msgstr ""
"Error al evaluar la regla exception.rule:\n"
"%s\n"
"(%s)"
#. module: base_exception
#: model:ir.model,name:base_exception.model_base_exception
#, fuzzy
msgid "Exception"
msgstr "Excepciones"
@ -168,19 +123,16 @@ msgstr "Nombre de la excepción"
#. module: base_exception
#: model:ir.model,name:base_exception.model_exception_rule
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_tree
msgid "Exception Rule"
msgstr "Regla de excepción"
#. module: base_exception
#: model:ir.model,name:base_exception.model_exception_rule_confirm
#, fuzzy
msgid "Exception Rule Confirm Wizard"
msgstr "exception.rule.confirm"
#. module: base_exception
#: model:ir.model,name:base_exception.model_base_exception_method
#, fuzzy
msgid "Exception Rule Methods"
msgstr "Reglas de excepción"
@ -197,7 +149,6 @@ msgstr "Reglas de excepción"
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__exception_type
#, fuzzy
msgid "Exception Type"
msgstr "Nombre de la excepción"
@ -211,14 +162,8 @@ msgstr "Administrador de excepciones"
msgid "Exceptions"
msgstr "Excepciones"
#. module: base_exception
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_confirm
msgid "Exceptions Rules"
msgstr "Reglas de excepción"
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__exceptions_summary
#, fuzzy
msgid "Exceptions Summary"
msgstr "Administrador de excepciones"
@ -243,12 +188,9 @@ msgid "Help with Python expressions"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__id
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__id
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__id
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__id
msgid "ID"
msgstr "ID"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__ignore_exception
@ -258,14 +200,11 @@ msgstr "Ignorar excepciones"
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__is_blocking
msgid "Is blocking"
msgid "Is Blocking"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception____last_update
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method____last_update
#: model:ir.model.fields,field_description:base_exception.field_exception_rule____last_update
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm____last_update
msgid "Last Modified on"
msgstr "Última actualización por"
@ -287,7 +226,7 @@ msgstr "Excepción principal"
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__method
msgid "Method"
msgstr ""
msgstr "Método"
#. module: base_exception
#: code:addons/base_exception/wizard/base_exception_confirm.py:0
@ -298,12 +237,12 @@ msgstr ""
#. module: base_exception
#: model:ir.actions.act_window,name:base_exception.action_exception_rule_confirm
msgid "Outstanding exceptions to manage"
msgstr ""
msgstr "Excepciones pendientes de administrar"
#. module: base_exception
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_confirm
msgid "Outstanding exceptions to manager"
msgstr ""
msgstr "Excepciones pendientes al gestor"
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__code
@ -321,26 +260,18 @@ msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__related_model_id
msgid "Related Model"
msgstr ""
msgstr "Modelo relacionado"
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__sequence
msgid "Sequence"
msgstr "Secuencia"
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__smart_search
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__smart_search
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__smart_search
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__smart_search
msgid "Smart Search"
msgstr ""
#. module: base_exception
#: code:addons/base_exception/models/base_exception.py:0
#, python-format
msgid "The exceptions can not be ignored, because some of them are blocking."
msgstr ""
msgstr "Las excepciones no se pueden ignorar, porque algunas de ellas están bloqueando."
#. module: base_exception
#: code:addons/base_exception/models/base_exception.py:0
@ -348,43 +279,26 @@ msgstr ""
msgid ""
"There is a problem of configuration, python code, domain or method is "
"missing to match the exception type."
msgstr ""
msgstr "Hay un problema de configuración, código python, match exception type"
#. module: base_exception
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_form
msgid "To block the exception use: <code>failed = True</code>"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_base_exception__user_can_see_changeset
#: model:ir.model.fields,field_description:base_exception.field_base_exception_method__user_can_see_changeset
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__user_can_see_changeset
#: model:ir.model.fields,field_description:base_exception.field_exception_rule_confirm__user_can_see_changeset
msgid "User Can See Changeset"
msgstr ""
msgstr "Para bloquear el uso de excepción: <code>failed = True</code>"
#. module: base_exception
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_form
msgid ""
"Various fields may use Python code or Python expressions. The following "
"variables can be used:"
msgstr ""
msgstr "Varios campos pueden usar código de Python o expresiones de Python. A continuación se muestran las variables que pueden ser usadas."
#. module: base_exception
#: model:ir.model.fields,help:base_exception.field_exception_rule__is_blocking
msgid "When checked the exception can not be ignored"
msgstr ""
msgstr "Cuando está marcada, la excepción no se puede ignorar"
#. module: base_exception
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_confirm
msgid "_Close"
msgstr ""
#~ msgid "Next state"
#~ msgstr "Estado siguiente"
#~ msgid "Rule Group"
#~ msgstr "Grupo de reglas"
#~ msgid "base.exception"
#~ msgstr "base.exception"
msgstr "_Cerrar"

View File

@ -21,10 +21,8 @@ class ExceptionRule(models.Model):
_order = "active desc, sequence asc"
name = fields.Char("Exception Name", required=True, translate=True)
description = fields.Text("Description", translate=True)
sequence = fields.Integer(
string="Sequence", help="Gives the sequence order when applying the test"
)
description = fields.Text(translate=True)
sequence = fields.Integer(help="Gives the sequence order when applying the test")
model = fields.Selection(selection=[], string="Apply on", required=True)
exception_type = fields.Selection(
@ -33,7 +31,6 @@ class ExceptionRule(models.Model):
("by_py_code", "By python code"),
("by_method", "By method"),
],
string="Exception Type",
required=True,
default="by_py_code",
help="By python code: allow to define any arbitrary check\n"
@ -42,16 +39,15 @@ class ExceptionRule(models.Model):
" are evaluated with several records\n"
"By method: allow to select an existing check method",
)
domain = fields.Char("Domain")
method = fields.Selection(selection=[], string="Method", readonly=True)
active = fields.Boolean("Active", default=True)
domain = fields.Char()
method = fields.Selection(selection=[], readonly=True)
active = fields.Boolean(default=True)
code = fields.Text(
"Python Code",
help="Python code executed to check if the exception apply or "
"not. Use failed = True to block the exception",
)
is_blocking = fields.Boolean(
string="Is blocking",
help="When checked the exception can not be ignored",
)
@ -163,11 +159,11 @@ class BaseExceptionMethod(models.AbstractModel):
_logger.exception(e)
raise UserError(
_(
"Error when evaluating the exception.rule rule:\n %s \n(%s)",
rule.name,
e,
)
"Error when evaluating the exception.rule"
" rule:\n %(rule_name)s \n(%(error)s)"
)
% {"rule_name": rule.name, "error": e}
) from e
return space.get("failed", False)
def _detect_exceptions(self, rule):
@ -223,9 +219,7 @@ class BaseExceptionModel(models.AbstractModel):
string="Main Exception",
store=True,
)
exceptions_summary = fields.Html(
"Exceptions Summary", compute="_compute_exceptions_summary"
)
exceptions_summary = fields.Html(compute="_compute_exceptions_summary")
exception_ids = fields.Many2many("exception.rule", string="Exceptions", copy=False)
ignore_exception = fields.Boolean("Ignore Exceptions", copy=False)
@ -271,19 +265,6 @@ class BaseExceptionModel(models.AbstractModel):
else:
rec.exceptions_summary = False
def _popup_exceptions(self):
action = self._get_popup_action().sudo().read()[0]
action.update(
{
"context": {
"active_id": self.ids[0],
"active_ids": self.ids,
"active_model": self._name,
}
}
)
return action
@api.model
def _get_popup_action(self):
return self.env.ref("base_exception.action_exception_rule_confirm")

View File

@ -19,12 +19,10 @@ class TestBaseException(SavepointCase):
from .purchase_test import ExceptionRule, LineTest, PurchaseTest
cls.loader.update_registry((ExceptionRule, LineTest, PurchaseTest))
cls.partner = cls.env["res.partner"].create({"name": "Foo"})
cls.po = cls.env["base.exception.test.purchase"].create(
{
"name": "Test base exception to basic purchase",
"partner_id": cls.partner.id,
"partner_id": cls.env["res.partner"].create({"name": "Foo"}).id,
"line_ids": [
(0, 0, {"name": "line test", "amount": 120.0, "qty": 1.5})
],
@ -39,17 +37,29 @@ class TestBaseException(SavepointCase):
"exception_type": "by_py_code",
}
)
cls.exception_rule_confirm_obj = cls.env["exception.rule.confirm"]
cls.exception_rule_confirm = cls.exception_rule_confirm.create(
{
"related_model_id": cls.po.id,
"exception_ids": [(4, cls.exception_rule.id)],
"ignore": False,
}
)
@classmethod
def tearDownClass(cls):
cls.loader.restore_registry()
super().tearDownClass()
return super().tearDownClass()
def test_valid(self):
self.exception_rule.active = False
self.po.button_confirm()
self.assertFalse(self.po.exception_ids)
def test_exception_rule_confirm(self):
self.exception_rule_confirm.action_confirm()
self.assertFalse(self.exception_rule_confirm.exception_ids)
def test_fail_by_py(self):
with self.assertRaises(ValidationError):
self.po.button_confirm()
@ -90,6 +100,28 @@ class TestBaseException(SavepointCase):
self.po.button_confirm()
self.assertEqual(self.po.state, "purchase")
def test_purchase_check_exception(self):
self.po.test_purchase_check_exception()
def test_purchase_check_button_approve(self):
self.po.button_approve()
self.assertEqual(self.po.state, "to approve")
def test_purchase_check_button_draft(self):
self.po.button_draft()
self.assertEqual(self.po.state, "draft")
def test_purchase_check_button_confirm(self):
self.po.button_confirm()
self.assertEqual(self.po.state, "purchase")
def test_purchase_check_button_cancel(self):
self.po.button_cancel()
self.assertEqual(self.po.state, "cancel")
def test_detect_exceptions(self):
self.po.detect_exceptions()
def test_blocking_exception(self):
self.exception_rule.is_blocking = True
# Block because of exception during validation

View File

@ -4,7 +4,7 @@
<field name="name">exception.rule.tree</field>
<field name="model">exception.rule</field>
<field name="arch" type="xml">
<tree string="Exception Rule">
<tree>
<field name="sequence" widget="handle" />
<field name="name" />
<field name="description" />

View File

@ -7,7 +7,7 @@
<form string="Outstanding exceptions to manager" version="7.0">
<group>
<field name="exception_ids" nolabel="1" colspan="4">
<tree string="Exceptions Rules">
<tree>
<field name="name" />
<field name="description" />
</tree>