Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions hr_expense_pay_to_vendor/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
==========================
HR Expense - Pay To Vendor
==========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:35b4d6a5e7979037d4a3fa64fbf7222c10e47e8d7fcdcdf22246874df1f2f8f3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |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--expense-lightgray.png?logo=github
:target: https://github.com/OCA/hr-expense/tree/17.0/hr_expense_pay_to_vendor
:alt: OCA/hr-expense
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/hr-expense-17-0/hr-expense-17-0-hr_expense_pay_to_vendor
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/hr-expense&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allow expense "Pay to Vendor" as option when user select,
Paid By Company.

**Pay to Vendor** is suitable for cases when user wanted to buy
something, i.e., Plane Ticket, but do not want to pay money him/herself
and use expense as the way to make payment order to accounting
department.

When expense has posted journal entry, the AR will be set to Vendor (and
not the Employee). Then, register the payment will be clearing the AR to
Bank.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

1. Go to *Expenses -> My Expenses -> Expenses to Submit* and create a
new *Expense* with *Company* as Paid By, and a Vendor as Pay to
Vendor
2. Click on *Submit to Manager* button
3. Click on *Approve* button
4. Click on *Post Journal Entries* button, the Receivable will be on
Vendor
5. Click on *Register Payment* button, fill in the data of the wizard
and click on *Validate* button

You can now check that the partner in journal entries are on Vendor, and
not on Employee.

Bug Tracker
===========

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 to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/hr-expense/issues/new?body=module:%20hr_expense_pay_to_vendor%0Aversion:%2017.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.

Credits
=======

Authors
-------

* Ecosoft

Contributors
------------

- Kitti U. <kittiu@ecosoft.co.th>

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-kittiu| image:: https://github.com/kittiu.png?size=40px
:target: https://github.com/kittiu
:alt: kittiu

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-kittiu|

