forked from OCA/hr-expense
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
161 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,14 +13,14 @@ Supplier invoices on HR expenses | |
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr-lightgray.png?logo=github | ||
:target: https://github.com/OCA/hr/tree/12.0/hr_expense_invoice | ||
:alt: OCA/hr | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fhr--expense-lightgray.png?logo=github | ||
:target: https://github.com/OCA/hr-expense/tree/13.0/hr_expense_invoice | ||
:alt: OCA/hr-expense | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/hr-12-0/hr-12-0-hr_expense_invoice | ||
:target: https://translation.odoo-community.org/projects/hr-expense-13-0/hr-expense-13-0-hr_expense_invoice | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/116/12.0 | ||
:target: https://runbot.odoo-community.org/runbot/289/13.0 | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
@@ -68,10 +68,10 @@ Known issues / Roadmap | |
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr/issues>`_. | ||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/hr-expense/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us smashing it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/hr/issues/new?body=module:%20hr_expense_invoice%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
`feedback <https://github.com/OCA/hr-expense/issues/new?body=module:%20hr_expense_invoice%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
|
@@ -92,6 +92,8 @@ Contributors | |
* Vicent Cubells | ||
|
||
* Kitti Upariphutthiphong <[email protected]> | ||
* Rattapong Chokmasermkul <[email protected]> | ||
* Saran Lim. <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
@@ -106,6 +108,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose | |
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/hr <https://github.com/OCA/hr/tree/12.0/hr_expense_invoice>`_ project on GitHub. | ||
This module is part of the `OCA/hr-expense <https://github.com/OCA/hr-expense/tree/13.0/hr_expense_invoice>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from . import hr_expense | ||
from . import hr_expense_sheet | ||
from . import account_payment | ||
from . import account_move_line | ||
from . import account_move |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2019 Ecosoft <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import models | ||
|
||
|
||
class AccountMove(models.Model): | ||
_inherit = "account.move" | ||
|
||
def _get_cash_basis_matched_percentage(self): | ||
res = super()._get_cash_basis_matched_percentage() | ||
if ( | ||
res == 1 | ||
and self._context.get("use_hr_expense_invoice") | ||
and self._context.get("default_expense_line_ids") | ||
): | ||
return False | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
# Copyright 2019 Kitti U. <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from odoo import api, models | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import models | ||
|
||
|
||
class AccountMoveLine(models.Model): | ||
_inherit = "account.move.line" | ||
|
||
@api.multi | ||
def reconcile(self, writeoff_acc_id=False, writeoff_journal_id=False): | ||
if self._context.get("use_hr_expense_invoice"): | ||
self = self.filtered(lambda l: not l.reconciled) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# Copyright 2019 Kitti U. <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import _, models | ||
from odoo.exceptions import ValidationError | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Copyright 2015 Pedro M. Baeza <[email protected]> | ||
# Copyright 2017 Vicent Cubells <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.exceptions import UserError | ||
|
@@ -10,25 +10,22 @@ class HrExpense(models.Model): | |
_inherit = "hr.expense" | ||
|
||
invoice_id = fields.Many2one( | ||
comodel_name="account.invoice", | ||
comodel_name="account.move", | ||
string="Vendor Bill", | ||
domain="[('type', '=', 'in_invoice'), ('state', '=', 'open')]", | ||
oldname="invoice", | ||
domain="[('type', '=', 'in_invoice'), ('state', '=', 'posted')]", | ||
copy=False, | ||
) | ||
|
||
@api.multi | ||
@api.constrains("invoice_id") | ||
def _check_invoice_id(self): | ||
for expense in self: # Only non binding expense | ||
if ( | ||
not expense.sheet_id | ||
and expense.invoice_id | ||
and expense.invoice_id.state != "open" | ||
and expense.invoice_id.state != "posted" | ||
): | ||
raise UserError(_("Vendor bill state must be Open")) | ||
raise UserError(_("Vendor bill state must be Posted")) | ||
|
||
@api.multi | ||
def _get_account_move_line_values(self): | ||
move_line_values_by_expense = super()._get_account_move_line_values() | ||
for expense_id, move_lines in move_line_values_by_expense.items(): | ||
|
@@ -40,5 +37,7 @@ def _get_account_move_line_values(self): | |
move_line[ | ||
"partner_id" | ||
] = expense.invoice_id.partner_id.commercial_partner_id.id | ||
move_line["account_id"] = expense.invoice_id.account_id.id | ||
move_line["account_id"] = expense.invoice_id.line_ids.filtered( | ||
lambda l: l.account_internal_type == "payable" | ||
).account_id.id | ||
return move_line_values_by_expense |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Copyright 2015 Pedro M. Baeza <[email protected]> | ||
# Copyright 2017 Vicent Cubells <[email protected]> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import _, api, fields, models | ||
from odoo.exceptions import UserError | ||
|
@@ -13,7 +13,6 @@ class HrExpenseSheet(models.Model): | |
invoice_count = fields.Integer(compute="_compute_invoice_count") | ||
invoice_fully_created = fields.Boolean(compute="_compute_invoice_count") | ||
|
||
@api.multi | ||
def action_sheet_move_create(self): | ||
expense_line_ids = self.mapped("expense_line_ids").filtered("invoice_id") | ||
self._validate_expense_invoice(expense_line_ids) | ||
|
@@ -27,17 +26,19 @@ def action_sheet_move_create(self): | |
c_move_lines |= move_lines.filtered( | ||
lambda x: x.partner_id == partner and x.debit and not x.reconciled | ||
) | ||
c_move_lines |= line.invoice_id.move_id.line_ids.filtered( | ||
lambda x: x.account_id == line.invoice_id.account_id | ||
c_move_lines |= line.invoice_id.line_ids.filtered( | ||
lambda x: x.account_id | ||
== line.invoice_id.line_ids.filtered( | ||
lambda l: l.account_internal_type == "payable" | ||
).account_id | ||
and x.credit | ||
and not x.reconciled | ||
) | ||
c_move_lines.reconcile() | ||
c_move_lines.with_context(use_hr_expense_invoice=True).reconcile() | ||
return res | ||
|
||
@api.multi | ||
def _compute_invoice_count(self): | ||
Invoice = self.env["account.invoice"] | ||
Invoice = self.env["account.move"] | ||
can_read = Invoice.check_access_rights("read", raise_exception=False) | ||
for sheet in self: | ||
sheet.invoice_count = ( | ||
|
@@ -55,10 +56,10 @@ def _validate_expense_invoice(self, expense_lines): | |
if not invoices: | ||
return | ||
# All invoices must confirmed | ||
if any(invoices.filtered(lambda i: i.state != "open")): | ||
raise UserError(_("Vendor bill state must be Open")) | ||
if any(invoices.filtered(lambda i: i.state != "posted")): | ||
raise UserError(_("Vendor bill state must be Posted")) | ||
expense_amount = sum(expense_lines.mapped("total_amount")) | ||
invoice_amount = sum(invoices.mapped("residual")) | ||
invoice_amount = sum(invoices.mapped("amount_residual")) | ||
# Expense amount must equal invoice amount | ||
if float_compare(expense_amount, invoice_amount, precision) != 0: | ||
raise UserError( | ||
|
@@ -68,17 +69,16 @@ def _validate_expense_invoice(self, expense_lines): | |
) | ||
) | ||
|
||
@api.multi | ||
def action_view_invoices(self): | ||
self.ensure_one() | ||
action = { | ||
"name": _("Invoices"), | ||
"type": "ir.actions.act_window", | ||
"res_model": "account.invoice", | ||
"res_model": "account.move", | ||
"target": "current", | ||
} | ||
invoice_ids = self.expense_line_ids.mapped("invoice_id").ids | ||
view = self.env.ref("account.invoice_supplier_form") | ||
view = self.env.ref("account.view_move_form") | ||
if len(invoice_ids) == 1: | ||
invoice = invoice_ids[0] | ||
action["res_id"] = invoice | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
* Vicent Cubells | ||
|
||
* Kitti Upariphutthiphong <[email protected]> | ||
* Rattapong Chokmasermkul <[email protected]> | ||
* Saran Lim. <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.