From 1bf327d9854044f285ef6c95bd13e980ad7e5f97 Mon Sep 17 00:00:00 2001 From: Yannick Tivisse Date: Thu, 18 Aug 2016 10:03:53 +0200 Subject: [PATCH 1/4] [IMP] hr_expense: Reorganize menuitems usability wise --- addons/hr_expense/views/hr_expense_views.xml | 110 +++++++------------ 1 file changed, 38 insertions(+), 72 deletions(-) diff --git a/addons/hr_expense/views/hr_expense_views.xml b/addons/hr_expense/views/hr_expense_views.xml index 830e87fb3a7..c17198405d4 100644 --- a/addons/hr_expense/views/hr_expense_views.xml +++ b/addons/hr_expense/views/hr_expense_views.xml @@ -1,5 +1,6 @@ + hr.expense.tree hr.expense @@ -187,7 +188,7 @@ All Expenses hr.expense - tree,kanban,form,graph,pivot + pivot,graph,tree,kanban,form

@@ -204,26 +205,6 @@ - - My Expenses - hr.expense - tree,kanban,form,graph,pivot - - [('employee_id.user_id', '=', uid)] - {'show_report': True} - -

- The steps to process expenses are: -

    -
  1. You record expenses,
  2. -
  3. Periodically, you submit expenses report to your manager,
  4. -
  5. Once approved, your expense report, goes to the accounting,
  6. -
  7. The accountant validates entries and reimburse you.
  8. -
-

-
-
- My Expenses to Report hr.expense @@ -244,25 +225,24 @@ - - - tree - - - - - - - kanban - - - - - - - form - - + + Refused Expenses + hr.expense + tree,kanban,form,graph,pivot + + [('employee_id.user_id', '=', uid)] + {'search_default_refused': 1} + +

+ The steps to process expenses are: +

    +
  1. You record expenses,
  2. +
  3. Periodically, you submit expenses report to your manager,
  4. +
  5. Once approved, your expense report, goes to the accounting,
  6. +
  7. The accountant validates entries and reimburse you.
  8. +
+

+
@@ -578,6 +558,7 @@ + @@ -585,22 +566,6 @@
- - My Reports - hr.expense.sheet - tree,kanban,form,pivot,graph - - [('employee_id.user_id', '=', uid)] - {'search_default_submitted': 1} - -

- Click here to create a new expense report. -

- Once you have created your expense, submit it to your manager who will validate it. -

-
-
- My Reports hr.expense.sheet @@ -668,7 +633,7 @@ My Reports hr.expense.sheet - tree,kanban,form,pivot,graph + pivot,graph,tree,kanban,form [] {} @@ -778,23 +743,24 @@ - - - + + + + - - + + + + + + - - - - - - + + Date: Thu, 18 Aug 2016 10:25:18 +0200 Subject: [PATCH 2/4] [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 --- addons/hr_expense/models/hr_expense.py | 6 ------ addons/hr_expense/models/res_config.py | 15 --------------- addons/hr_expense/views/res_config_views.xml | 1 - 3 files changed, 22 deletions(-) diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py index 87273168687..5ce0b3edfe9 100644 --- a/addons/hr_expense/models/hr_expense.py +++ b/addons/hr_expense/models/hr_expense.py @@ -289,7 +289,6 @@ class HrExpense(models.Model): def message_new(self, msg_dict, custom_values=None): if custom_values is None: custom_values = {} - # Retrieve the email address from the email field. The string is constructed like # 'foo '. We will extract 'bar' from this email_address = email_split(msg_dict.get('email_from', False))[0] @@ -300,11 +299,6 @@ class HrExpense(models.Model): employee = self.env['hr.employee'].search([('work_email', 'ilike', email_address)], limit=1) if not employee: employee = self.env['hr.employee'].search([('user_id.email', 'ilike', email_address)], limit=1) - if not employee: - access = self.env['ir.config_parameter'].get_param("hr_expense.email.gateway") or 'open' - if access == 'open': - # Open access is mostly used during the on boarding flow, should not be used in production - employee = self.env['hr.employee'].search([('user_id','<>',False)], limit=1) if not employee: # Send back an email to explain why the expense has not been created mail_template = self.env.ref('hr_expense.mail_template_data_expense_unknown_email_address') diff --git a/addons/hr_expense/models/res_config.py b/addons/hr_expense/models/res_config.py index 71bc01b0861..c1eda4f459b 100644 --- a/addons/hr_expense/models/res_config.py +++ b/addons/hr_expense/models/res_config.py @@ -1,29 +1,14 @@ # -*- coding: utf-8 -*- from odoo import api, fields, models -from openerp import SUPERUSER_ID class HrExpenseConfigSettings(models.TransientModel): _name = 'hr.expense.config.settings' _inherit = 'res.config.settings' - alias_expense_open = fields.Selection([ - ('open', "Accept expenses from any email address"), - ('restricted', "Accept expenses from employee email addresses only") - ], "Mail Gateway") - 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_expense_open(self, fields): - return {'alias_expense_open': self.env['ir.config_parameter'].get_param("hr_expense.email.gateway") or 'open'} - - @api.multi - def set_default_alias_expense_open(self): - self.env['ir.config_parameter'].set_param("hr_expense.email.gateway", self.alias_expense_open) - return True - @api.model def get_default_alias_prefix(self, fields): alias_name = self.env.ref('hr_expense.mail_alias_expense').alias_name diff --git a/addons/hr_expense/views/res_config_views.xml b/addons/hr_expense/views/res_config_views.xml index fc18857f12d..81befec69cd 100644 --- a/addons/hr_expense/views/res_config_views.xml +++ b/addons/hr_expense/views/res_config_views.xml @@ -12,7 +12,6 @@