This module is part of the `OCA/hr-expense <https://github.com/OCA/hr-expense/tree/17.0/hr_expense_pay_to_vendor>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
3 changes: 3 additions & 0 deletions hr_expense_pay_to_vendor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import models
15 changes: 15 additions & 0 deletions hr_expense_pay_to_vendor/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2021 Ecosoft
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "HR Expense - Pay To Vendor",
"version": "17.0.1.0.0",
"author": "Ecosoft, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/hr-expense",
"license": "AGPL-3",
"category": "Human Resources",
"depends": ["hr_expense"],
"data": ["views/hr_expense_views.xml"],
"installable": True,
"maintainers": ["kittiu"],
}
43 changes: 43 additions & 0 deletions hr_expense_pay_to_vendor/i18n/hr_expense_pay_to_vendor.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_expense_pay_to_vendor
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: hr_expense_pay_to_vendor
#: model:ir.model,name:hr_expense_pay_to_vendor.model_hr_expense
msgid "Expense"
msgstr ""

#. module: hr_expense_pay_to_vendor
#: model:ir.model,name:hr_expense_pay_to_vendor.model_hr_expense_sheet
msgid "Expense Report"
msgstr ""

#. module: hr_expense_pay_to_vendor
#. odoo-python
#: code:addons/hr_expense_pay_to_vendor/models/hr_expense.py:0
#, python-format
msgid "Expenses must be paying to the same vendor."
msgstr ""

#. module: hr_expense_pay_to_vendor
#: model:ir.model.fields,help:hr_expense_pay_to_vendor.field_hr_expense__vendor_id
#: model:ir.model.fields,help:hr_expense_pay_to_vendor.field_hr_expense_sheet__vendor_id
msgid "Paid by company direct to this vendor"
msgstr ""

#. module: hr_expense_pay_to_vendor
#: model:ir.model.fields,field_description:hr_expense_pay_to_vendor.field_hr_expense__vendor_id
#: model:ir.model.fields,field_description:hr_expense_pay_to_vendor.field_hr_expense_sheet__vendor_id
msgid "To Vendor"
msgstr ""
46 changes: 46 additions & 0 deletions hr_expense_pay_to_vendor/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hr_expense_pay_to_vendor
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-06-29 13:08+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: hr_expense_pay_to_vendor
#: model:ir.model,name:hr_expense_pay_to_vendor.model_hr_expense
msgid "Expense"
msgstr "Spesa"

#. module: hr_expense_pay_to_vendor
#: model:ir.model,name:hr_expense_pay_to_vendor.model_hr_expense_sheet
msgid "Expense Report"
msgstr "Nota spese"

#. module: hr_expense_pay_to_vendor
#. odoo-python
#: code:addons/hr_expense_pay_to_vendor/models/hr_expense.py:0
#, python-format
msgid "Expenses must be paying to the same vendor."
msgstr "La spesa deve essere pagata allo stesso fornitore."

#. module: hr_expense_pay_to_vendor
#: model:ir.model.fields,help:hr_expense_pay_to_vendor.field_hr_expense__vendor_id
#: model:ir.model.fields,help:hr_expense_pay_to_vendor.field_hr_expense_sheet__vendor_id
msgid "Paid by company direct to this vendor"
msgstr "Pagato direttamente al fornitore dall'azienda"

#. module: hr_expense_pay_to_vendor
#: model:ir.model.fields,field_description:hr_expense_pay_to_vendor.field_hr_expense__vendor_id
#: model:ir.model.fields,field_description:hr_expense_pay_to_vendor.field_hr_expense_sheet__vendor_id
msgid "To Vendor"
msgstr "Al fornitore"
3 changes: 3 additions & 0 deletions hr_expense_pay_to_vendor/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import hr_expense
74 changes: 74 additions & 0 deletions hr_expense_pay_to_vendor/models/hr_expense.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2021 Ecosoft
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


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

vendor_id = fields.Many2one(
comodel_name="res.partner",
string="To Vendor",
help="Paid by company direct to this vendor",
)

def _get_expense_account_destination(self):
self.ensure_one()
if not (self.payment_mode == "company_account" and self.vendor_id):
return super()._get_expense_account_destination()
# Use vendor's account
account_dest = (
self.vendor_id.property_account_payable_id.id
or self.vendor_id.parent_id.property_account_payable_id.id
)
return account_dest


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

vendor_id = fields.Many2one(
comodel_name="res.partner",
related="expense_line_ids.vendor_id",
string="To Vendor",
readonly=True,
)

@api.constrains("expense_line_ids")
def _check_payment_mode(self):
res = super()._check_payment_mode()
for sheet in self:
expenses = sheet.expense_line_ids
payment_mode = expenses.mapped("payment_mode")
if payment_mode and payment_mode[0] == "company_account":
if expenses and any(
expense.vendor_id != expenses[0].vendor_id for expense in expenses
):
raise ValidationError(
_("Expenses must be paying to the same vendor.")
)
return res

def action_sheet_move_create(self):
# For expense paid by copany to vendor, only set state to post
res = super().action_sheet_move_create()
to_post = self.filtered(
lambda l: l.payment_mode == "company_account" and l.vendor_id
)
to_post.write({"state": "post"})
return res

def _prepare_payment_vals(self):
self.ensure_one()
payment_vals = super()._prepare_payment_vals()
if self.payment_mode == "company_account" and self.vendor_id:
for line in payment_vals["line_ids"]:
line[2]["partner_id"] = self.vendor_id.id
# Overwrite name without taxes
if line[2].get("tax_base_amount", False):
continue
expense_name = line[2]["name"].split(":")[1].strip()
line[2]["name"] = f"{self.vendor_id.name}: {expense_name}"
return payment_vals
3 changes: 3 additions & 0 deletions hr_expense_pay_to_vendor/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions hr_expense_pay_to_vendor/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Kitti U. \<<kittiu@ecosoft.co.th>\>
11 changes: 11 additions & 0 deletions hr_expense_pay_to_vendor/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This module allow expense "Pay to Vendor" as option when user select,
Paid By Company.

**Pay to Vendor** is suitable for cases when user wanted to buy
something, i.e., Plane Ticket, but do not want to pay money him/herself
and use expense as the way to make payment order to accounting
department.

When expense has posted journal entry, the AR will be set to Vendor (and
not the Employee). Then, register the payment will be clearing the AR to
Bank.
14 changes: 14 additions & 0 deletions hr_expense_pay_to_vendor/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
To use this module, you need to:

1. Go to *Expenses -\> My Expenses -\> Expenses to Submit* and create a
new *Expense* with *Company* as Paid By, and a Vendor as Pay to
Vendor
2. Click on *Submit to Manager* button
3. Click on *Approve* button
4. Click on *Post Journal Entries* button, the Receivable will be on
Vendor
5. Click on *Register Payment* button, fill in the data of the wizard
and click on *Validate* button

You can now check that the partner in journal entries are on Vendor, and
not on Employee.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading