[14.0][MIG] base_exception: Migration to 14.0

pull/2463/head
Kevin Khao 2020-11-24 15:36:41 +01:00 committed by matiasperalta1
parent 240cb3f301
commit 9c114a9451
8 changed files with 19 additions and 64 deletions

View File

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

View File

@ -4,7 +4,7 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
@ -18,11 +18,6 @@ msgstr ""
msgid "<code>self</code>: Record on which the rule is evaluated."
msgstr ""
#. module: base_exception
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_form
msgid "<code>time</code>: useful Python libraries"
msgstr ""
#. module: base_exception
#: model:ir.model.fields,field_description:base_exception.field_exception_rule__active
msgid "Active"
@ -38,6 +33,11 @@ msgstr ""
msgid "Archived"
msgstr ""
#. module: base_exception
#: model_terms:ir.ui.view,arch_db:base_exception.view_exception_rule_form
msgid "As well as all the libraries provided in safe_eval."
msgstr ""
#. module: base_exception
#: model:ir.model.fields.selection,name:base_exception.selection__exception_rule__exception_type__by_domain
msgid "By domain"
@ -56,38 +56,6 @@ msgid ""
" performance can be better when exceptions are evaluated with several records"
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"
@ -303,14 +271,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

@ -5,7 +5,6 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import html
import time
from odoo import _, api, fields, models, osv
from odoo.exceptions import UserError, ValidationError
@ -131,15 +130,9 @@ class BaseExceptionMethod(models.AbstractModel):
@api.model
def _exception_rule_eval_context(self, rec):
return {
"time": time,
"self": rec,
# object, obj: deprecated.
# should be removed in future migrations
"object": rec,
"obj": rec,
# copy context to prevent side-effects of eval
# should be deprecated too, accesible through self.
"context": self.env.context.copy(),
}
@api.model

View File

@ -11,3 +11,5 @@
* Tecnativa <tecnativa.com>
* João Marques
* Kevin Khao <kevin.khao@akretion.com>

View File

@ -1,6 +1,6 @@
This module provide an abstract model to manage customizable
exceptions to be applied on different models (sale order, invoice, ...).
It is not useful for itself. You can see an example of implementation
It is not useful by itself. You can see an example of implementation
in the 'sale_exception' module. (sale-workflow repository) or
'purchase_exception' module (purchase-workflow repository).

View File

@ -1,3 +1,3 @@
Terms used in old api like `pool`, `cr`, `uid` must be removed porting this module in version 12.
This module execute user provided code though a safe_eval, it's unsecure? How mitigate risks should be adressed in future versions of this module.
This module executes user-provided code though a safe_eval which might be
unsecure.
How to mitigate risks should be adressed in future versions of this module.

View File

@ -14,8 +14,7 @@ from .purchase_test import LineTest, PurchaseTest
_logger = logging.getLogger(__name__)
@common.at_install(False)
@common.post_install(True)
@common.tagged("post_install", "-at_install")
class TestBaseException(common.SavepointCase):
@classmethod
def setUpClass(cls):
@ -27,6 +26,7 @@ class TestBaseException(common.SavepointCase):
if "test_purchase_ids" not in cls.exception_rule._fields:
field = fields.Many2many("base.exception.test.purchase")
cls.exception_rule._add_field("test_purchase_ids", field)
cls.exception_rule._fields["test_purchase_ids"].depends_context = None
cls.exception_confirm = cls.env["exception.rule.confirm"]
cls.exception_rule._fields["model"].selection.append(
("base.exception.test.purchase", "Purchase Order")
@ -41,7 +41,7 @@ class TestBaseException(common.SavepointCase):
"name": "No ZIP code on destination",
"sequence": 10,
"model": "base.exception.test.purchase",
"code": "if not obj.partner_id.zip: failed=True",
"code": "if not self.partner_id.zip: failed=True",
}
)
@ -50,7 +50,7 @@ class TestBaseException(common.SavepointCase):
"name": "Min order except",
"sequence": 10,
"model": "base.exception.test.purchase",
"code": "if obj.amount_total <= 200.0: failed=True",
"code": "if self.amount_total <= 200.0: failed=True",
}
)

View File

@ -77,11 +77,11 @@
<ul>
<li><code
>self</code>: Record on which the rule is evaluated.</li>
<li><code
>time</code>: useful Python libraries</li>
<li>To block the exception use: <code
>failed = True</code></li>
</ul>
<p
>As well as all the libraries provided in safe_eval.</p>
</div>
</group>
</page>