Browse Source

[10][FIX] Protect crash at runtime if oca-decorator not installed (#254)

Fail silently if @foreach not loaded
pull/266/merge
Hpar 7 years ago
committed by Pedro M. Baeza
parent
commit
9c9683ebb0
  1. 7
      pos_pricelist/__init__.py
  2. 6
      pos_pricelist/models/pos_config.py

7
pos_pricelist/__init__.py

@ -2,4 +2,9 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from .hooks import post_init_hook from .hooks import post_init_hook
from . import models
try:
from . import models
except ImportError: # pragma: no-cover
import logging
_logger = logging.getLogger(__name__)
_logger.warn("Missing dependency", exc_info=True)

6
pos_pricelist/models/pos_config.py

@ -4,15 +4,11 @@
from odoo import _, api, fields, models from odoo import _, api, fields, models
from odoo.exceptions import ValidationError from odoo.exceptions import ValidationError
from oca.decorators import foreach # pylint: disable=W7935
import logging import logging
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
try:
from oca.decorators import foreach
except ImportError: # pragma: no-cover
_logger.warn("Missing dependency", exc_info=True)
class PosConfig(models.Model): class PosConfig(models.Model):
_inherit = 'pos.config' _inherit = 'pos.config'

Loading…
Cancel
Save