mirror of
https://github.com/OCA/intrastat-extrastat.git
synced 2025-02-16 17:13:41 +02:00
57 lines
2.3 KiB
Python
57 lines
2.3 KiB
Python
# -*- encoding: utf-8 -*-
|
|
##############################################################################
|
|
#
|
|
# Intrastat base module for Odoo
|
|
# Copyright (C) 2013-2014 Akretion (http://www.akretion.com)
|
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
|
#
|
|
# 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 openerp import models, fields, api, _
|
|
from openerp.exceptions import ValidationError
|
|
|
|
|
|
class ResCompany(models.Model):
|
|
_inherit = "res.company"
|
|
|
|
intrastat_remind_user_ids = fields.Many2many(
|
|
'res.users', column1='company_id', column2='user_id',
|
|
string="Users Receiving the Intrastat Reminder",
|
|
help="List of OpenERP users who will receive a notification to "
|
|
"remind them about the Intrastat declaration.")
|
|
intrastat_email_list = fields.Char(
|
|
compute='_compute_intrastat_email_list',
|
|
string='List of emails of Users Receiving the Intrastat Reminder')
|
|
|
|
@api.one
|
|
@api.depends(
|
|
'intrastat_remind_user_ids', 'intrastat_remind_user_ids.email')
|
|
def _compute_intrastat_email_list(self):
|
|
emails = []
|
|
for user in self.intrastat_remind_user_ids:
|
|
if user.email:
|
|
emails.append(user.email)
|
|
self.intrastat_email_list = ','.join(emails)
|
|
|
|
@api.one
|
|
@api.constrains('intrastat_remind_user_ids')
|
|
def _check_intrastat_remind_users(self):
|
|
for user in self.intrastat_remind_user_ids:
|
|
if not user.email:
|
|
raise ValidationError(
|
|
_("Missing e-mail address on user '%s'.")
|
|
% (user.name))
|