diff --git a/hr_expense_vendor/README.rst b/hr_expense_vendor/README.rst
new file mode 100644
index 00000000..e702d50b
--- /dev/null
+++ b/hr_expense_vendor/README.rst
@@ -0,0 +1,30 @@
+*************************
+Hibou - HR Expense Vendor
+*************************
+
+Records the vendor paid on expenses.
+
+For more information and add-ons, visit `Hibou.io `_.
+
+
+=============
+Main Features
+=============
+
+* Validates presence of assigned vendor to process a Company Paid Expense.
+* If the expense is company paid, then the vendor will be the partner used when creating the journal entry, this makes it much easier to reconcile.
+* Additionally, adds the expense reference to the journal entry to make it easier to reconcile in either case.
+
+
+.. image:: https://user-images.githubusercontent.com/15882954/41182457-9b692f92-6b2a-11e8-9d5a-d8ef2f19f198.png
+ :alt: 'Expense Detail'
+ :width: 988
+ :align: left
+
+=======
+License
+=======
+
+Please see `LICENSE `_.
+
+Copyright Hibou Corp. 2018
diff --git a/hr_expense_vendor/__init__.py b/hr_expense_vendor/__init__.py
new file mode 100644
index 00000000..0650744f
--- /dev/null
+++ b/hr_expense_vendor/__init__.py
@@ -0,0 +1 @@
+from . import models
diff --git a/hr_expense_vendor/__manifest__.py b/hr_expense_vendor/__manifest__.py
new file mode 100644
index 00000000..2dd1088b
--- /dev/null
+++ b/hr_expense_vendor/__manifest__.py
@@ -0,0 +1,19 @@
+{
+ 'name': 'HR Expense Vendor',
+ 'version': '16.0.1.0.0',
+ 'author': 'Hibou Corp. ',
+ 'category': 'Human Resources',
+ 'summary': 'Record the vendor paid on expenses.',
+ 'description': """
+Record the vendor paid on expenses.
+""",
+ 'website': 'https://hibou.io/',
+ 'depends': [
+ 'hr_expense',
+ ],
+ 'data': [
+ 'views/hr_expense_views.xml',
+ ],
+ 'installable': True,
+ 'auto_install': False,
+}
diff --git a/hr_expense_vendor/models/__init__.py b/hr_expense_vendor/models/__init__.py
new file mode 100644
index 00000000..86b1ea31
--- /dev/null
+++ b/hr_expense_vendor/models/__init__.py
@@ -0,0 +1 @@
+from . import hr_expense
diff --git a/hr_expense_vendor/models/hr_expense.py b/hr_expense_vendor/models/hr_expense.py
new file mode 100644
index 00000000..66dcc46d
--- /dev/null
+++ b/hr_expense_vendor/models/hr_expense.py
@@ -0,0 +1,75 @@
+from odoo import api, fields, models, _
+from odoo.exceptions import UserError
+from odoo.tools import float_compare
+
+
+class HRExpense(models.Model):
+ _inherit = 'hr.expense'
+
+ vendor_id = fields.Many2one('res.partner', string='Vendor')
+
+ def _get_account_move_line_values(self):
+ self.ensure_one()
+ expense = self
+ return {
+ 'name': expense.employee_id.name + ': ' + expense.name.split('\n')[0][:64],
+ 'account_id': expense.account_id.id,
+ 'quantity': expense.quantity or 1,
+ 'price_unit': expense.unit_amount if expense.unit_amount != 0 else expense.total_amount,
+ 'product_id': expense.product_id.id,
+ 'product_uom_id': expense.product_uom_id.id,
+ 'analytic_distribution': expense.analytic_distribution,
+ 'expense_id': expense.id,
+ 'partner_id': expense.vendor_id.id,
+ 'tax_ids': [(6, 0, expense.tax_ids.ids)],
+ 'currency_id': expense.currency_id.id,
+ }
+
+ def action_move_create(self):
+ """
+ Move creation value are no longer built in extendable methods,
+ so we need to override here to edit moves before they are posted
+ """
+ company_paid = self.filtered(lambda e: e.payment_mode == 'company_account')
+ if company_paid.filtered(lambda e: not e.vendor_id):
+ raise UserError(_('You must have an assigned vendor to process a Company Paid Expense'))
+ moves_by_expense = super(HRExpense, self - company_paid).action_move_create()
+ company_moves = self.env['account.move'].create(company_paid.sheet_id._prepare_account_move_vals_list())
+ company_moves._post()
+
+ for expense in company_paid:
+ expense.sheet_id.paid_expense_sheets()
+
+ moves_by_expense.update({move.expense_sheet_id.id: move for move in company_moves})
+ return moves_by_expense
+
+
+class HRExpenseSheet(models.Model):
+ _inherit = 'hr.expense.sheet'
+
+ expense_line_ids = fields.One2many(states={'done': [('readonly', True)], 'post': [('readonly', True)]})
+
+ def _prepare_account_move_vals_list(self):
+ if self.filtered(lambda s: len(s.expense_line_ids.vendor_id) > 1):
+ raise UserError(_("You cannot create journal entries for different vendors in the same report."))
+ return [{
+ 'journal_id': (
+ sheet.bank_journal_id
+ if sheet.payment_mode == 'company_account' else
+ sheet.journal_id
+ ).id,
+ 'move_type': 'in_receipt',
+ 'company_id': sheet.company_id.id,
+ 'partner_id': sheet.expense_line_ids.vendor_id.id,
+ 'date': sheet.accounting_date or fields.Date.context_today(sheet),
+ 'invoice_date': sheet.accounting_date or fields.Date.context_today(sheet),
+ 'ref': sheet.name,
+ # force the name to the default value, to avoid an eventual 'default_name' in the context
+ # to set it to '' which cause no number to be given to the account.move when posted.
+ 'name': '/',
+ 'expense_sheet_id': [fields.Command.set(sheet.ids)],
+ 'line_ids':[
+ fields.Command.create(expense._get_account_move_line_values())
+ for expense in sheet.expense_line_ids
+ ]
+ } for sheet in self]
diff --git a/hr_expense_vendor/tests/__init__.py b/hr_expense_vendor/tests/__init__.py
new file mode 100644
index 00000000..bf77393e
--- /dev/null
+++ b/hr_expense_vendor/tests/__init__.py
@@ -0,0 +1 @@
+from . import test_expenses
diff --git a/hr_expense_vendor/tests/test_expenses.py b/hr_expense_vendor/tests/test_expenses.py
new file mode 100644
index 00000000..2ecfbe98
--- /dev/null
+++ b/hr_expense_vendor/tests/test_expenses.py
@@ -0,0 +1,62 @@
+from odoo.addons.hr_expense.tests.common import TestExpenseCommon
+from odoo.exceptions import UserError
+from odoo.tests import Form, tagged
+
+
+@tagged('-at_install', 'post_install')
+class TestCheckVendor(TestExpenseCommon):
+
+ @classmethod
+ def setUpClass(cls, chart_template_ref=None):
+ super(TestCheckVendor, cls).setUpClass(chart_template_ref=chart_template_ref)
+ cls.vendor_id = cls.env.ref('base.res_partner_3')
+ cls.tax = cls.env['account.tax'].create({
+ 'name': 'Expense 10%',
+ 'amount': 10,
+ 'amount_type': 'percent',
+ 'type_tax_use': 'purchase',
+ 'price_include': True,
+ })
+
+ def test_journal_entry_vendor(self):
+ expense_form = Form(self.env['hr.expense'])
+ expense_form.name = 'Car Travel Expenses'
+ expense_form.employee_id = self.expense_employee
+ expense_form.product_id = self.product_zero_cost
+ expense_form.total_amount = 700.00
+ expense_form.tax_ids.clear()
+ expense_form.tax_ids.add(self.tax)
+ expense_form.payment_mode = 'company_account'
+ expense = expense_form.save()
+
+ action_submit_expenses = expense.action_submit_expenses()
+ expense_sheet_form = Form(self.env[action_submit_expenses['res_model']].with_context(**action_submit_expenses.get('context', {})))
+ expense_sheet = expense_sheet_form.save()
+
+ self.assertEqual(expense_sheet.state, 'draft', 'Expense is not in Draft state')
+ expense_sheet.action_submit_sheet()
+
+ self.assertEqual(expense_sheet.state, 'submit', 'Expense is not in Submitted state')
+ # Approve
+ expense_sheet.approve_expense_sheets()
+ self.assertEqual(expense_sheet.state, 'approve', 'Expense is not in Approved state')
+ # Create Expense Entries
+ with self.assertRaises(UserError):
+ expense_sheet.action_sheet_move_create()
+
+ expense.vendor_id = self.vendor_id
+ expense_sheet.action_sheet_move_create()
+ self.assertEqual(expense_sheet.state, 'done')
+ self.assertTrue(expense_sheet.account_move_id.id, 'Expense Journal Entry is not created')
+
+ # [(line.debit, line.credit, line.tax_line_id.id) for line in expense_sheet.account_move_id.line_ids]
+ # should get this result [(0.0, 700.0, False), (63.64, 0.0, 179), (636.36, 0.0, False)]
+ for line in expense_sheet.account_move_id.line_ids:
+ if line.credit:
+ self.assertEqual(line.partner_id, self.vendor_id)
+ self.assertAlmostEqual(line.credit, 700.00)
+ else:
+ if not line.tax_line_id == self.tax:
+ self.assertAlmostEqual(line.debit, 636.36)
+ else:
+ self.assertAlmostEqual(line.debit, 63.64)
diff --git a/hr_expense_vendor/views/hr_expense_views.xml b/hr_expense_vendor/views/hr_expense_views.xml
new file mode 100644
index 00000000..58e73d11
--- /dev/null
+++ b/hr_expense_vendor/views/hr_expense_views.xml
@@ -0,0 +1,24 @@
+
+
+
+ hr.expense.sheet.form.inherit
+ hr.expense.sheet
+
+
+
+
+
+
+
+
+
+ hr.expense.form.inherit
+ hr.expense
+
+
+
+
+
+
+
+
\ No newline at end of file