Files
odoo_source/addons/hr_expense/models/res_config.py
T
Yannick Tivisse 920b791ac5 [FIX] hr_employee: Don't create expenses from every email address
This is simply useless and the open door to spam. The inital goal for this
option was to be able to create an expense from any email in the onboarding.
It was even commented with 'Don't use this in production' which is another
point to remove it.

It is wrong because:
- In a saas instance, the employee email = the admin email = the email you
  entered while filling the form. So, if the user sends an email with his phone,
  the expense will be created. If the user sends an email with another email address
  then the expense won't be created but he'll receive an automated email explaining
  that he should register his email address either on it's user information or on it's
  employee information (professional on employee, private on user for example).
- With this modified behavior, if no email address is matching the sender email address
  the system will create an expense with the-first-employee-linked-to-an-user as employee,
  which is totally wrong. Furthermore, the guy that sent the email will not see the created
  expense because it hasn't been assigned to him.
- Everyone can create expenses, I don't even imagine how fast we can overload the database
  with a huge pile of crap
2016-08-25 14:55:08 +02:00

21 lines
768 B
Python

# -*- coding: utf-8 -*-
from odoo import api, fields, models
class HrExpenseConfigSettings(models.TransientModel):
_name = 'hr.expense.config.settings'
_inherit = 'res.config.settings'
alias_prefix = fields.Char('Default Alias Name for Expenses')
alias_domain = fields.Char('Alias Domain', default=lambda self: self.env["ir.config_parameter"].get_param("mail.catchall.domain"))
@api.model
def get_default_alias_prefix(self, fields):
alias_name = self.env.ref('hr_expense.mail_alias_expense').alias_name
return {'alias_prefix': alias_name}
@api.multi
def set_default_alias_prefix(self):
for record in self:
self.env.ref('hr_expense.mail_alias_expense').write({'alias_name': record.alias_prefix})