Skip to content

Commit

Permalink
[14.0][ADD] hr_expense_journal
Browse files Browse the repository at this point in the history
  • Loading branch information
Freni-OSI authored and dreispt committed Dec 3, 2021
1 parent 61a264c commit c6309d2
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hr_expense_journal/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
19 changes: 19 additions & 0 deletions hr_expense_journal/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Select Expense Journal",
"version": "14.0.1.0.0",
"author": "Open Source Integrators, Odoo Community Association (OCA)",
"summary": "Set the Journal for the payment type used to pay the expense",
"website": "https://github.com/OCA/hr-expense",
"license": "AGPL-3",
"depends": ["hr_expense"],
"category": "Human Resources/Expenses",
"data": [
"views/hr_expense_views.xml",
],
"installable": True,
"maintainers": ["dreispt"],
"development_status": "Beta",
}
4 changes: 4 additions & 0 deletions hr_expense_journal/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import hr_expense
16 changes: 16 additions & 0 deletions hr_expense_journal/models/hr_expense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2021 Open Source Integrators
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class HrExpense(models.Model):
_inherit = "hr.expense"

payment_type_id = fields.Many2one("account.journal", string="Payment Journal")

def _create_sheet_from_expenses(self):
res = super()._create_sheet_from_expenses()
if self.payment_type_id:
res.update({"bank_journal_id": self.payment_type_id.id})
return res
4 changes: 4 additions & 0 deletions hr_expense_journal/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Open Source Integrators <https://www.opensourceintegrators.com>`_:

* Daniel Reis <[email protected]>
* Freni Patel <[email protected]>
7 changes: 7 additions & 0 deletions hr_expense_journal/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Employees can pay for expenses using company Credit Cards.

In this case, there is the need for the Expense to identify
what Credit Card was used for that payment.

This allows the Expense report to use the correct journal,
and have the payment accounting enty to be posted in the correct place.
5 changes: 5 additions & 0 deletions hr_expense_journal/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Create an Expense and select "Paid By Company".
- A "Payment Type" field will be available, to select the
journal corresponding to teh credit card or payment method used.
- When creating the Expense Report, the selected Payment Type
is used to populate the "Bank Journal" field, in the "Other Setting" tab.
33 changes: 33 additions & 0 deletions hr_expense_journal/views/hr_expense_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<odoo>
<record id="hr_expense_form_view_inherit" model="ir.ui.view">
<field name="model">hr.expense</field>
<field name="inherit_id" ref="hr_expense.hr_expense_view_form" />
<field name="arch" type="xml">

<xpath expr="//sheet/group/group[3]" position="inside">
<field
name="payment_type_id"
attrs="{'invisible': [('payment_mode', '!=', 'company_account')]}"
domain="[('type', '=', 'bank')]"
/>
</xpath>

</field>
</record>
<record id="hr_expense_sheet_view_inherit" model="ir.ui.view">
<field name="model">hr.expense.sheet</field>
<field name="inherit_id" ref="hr_expense.view_hr_expense_sheet_form" />
<field name="arch" type="xml">

<field name="expense_line_ids" position="attributes">
<!-- Can add only Expenses matching the payment mode and payment journal -->
<attribute name="domain">
[('state', '=', 'draft'), ('employee_id', '=', employee_id), ('company_id', '=', company_id),
('payment_mode', '=', payment_mode),
'|', ('payment_type_id', '=', bank_journal_id), ('payment_type_id', '=', False)]
</attribute>
</field>

</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions setup/hr_expense_journal/odoo/addons/hr_expense_journal
6 changes: 6 additions & 0 deletions setup/hr_expense_journal/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit c6309d2

Please sign in to comment.