summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorfda-odoo <fda@odoo.com>2017-10-31 17:32:46 +0100
committerfda-odoo <fda@odoo.com>2018-01-25 15:51:57 +0100
commitab8f5ec95d41fdab501cb4c5b5b8e0218f337942 (patch)
tree1407dd68557cd88b8d6f272a70427c9aff8d8f30 /addons
parentf79b00c3b71e02f73537cb17285a6902fc0906b5 (diff)
[IMP] hr_expense: change tours text, labels, search field
- subscribe responsibles of an expense to followers of that expense - hr_expense requires sale_expense instead of sale_management - remove one tour step and change texts of some others - remove header from expense line wizard - add tax field in form view for expense - change the display name of some fields and other titles. - remove the expense report and improve search bar for expenses in report.
Diffstat (limited to 'addons')
-rw-r--r--addons/hr_expense/__manifest__.py2
-rw-r--r--addons/hr_expense/models/hr_expense.py20
-rw-r--r--addons/hr_expense/models/res_config_settings.py2
-rw-r--r--addons/hr_expense/static/src/js/tour.js11
-rw-r--r--addons/hr_expense/views/hr_expense_views.xml66
-rw-r--r--addons/hr_expense/views/res_config_settings_views.xml4
6 files changed, 60 insertions, 45 deletions
diff --git a/addons/hr_expense/__manifest__.py b/addons/hr_expense/__manifest__.py
index d1f3ab98f1d..ac6f28bc91e 100644
--- a/addons/hr_expense/__manifest__.py
+++ b/addons/hr_expense/__manifest__.py
@@ -3,7 +3,7 @@
{
- 'name': 'Expense Tracker',
+ 'name': 'Expenses',
'version': '2.0',
'category': 'Human Resources',
'sequence': 95,
diff --git a/addons/hr_expense/models/hr_expense.py b/addons/hr_expense/models/hr_expense.py
index d5b238664ac..e07c10f46ac 100644
--- a/addons/hr_expense/models/hr_expense.py
+++ b/addons/hr_expense/models/hr_expense.py
@@ -29,8 +29,8 @@ class HrExpense(models.Model):
def _default_account_id(self):
return self.env['ir.property'].get('property_account_expense_categ_id', 'product.category')
- name = fields.Char("Expense Description", readonly=True, required=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]})
- date = fields.Date("Expense Date", readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=fields.Date.context_today)
+ name = fields.Char(string='Description', readonly=True, required=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]})
+ date = fields.Date(readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=fields.Date.context_today, string="Date")
employee_id = fields.Many2one('hr.employee', string="Employee", required=True, readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=_default_employee_id)
product_id = fields.Many2one('product.product', string='Product', readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, domain=[('can_be_expensed', '=', True)], required=True)
product_uom_id = fields.Many2one('product.uom', string='Unit of Measure', required=True, readonly=True, states={'draft': [('readonly', False)], 'refused': [('readonly', False)]}, default=_default_product_uom_id)
@@ -49,8 +49,8 @@ class HrExpense(models.Model):
payment_mode = fields.Selection([
("own_account", "Employee (to reimburse)"),
("company_account", "Company")
- ], default='own_account', states={'done': [('readonly', True)], 'post': [('readonly', True)], 'submitted': [('readonly', True)]}, string="Payment By")
- attachment_number = fields.Integer("Number of Attachments", compute='_compute_attachment_number')
+ ], default='own_account', states={'done': [('readonly', True)], 'post': [('readonly', True)], 'submitted': [('readonly', True)]}, string="Paid By")
+ attachment_number = fields.Integer('Number of Attachments', compute='_compute_attachment_number')
state = fields.Selection([
('draft', 'To Submit'),
('reported', 'Reported'),
@@ -161,6 +161,7 @@ class HrExpense(models.Model):
if len(self.mapped('employee_id')) != 1:
raise UserError(_("You cannot report expenses for different employees in the same report!"))
return {
+ 'name': _('New Expense Report'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'hr.expense.sheet',
@@ -470,7 +471,7 @@ class HrExpenseSheet(models.Model):
], string='Status', index=True, readonly=True, track_visibility='onchange', copy=False, default='submit', required=True, help='Expense Report State')
employee_id = fields.Many2one('hr.employee', string="Employee", required=True, readonly=True, states={'submit': [('readonly', False)]}, default=lambda self: self.env['hr.employee'].search([('user_id', '=', self.env.uid)], limit=1))
address_id = fields.Many2one('res.partner', string="Employee Home Address")
- payment_mode = fields.Selection([("own_account", "Employee (to reimburse)"), ("company_account", "Company")], related='expense_line_ids.payment_mode', default='own_account', readonly=True, string="Payment By")
+ payment_mode = fields.Selection([("own_account", "Employee (to reimburse)"), ("company_account", "Company")], related='expense_line_ids.payment_mode', default='own_account', readonly=True, string="Paid By")
responsible_id = fields.Many2one('res.users', 'Validation By', readonly=True, copy=False, states={'submit': [('readonly', False)]})
total_amount = fields.Monetary('Total Amount', currency_field='currency_id', compute='_compute_amount', store=True, digits=dp.get_precision('Account'))
company_id = fields.Many2one('res.company', string='Company', readonly=True, states={'submit': [('readonly', False)]}, default=lambda self: self.env.user.company_id)
@@ -529,6 +530,8 @@ class HrExpenseSheet(models.Model):
res = super(HrExpenseSheet, self).write(vals)
if vals.get('employee_id'):
self._add_followers()
+ if vals.get('responsible_id'):
+ self.message_subscribe([self.responsible_id.partner_id.id])
return res
@api.multi
@@ -583,6 +586,10 @@ class HrExpenseSheet(models.Model):
MailFollowers = self.env['mail.followers']
for partner in users.mapped('partner_id'):
values['message_follower_ids'] += MailFollowers._add_follower_command(self._name, [], {partner.id: None}, {})[0]
+
+ if vals.get('responsible_id') and vals.get('responsible_id') != vals.get('employee_id'):
+ resp_partner = self.env['res.users'].browse(vals['responsible_id'])
+ values['message_follower_ids'] += MailFollowers._add_follower_command(self._name, [], {resp_partner.partner_id.id: None}, {})[0]
# --------------------------------------------
# Actions
@@ -633,7 +640,8 @@ class HrExpenseSheet(models.Model):
def approve_expense_sheets(self):
if not self.user_has_groups('hr_expense.group_hr_expense_user'):
raise UserError(_("Only HR Officers can approve expenses"))
- self.write({'state': 'approve', 'responsible_id': self.env.user.id})
+ responsible = self.responsible_id.id or self.env.user.id
+ self.write({'state': 'approve', 'responsible_id': responsible})
@api.multi
def paid_expense_sheets(self):
diff --git a/addons/hr_expense/models/res_config_settings.py b/addons/hr_expense/models/res_config_settings.py
index a142834e17a..c07d364dd7d 100644
--- a/addons/hr_expense/models/res_config_settings.py
+++ b/addons/hr_expense/models/res_config_settings.py
@@ -9,7 +9,7 @@ class ResConfigSettings(models.TransientModel):
expense_alias_prefix = fields.Char('Default Alias Name for Expenses')
use_mailgateway = fields.Boolean(string='Let your employees record expenses by email',
config_parameter='hr_expense.use_mailgateway')
- module_sale_management = fields.Boolean(string="Customer Billing")
+ module_sale_expense = fields.Boolean(string="Customer Billing")
@api.model
def get_values(self):
diff --git a/addons/hr_expense/static/src/js/tour.js b/addons/hr_expense/static/src/js/tour.js
index 14bc3ae7873..2c757c5e62e 100644
--- a/addons/hr_expense/static/src/js/tour.js
+++ b/addons/hr_expense/static/src/js/tour.js
@@ -13,22 +13,17 @@ tour.register('hr_expense_tour' ,
[tour.STEPS.MENU_MORE,
{
trigger: '.o_app[data-menu-xmlid="hr_expense.menu_hr_expense_root"], .oe_menu_toggler[data-menu-xmlid="hr_expense.menu_hr_expense_root"]',
- content: _t("Go to the expense to attach a receipt."),
+ content: _t("Want to manage your expenses? It starts here."),
position: 'bottom',
}, {
trigger: '.o_list_button_add',
extra_trigger: ".o_expense_tree",
- content: _t('<p>Click here to create your first expense and add it under here.</p>'),
+ content: _t('<p>Let’s start by creating your first expense.</p>'),
position: 'bottom'
}, {
- trigger: ".o_required_modifier input",
- extra_trigger: ".o_expense_form",
- content: _t("Write the name of the product, or select an existing one."),
- position: "top",
-}, {
trigger: '.o_form_button_save',
extra_trigger: ".o_expense_form",
- content: _t("<p>Once your Expense is ready, you can save it.</p>"),
+ content: _t("<p>Once your <b>Expense report</b> is ready, you can save it and wait for the approval from your manager.</p>"),
position: 'bottom',
}, {
trigger: '.o_expense_form .o_chatter_button_new_message',
diff --git a/addons/hr_expense/views/hr_expense_views.xml b/addons/hr_expense/views/hr_expense_views.xml
index 7ad72b2ffd7..6c15c9bdda9 100644
--- a/addons/hr_expense/views/hr_expense_views.xml
+++ b/addons/hr_expense/views/hr_expense_views.xml
@@ -21,26 +21,13 @@
</field>
</record>
- <record id="hr_expense_form_view" model="ir.ui.view">
- <field name="name">hr.expense.form</field>
+ <record id="hr_expense_view_form_without_header" model="ir.ui.view">
+ <field name="name">hr.expense.view.form</field>
<field name="model">hr.expense</field>
- <field eval="25" name="priority"/>
+ <field eval="35" name="priority"/>
<field name="arch" type="xml">
<form string="Expenses" class="o_expense_form">
- <header invisible="context.get('expense_adding_line')">
- <button name="action_submit_expenses" states="draft" string="Submit to Manager" type="object" class="oe_highlight o_expense_submit"/>
- <field name="state" widget="statusbar" statusbar_visible="draft,reported,done"/>
- <button name="action_view_sheet" type="object" string="View Report" class="oe_highlight" attrs="{'invisible': [('state', '=','draft')]}"/>
- </header>
<sheet>
- <div class="oe_button_box" invisible="context.get('expense_adding_line')">
- <button name="action_get_attachment_view"
- class="oe_stat_button"
- icon="fa-book"
- type="object">
- <field name="attachment_number" widget="statinfo" string="Documents"/>
- </button>
- </div>
<div class="oe_title">
<label for="name"/>
<h1>
@@ -76,7 +63,7 @@
</group>
<div>
- <field name="description" placeholder="Notes..."/>
+ <field name="description" class="oe_inline" placeholder="Notes..."/>
</div>
</sheet>
<div class="oe_chatter">
@@ -87,6 +74,33 @@
</field>
</record>
+ <record id="hr_expense_view_form" model="ir.ui.view">
+ <field name="name">hr.expense.view.form</field>
+ <field name="model">hr.expense</field>
+ <field name="inherit_id" ref="hr_expense.hr_expense_view_form_without_header"/>
+ <field name="mode">primary</field>
+ <field name="arch" type="xml">
+ <xpath expr="/form/*" position="before">
+ <header>
+ <button name="submit_expenses" states="draft" string="Submit to Manager" type="object" class="oe_highlight"/>
+ <field name="state" widget="statusbar" statusbar_visible="draft,reported,approved,done,refused"/>
+ <button name="view_sheet" type="object" string="View Report" class="oe_highlight" attrs="{'invisible': [('state', '=','draft')]}"/>
+ </header>
+ </xpath>
+ <xpath expr="/form/sheet/*" position="before">
+ <div class="oe_button_box">
+ <button name="action_get_attachment_view"
+ class="oe_stat_button"
+ icon="fa-book"
+ type="object"
+ attrs="{'invisible': [('attachment_number', '=', 0)]}">
+ <field name="attachment_number" widget="statinfo" string="Documents" options="{'reload_on_button': true}"/>
+ </button>
+ </div>
+ </xpath>
+ </field>
+ </record>
+
<record id="hr_expense_kanban_view" model="ir.ui.view">
<field name="name">hr.expense.kanban</field>
<field name="model">hr.expense</field>
@@ -196,7 +210,7 @@
</record>
<record id="hr_expense_actions_my_unsubmitted" model="ir.actions.act_window">
- <field name="name">My Expenses to Submit</field>
+ <field name="name">My Expenses</field>
<field name="res_model">hr.expense</field>
<field name="view_mode">tree,kanban,form,graph,pivot</field>
<field name="search_view_id" ref="view_hr_expense_filter"/>
@@ -387,7 +401,8 @@
<button name="action_get_attachment_view"
class="oe_stat_button"
icon="fa-book"
- type="object">
+ type="object"
+ attrs="{'invisible': [('attachment_number', '=', 0)]}">
<field name="attachment_number" widget="statinfo" string="Documents"/>
</button>
</div>
@@ -401,15 +416,15 @@
<group>
<field name="employee_id"/>
<field name="payment_mode"/>
- <field name="responsible_id" invisible="1"/>
+ <field name="responsible_id"/>
<field name="address_id" invisible="1"/>
<field name="department_id" invisible="1"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
</group>
<notebook>
- <page string="Expense Lines">
- <field name="expense_line_ids" nolabel="1" widget="many2many" domain="[('state', '=', 'draft')]" options="{'not_delete': True, 'reload_on_button': True, 'no_create': True}" context="{'expense_adding_line': True}">
+ <page string="Expense">
+ <field name="expense_line_ids" nolabel="1" widget="many2many" domain="[('state', '=', 'draft')]" options="{'reload_on_button': True}" context="{'form_view_ref' : 'hr_expense.hr_expense_view_form_without_header', 'expense_adding_line': True}">
<tree decoration-danger="is_refused">
<field name="date"/>
<field name="name"/>
@@ -418,13 +433,12 @@
<field name="message_unread" invisible="1"/>
<field name="attachment_number" string=" "/>
<button name="action_get_attachment_view" string="View Attachments" type="object" icon="fa-paperclip"/>
- <field name="tax_ids" widget="many2many_tags"/>
+ <field name="tax_ids" widget="many2many_tags" groups="account.group_account_user"/>
<field name="currency_id" invisible="1"/>
<field name="total_amount"/>
<field name="company_currency_id" invisible="1"/>
<field name="total_amount_company" groups="base.group_multi_currency"/>
<field name="is_refused" invisible="True"/>
- <button name="%(hr_expense.hr_expense_refuse_wizard_action)d" states="reported, refused" string="Refuse" context="{'hr_expense_refuse_model':'hr.expense'}" type="action" groups="hr_expense.group_hr_expense_user, account.group_account_user" icon="fa-times" attrs="{'invisible': ['|', ('is_refused', '=', True),('state', 'in', ['done'])]}"/>
</tree>
</field>
<field name="currency_id" invisible="1"/>
@@ -722,7 +736,7 @@
</record>
<record id="hr_expense_submit_action_server" model="ir.actions.server">
- <field name="name">Expense: Submit To Manager</field>
+ <field name="name">Submit To Manager</field>
<field name="type">ir.actions.server</field>
<field name="model_id" ref="model_hr_expense"/>
<field name="binding_model_id" ref="model_hr_expense"/>
@@ -752,8 +766,6 @@ if records:
<menuitem id="menu_hr_expense_reports" name="Reporting" sequence="4" parent="menu_hr_expense_root" groups="hr_expense.group_hr_expense_manager"/>
<menuitem id="menu_hr_expense_all_expenses" name="Expenses Analysis" sequence="0" parent="menu_hr_expense_reports" action="hr_expense_actions_all"/>
- <menuitem id="menu_hr_expense_sheet_all_all" name="Expenses Reports Analysis" sequence="4" parent="menu_hr_expense_reports"
- action="action_hr_expense_sheet_all_all" groups="hr_expense.group_hr_expense_manager"/>
<menuitem id="menu_hr_expense_configuration" name="Configuration" parent="menu_hr_expense_root"
sequence="100"/>
diff --git a/addons/hr_expense/views/res_config_settings_views.xml b/addons/hr_expense/views/res_config_settings_views.xml
index 3ea7b74fc22..3144c60b8ba 100644
--- a/addons/hr_expense/views/res_config_settings_views.xml
+++ b/addons/hr_expense/views/res_config_settings_views.xml
@@ -41,10 +41,10 @@
<div class="col-xs-12 col-md-6 o_setting_box" title="This installs the Sales Management app.
Expenses can be invoiced to customers from sales orders.">
<div class="o_setting_left_pane">
- <field name="module_sale_management"/>
+ <field name="module_sale_expense"/>
</div>
<div class="o_setting_right_pane">
- <label for="module_sale_management"/>
+ <label for="module_sale_expense"/>
<div class="text-muted">
Sell services and invoice expenses to customer
</div>