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
13 changed files
with
922 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
============================== | ||
Accunt Menu - Invoice & Refund | ||
============================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| 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 | ||
.. |badge2| image:: https://img.shields.io/badge/github-OCA%2Faccount--invoicing-lightgray.png?logo=github | ||
:target: https://github.com/OCA/account-invoicing/tree/13.0-mig-account_menu_invoice_refund/account_menu_invoice_refund | ||
:alt: OCA/account-invoicing | ||
.. |badge3| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/account-invoicing-13-0-mig-account_menu_invoice_refund/account-invoicing-13-0-mig-account_menu_invoice_refund-account_menu_invoice_refund | ||
:alt: Translate me on Weblate | ||
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/95/13.0-mig-account_menu_invoice_refund | ||
:alt: Try me on Runbot | ||
|
||
|badge1| |badge2| |badge3| |badge4| | ||
|
||
By Odoo standard, Invoices and Refunds are in different menu, | ||
and can't be mixed upon payment. | ||
|
||
This module add 2 new menus, | ||
|
||
1. Invoicing > Customers > Invoices / Credit Notes | ||
2. Invoicing > Vendors > Bills / Refunds | ||
|
||
Additionally it allow register net payment by selecting both invoice and refund. | ||
|
||
**Note:** | ||
This is accomplished by simply remove the condition that disallow | ||
mixing invoice and refund in account.payment's default_get() | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Usage | ||
===== | ||
|
||
To make payment that net invoice and refund, | ||
|
||
* Got to new menu, "Invoices / Credit Notes" or "Bills / Refunds" | ||
* Make payment as normal, you will see the payment amount will be invoice amount minus refund amount | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-invoicing/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/account-invoicing/issues/new?body=module:%20account_menu_invoice_refund%0Aversion:%2013.0-mig-account_menu_invoice_refund%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 Upariphutthiphong <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/account-invoicing <https://github.com/OCA/account-invoicing/tree/13.0-mig-account_menu_invoice_refund/account_menu_invoice_refund>`_ 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright 2019 Ecosoft Co., Ltd (https://ecosoft.co.th/) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
|
||
from .hooks import post_load_hook |
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,18 @@ | ||
# Copyright 2019 Ecosoft Co., Ltd (https://ecosoft.co.th/) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
|
||
{ | ||
"name": "Account Menu - Invoice & Refund", | ||
"version": "13.0.1.0.0", | ||
"summary": "New invoice menu that combine invoices and refunds", | ||
"category": "Accounting & Finance", | ||
"author": "Ecosoft, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"website": "https://github.com/OCA/account-invoicing", | ||
"depends": ["account"], | ||
"data": ["views/account_move_view.xml"], | ||
"installable": True, | ||
"development_status": "beta", | ||
"maintainers": ["kittiu"], | ||
"post_load": "post_load_hook", | ||
} |
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,116 @@ | ||
# Copyright 2019 Ecosoft Co., Ltd (https://ecosoft.co.th/) | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html) | ||
|
||
from odoo import _, api, fields | ||
from odoo.exceptions import UserError | ||
|
||
from odoo.addons.account.models.account_payment import account_payment, payment_register | ||
|
||
MAP_INVOICE_TYPE_PARTNER_TYPE = { | ||
"out_invoice": "customer", | ||
"out_refund": "customer", | ||
"out_receipt": "customer", | ||
"in_invoice": "supplier", | ||
"in_refund": "supplier", | ||
"in_receipt": "supplier", | ||
} | ||
|
||
|
||
def post_load_hook(): | ||
@api.model | ||
def new_default_get_payment_register(self, fields): | ||
""" Removed condition that disallow mixing invoice and refund """ | ||
rec = super(payment_register, self).default_get(fields) | ||
active_ids = self._context.get("active_ids") | ||
invoices = self.env["account.move"].browse(active_ids) | ||
|
||
# Check all invoices are open | ||
if any( | ||
invoice.state != "posted" | ||
or invoice.invoice_payment_state != "not_paid" | ||
or not invoice.is_invoice() | ||
for invoice in invoices | ||
): | ||
raise UserError(_("You can only register payments for open invoices")) | ||
if any(inv.company_id != invoices[0].company_id for inv in invoices): | ||
raise UserError( | ||
_( | ||
"""You can only register at the same time for payment that | ||
are all from the same company""" | ||
) | ||
) | ||
if "invoice_ids" not in rec: | ||
rec["invoice_ids"] = [(6, 0, invoices.ids)] | ||
if "journal_id" not in rec: | ||
rec["journal_id"] = ( | ||
self.env["account.journal"] | ||
.search( | ||
[ | ||
("company_id", "=", self.env.company.id), | ||
("type", "in", ("bank", "cash")), | ||
], | ||
limit=1, | ||
) | ||
.id | ||
) | ||
if "payment_method_id" not in rec: | ||
if invoices[0].is_inbound(): | ||
domain = [("payment_type", "=", "inbound")] | ||
else: | ||
domain = [("payment_type", "=", "outbound")] | ||
rec["payment_method_id"] = ( | ||
self.env["account.payment.method"].search(domain, limit=1).id | ||
) | ||
return rec | ||
|
||
if not hasattr(payment_register, "default_get_original"): | ||
payment_register.default_get_original = payment_register.default_get | ||
|
||
payment_register.default_get = new_default_get_payment_register | ||
|
||
@api.model | ||
def new_default_get_account_payment(self, default_fields): | ||
""" Removed condition that disallow register | ||
payment between Invoice and Refund""" | ||
rec = super(account_payment, self).default_get(default_fields) | ||
active_ids = self._context.get("active_ids") or self._context.get("active_id") | ||
active_model = self._context.get("active_model") | ||
|
||
# Check for selected invoices ids | ||
if not active_ids or active_model != "account.move": | ||
return rec | ||
|
||
invoices = ( | ||
self.env["account.move"] | ||
.browse(active_ids) | ||
.filtered(lambda move: move.is_invoice(include_receipts=True)) | ||
) | ||
|
||
# Check all invoices are open | ||
if not invoices or any(invoice.state != "posted" for invoice in invoices): | ||
raise UserError(_("You can only register payments for open invoices")) | ||
|
||
amount = self._compute_payment_amount( | ||
invoices, | ||
invoices[0].currency_id, | ||
invoices[0].journal_id, | ||
rec.get("payment_date") or fields.Date.today(), | ||
) | ||
|
||
rec.update( | ||
{ | ||
"currency_id": invoices[0].currency_id.id, | ||
"amount": abs(amount), | ||
"payment_type": "inbound" if amount > 0 else "outbound", | ||
"partner_id": invoices[0].commercial_partner_id.id, | ||
"partner_type": MAP_INVOICE_TYPE_PARTNER_TYPE[invoices[0].type], | ||
"communication": invoices[0].ref or invoices[0].name, | ||
"invoice_ids": [(6, 0, invoices.ids)], | ||
} | ||
) | ||
return rec | ||
|
||
if not hasattr(account_payment, "default_get_original"): | ||
account_payment.default_get_original = account_payment.default_get | ||
|
||
account_payment.default_get = new_default_get_account_payment |
59 changes: 59 additions & 0 deletions
59
account_menu_invoice_refund/i18n/account_menu_invoice_refund.pot
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,59 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_menu_invoice_refund | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.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: account_menu_invoice_refund | ||
#: model:ir.actions.act_window,name:account_menu_invoice_refund.action_invoice_in_tree | ||
#: model:ir.ui.menu,name:account_menu_invoice_refund.menu_action_invoice_in_tree | ||
msgid "Bills / Refunds" | ||
msgstr "" | ||
|
||
#. module: account_menu_invoice_refund | ||
#: model_terms:ir.actions.act_window,help:account_menu_invoice_refund.action_invoice_out_tree | ||
msgid "Create a customer invoice" | ||
msgstr "" | ||
|
||
#. module: account_menu_invoice_refund | ||
#: model_terms:ir.actions.act_window,help:account_menu_invoice_refund.action_invoice_in_tree | ||
msgid "Create a vendor bill" | ||
msgstr "" | ||
|
||
#. module: account_menu_invoice_refund | ||
#: model_terms:ir.actions.act_window,help:account_menu_invoice_refund.action_invoice_out_tree | ||
msgid "Create invoices, register payments and keep track of the discussions with your customers." | ||
msgstr "" | ||
|
||
#. module: account_menu_invoice_refund | ||
#: model_terms:ir.actions.act_window,help:account_menu_invoice_refund.action_invoice_in_tree | ||
msgid "Create vendor bills, register payments and keep track of the discussions with your customers." | ||
msgstr "" | ||
|
||
#. module: account_menu_invoice_refund | ||
#: code:addons/account_menu_invoice_refund/hooks.py:37 | ||
#, python-format | ||
msgid "In order to pay multiple invoices at once, they must use the same currency." | ||
msgstr "" | ||
|
||
#. module: account_menu_invoice_refund | ||
#: model:ir.actions.act_window,name:account_menu_invoice_refund.action_invoice_out_tree | ||
#: model:ir.ui.menu,name:account_menu_invoice_refund.menu_action_invoice_out_tree | ||
msgid "Invoices / Credit Notes" | ||
msgstr "" | ||
|
||
#. module: account_menu_invoice_refund | ||
#: code:addons/account_menu_invoice_refund/hooks.py:34 | ||
#, python-format | ||
msgid "You can only register payments for open invoices" | ||
msgstr "" | ||
|
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 @@ | ||
* Kitti Upariphutthiphong <kittiu@ecosoft.co.th> |
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,13 @@ | ||
By Odoo standard, Invoices and Refunds are in different menu, | ||
and can't be mixed upon payment. | ||
|
||
This module add 2 new menus, | ||
|
||
1. Invoicing > Customers > Invoices / Credit Notes | ||
2. Invoicing > Vendors > Bills / Refunds | ||
|
||
Additionally it allow register net payment by selecting both invoice and refund. | ||
|
||
**Note:** | ||
This is accomplished by simply remove the condition that disallow | ||
mixing invoice and refund in account.payment's default_get() |
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,4 @@ | ||
To make payment that net invoice and refund, | ||
|
||
* Got to new menu, "Invoices / Credit Notes" or "Bills / Refunds" | ||
* Make payment as normal, you will see the payment amount will be invoice amount minus refund amount |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.