# -*- coding: utf-8 -*-
##############################################################################
#
#    datenpol gmbh
#    Copyright (C) 2013-TODAY datenpol gmbh ()
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as
#    published by the Free Software Foundation, either version 3 of the
#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see .
#
##############################################################################
from odoo import models, api, _
from odoo.exceptions import ValidationError
class AbstractHelper(models.AbstractModel):
    _name = 'dp_custom.helper'
    _description = 'Abstract Helper'
    @api.model
    def check_not_specified_fields(self, vals):
        specified_fields = self._get_specified_fields()
        invalid_keys = []
        for key in vals.keys():
            if key not in specified_fields:
                invalid_keys.append(key)
        if invalid_keys:
            raise ValidationError(
                _('Es befinden sich unerlaubte Felder in Ihrem Aufruf. Bitte entfernen Sie diese: '+';'.join(invalid_keys)))
        return vals
    @api.model
    def correct_values(self, vals):
        return vals
    @api.model
    def _get_specified_fields(self):
        raise ValidationError(
            _('Method \'%s\' isn\'t Implemented in model \'%s\'') % (self._get_specified_fields.__name__, self._name))