48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
##############################################################################
|
|
#
|
|
# datenpol gmbh
|
|
# Copyright (C) 2013-TODAY datenpol gmbh (<http://www.datenpol.at/>)
|
|
#
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
#
|
|
##############################################################################
|
|
from odoo import models, api, _
|
|
from odoo.exceptions import ValidationError
|
|
|
|
|
|
class AbstractHelper(models.AbstractModel):
|
|
_name = 'dp_custom.helper'
|
|
_description = 'Abstract Helper'
|
|
|
|
@api.model
|
|
def remove_not_specified_fields(self, vals):
|
|
specified_fields = self._get_specified_fields()
|
|
remove_fields = []
|
|
for key in list(vals.keys()):
|
|
if key not in specified_fields:
|
|
remove_fields.append(key)
|
|
for key in remove_fields:
|
|
del vals[key]
|
|
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))
|