-
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] account_reconcile_payment_order
- Loading branch information
Showing
28 changed files
with
1,486 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,214 @@ | ||
=============================== | ||
Account Reconcile Payment Order | ||
=============================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:62593d3c4026a4022d861045e7c9cd3fa56484718450a6e7d52325acb833b6e4 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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%2Faccount--reconcile-lightgray.png?logo=github | ||
:target: https://github.com/OCA/account-reconcile/tree/16.0/account_reconcile_payment_order | ||
:alt: OCA/account-reconcile | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/account-reconcile-16-0/account-reconcile-16-0-account_reconcile_payment_order | ||
: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/account-reconcile&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
[ This file must be max 2-3 paragraphs, and is required. | ||
|
||
The goal of this document is to explain quickly the features of this | ||
module: “what” this module does and “what” it is for. ] | ||
|
||
Example: | ||
|
||
This module extends the functionality of ... to support ... and to allow | ||
users to ... | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Use Cases / Context | ||
=================== | ||
|
||
[ This file is optional but strongly suggested to allow end-users to | ||
evaluate the module's usefulness in their context. ] | ||
|
||
BUSINESS NEED: It should explain the “why” of the module: | ||
|
||
- what is the business requirement that generated the need to develop | ||
this module | ||
- in which context or use cases this module can be useful (practical | ||
examples are welcome!). | ||
|
||
APPROACH: It could also explain the approach to address the mentioned | ||
need. | ||
|
||
USEFUL INFORMATION: It can also inform on related modules: | ||
|
||
- modules it depends on and their features | ||
- other modules that can work well together with this one | ||
- suggested setups where the module is useful (eg: multicompany, | ||
multi-website) | ||
|
||
Installation | ||
============ | ||
|
||
[ This file must only be present if there are very specific installation | ||
instructions, such as installing non-python dependencies. The audience | ||
is systems administrators. ] | ||
|
||
To install this module, you need to: | ||
|
||
1. Do this ... | ||
|
||
Configuration | ||
============= | ||
|
||
[ This file is not always required; it should explain **how to configure | ||
the module before using it**; it is aimed at users with administration | ||
privileges. | ||
|
||
Please be detailed on the path to configuration (eg: do you need to | ||
activate developer mode?), describe step by step configurations and the | ||
use of screenshots is strongly recommended.] | ||
|
||
To configure this module, you need to: | ||
|
||
- Go to *App* > Menu > Menu item | ||
- Activate boolean… > save | ||
- … | ||
|
||
Usage | ||
===== | ||
|
||
[ This file is required and contains the instructions on **“how”** to | ||
use the module for end-users. | ||
|
||
If the module does not have a visible impact on the user interface, just | ||
add the following sentence: | ||
|
||
This module does not impact the user interface. | ||
|
||
If that’s not the case, please make sure that every usage step is | ||
covered and remember that images speak more than words!] | ||
|
||
To use this module, you need to: | ||
|
||
- Go to *App* > Menu > Menu item | ||
|
||
*insert screenshot!* | ||
|
||
- In “Contact” form, add a value to field *xyz* > save | ||
|
||
*insert screenshot!* | ||
|
||
- The value of *xyz* is now displayed in the list view. | ||
|
||
*insert screenshot!* | ||
|
||
Known issues / Roadmap | ||
====================== | ||
|
||
[ Enumerate known caveats and future potential improvements. It is | ||
mostly intended for end-users, and can also help potential new | ||
contributors discovering new features to implement. ] | ||
|
||
- ... | ||
|
||
Changelog | ||
========= | ||
|
||
[ The change log. The goal of this file is to help readers understand | ||
changes between version. The primary audience is end users and | ||
integrators. Purely technical changes such as code refactoring must not | ||
be mentioned here. | ||
|
||
This file may contain ONE level of section titles, underlined with the ~ | ||
(tilde) character. Other section markers are forbidden and will likely | ||
break the structure of the README.rst or other documents where this | ||
fragment is included. ] | ||
|
||
11.0.x.y.z (YYYY-MM-DD) | ||
----------------------- | ||
|
||
- [BREAKING] Breaking changes come first. | ||
(`#70 <https://github.com/OCA/repo/issues/70>`__) | ||
- [ADD] New feature. (`#74 <https://github.com/OCA/repo/issues/74>`__) | ||
- [FIX] Correct this. (`#71 <https://github.com/OCA/repo/issues/71>`__) | ||
|
||
.. _x.y.z-yyyy-mm-dd-1: | ||
|
||
11.0.x.y.z (YYYY-MM-DD) | ||
----------------------- | ||
|
||
- ... | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-reconcile/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/account-reconcile/issues/new?body=module:%20account_reconcile_payment_order%0Aversion:%2016.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 | ||
------- | ||
|
||
* Dixmit | ||
|
||
Contributors | ||
------------ | ||
|
||
- Firstname Lastname [email protected] (optional company | ||
website url) | ||
- Second Person [email protected] (optional company website | ||
url) | ||
|
||
Other credits | ||
------------- | ||
|
||
[ This file is optional and contains additional credits, other than | ||
authors, contributors, and maintainers. ] | ||
|
||
The development of this module has been financially supported by: | ||
|
||
- Company 1 name | ||
- Company 2 name | ||
|
||
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. | ||
|
||
This module is part of the `OCA/account-reconcile <https://github.com/OCA/account-reconcile/tree/16.0/account_reconcile_payment_order>`_ 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 @@ | ||
from . import models |
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,26 @@ | ||
# Copyright 2024 Dixmit | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Account Reconcile Payment Order", | ||
"summary": """ | ||
Allow to reconcile payment order on reconcile widget""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Dixmit,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/account-reconcile", | ||
"depends": ["account_reconcile_oca", "account_payment_order"], | ||
"data": [ | ||
"security/security.xml", | ||
"security/ir.model.access.csv", | ||
"views/account_payment_order_maturity.xml", | ||
"views/account_bank_statement_line.xml", | ||
], | ||
"assets": { | ||
"web.assets_backend": [ | ||
"account_reconcile_payment_order/static/src/**/*.esm.js", | ||
"account_reconcile_payment_order/static/src/**/*.xml", | ||
] | ||
}, | ||
"demo": [], | ||
} |
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 @@ | ||
from . import account_bank_statement_line | ||
from . import account_payment_order | ||
from . import account_payment_order_maturity | ||
from . import account_payment |
110 changes: 110 additions & 0 deletions
110
account_reconcile_payment_order/models/account_bank_statement_line.py
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,110 @@ | ||
# Copyright 2024 Dixmit | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountBankStatementLine(models.Model): | ||
|
||
_inherit = "account.bank.statement.line" | ||
|
||
add_payment_order_id = fields.Many2one( | ||
"account.payment.order.maturity", | ||
check_company=True, | ||
store=False, | ||
default=False, | ||
prefetch=False, | ||
) | ||
|
||
def clean_reconcile(self): | ||
""" | ||
Remove the counterparts when cleaning | ||
""" | ||
res = super().clean_reconcile() | ||
data = self.reconcile_data_info | ||
data["order_counterparts"] = [] | ||
self.reconcile_data_info = data | ||
return res | ||
|
||
@api.onchange("add_payment_order_id") | ||
def _onchange_add_payment_order_id(self): | ||
""" | ||
We need to check if the payment order is in already on the counterpart. | ||
In this case we need to add all the liquidity lines. Otherwise, we remove them | ||
""" | ||
if self.add_payment_order_id: | ||
data = self.reconcile_data_info["data"] | ||
if self.add_payment_order_id.id not in self.reconcile_data_info.get( | ||
"order_counterparts", [] | ||
): | ||
new_data = [] | ||
counterparts = [] | ||
for line in data: | ||
counterparts += line.get("counterpart_line_ids", []) | ||
new_data.append(line) | ||
for payment in self.add_payment_order_id.payment_ids.filtered( | ||
lambda r: not r.is_matched | ||
): | ||
( | ||
liquidity_lines, | ||
counterpart_lines, | ||
writeoff_lines, | ||
) = payment._seek_for_lines() | ||
for line in liquidity_lines.filtered( | ||
lambda r: r.id not in counterparts | ||
): | ||
reconcile_auxiliary_id, lines = self._get_reconcile_line( | ||
line, "other", True, 0.0 | ||
) | ||
new_data += lines | ||
data_info = self._recompute_suspense_line( | ||
new_data, | ||
self.reconcile_data_info["reconcile_auxiliary_id"], | ||
self.manual_reference, | ||
) | ||
data_info["order_counterparts"].append(self.add_payment_order_id.id) | ||
self.reconcile_data_info = data_info | ||
elif self.add_payment_order_id: | ||
data = self.reconcile_data_info["data"] | ||
lines = [] | ||
for payment in self.add_payment_order_id.payment_ids.filtered( | ||
lambda r: not r.is_matched | ||
): | ||
( | ||
liquidity_lines, | ||
counterpart_lines, | ||
writeoff_lines, | ||
) = payment._seek_for_lines() | ||
lines += liquidity_lines.ids | ||
new_data = [] | ||
for line in data: | ||
if set(line.get("counterpart_line_ids", [])).intersection( | ||
set(lines) | ||
): | ||
continue | ||
new_data.append(line) | ||
data_info = self._recompute_suspense_line( | ||
new_data, | ||
self.reconcile_data_info["reconcile_auxiliary_id"], | ||
self.manual_reference, | ||
) | ||
["order_counterparts"].append(self.add_payment_order_id.id) | ||
counterparts = set(data_info["order_counterparts"]) | ||
counterparts.remove(self.add_payment_order_id.id) | ||
data_info["order_counterparts"] = list(counterparts) | ||
self.reconcile_data_info = data_info | ||
self.add_payment_order_id = False | ||
|
||
def _recompute_suspense_line(self, data, reconcile_auxiliary_id, manual_reference): | ||
""" | ||
We want to keep the counterpart when we recompute | ||
""" | ||
order_counterparts = ( | ||
self.reconcile_data_info | ||
and self.reconcile_data_info.get("order_counterparts", []) | ||
) or [] | ||
result = super()._recompute_suspense_line( | ||
data, reconcile_auxiliary_id, manual_reference | ||
) | ||
result["order_counterparts"] = order_counterparts | ||
return result |
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,11 @@ | ||
# Copyright 2024 Dixmit | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class AccountPayment(models.Model): | ||
|
||
_inherit = "account.payment" | ||
|
||
maturity_order_id = fields.Many2one(comodel_name="account.payment.order.maturity") |
Oops, something went wrong.