-
-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by JordiBForgeFlow
- Loading branch information
Showing
18 changed files
with
3,213 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,90 @@ | ||
=========================== | ||
Account Reconcile Model Oca | ||
=========================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:cead010f67ccc5d4b9700540c9d8d0b4fb20d497a38d36cea80cf6f78563a756 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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-LGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html | ||
:alt: License: LGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github | ||
:target: https://github.com/OCA/account-reconcile/tree/18.0/account_reconcile_model_oca | ||
: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-18-0/account-reconcile-18-0-account_reconcile_model_oca | ||
: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=18.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module restores account reconciliation models functions moved from | ||
Odoo community to enterpise in V. 17.0 | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
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_model_oca%0Aversion:%2018.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 | ||
* Odoo | ||
|
||
Contributors | ||
------------ | ||
|
||
- Dixmit | ||
|
||
- Enric Tobella | ||
|
||
- Trobz <https://www.trobz.com/> | ||
|
||
- Do Anh Duy <duyda@trobz.com> | ||
|
||
Other credits | ||
------------- | ||
|
||
The migration of this module from 17.0 to 18.0 was financially supported | ||
by Camptocamp. | ||
|
||
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/18.0/account_reconcile_model_oca>`_ 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,16 @@ | ||
# Copyright 2024 Dixmit | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Account Reconcile Model Oca", | ||
"summary": """ | ||
This includes the logic moved from Odoo Community to Odoo Enterprise""", | ||
"version": "18.0.1.0.0", | ||
"license": "LGPL-3", | ||
"author": "Dixmit,Odoo,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/account-reconcile", | ||
"depends": ["account"], | ||
"excludes": ["account_accountant"], | ||
"data": [], | ||
"demo": [], | ||
} |
25 changes: 25 additions & 0 deletions
25
account_reconcile_model_oca/i18n/account_reconcile_model_oca.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,25 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_reconcile_model_oca | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.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_reconcile_model_oca | ||
#: model:ir.model,name:account_reconcile_model_oca.model_account_bank_statement_line | ||
msgid "Bank Statement Line" | ||
msgstr "" | ||
|
||
#. module: account_reconcile_model_oca | ||
#: model:ir.model,name:account_reconcile_model_oca.model_account_reconcile_model | ||
msgid "" | ||
"Preset to create journal entries during a invoices and payments matching" | ||
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,30 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_reconcile_model_oca | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2024-04-29 08:38+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: account_reconcile_model_oca | ||
#: model:ir.model,name:account_reconcile_model_oca.model_account_bank_statement_line | ||
msgid "Bank Statement Line" | ||
msgstr "Riga estratto conto" | ||
|
||
#. module: account_reconcile_model_oca | ||
#: model:ir.model,name:account_reconcile_model_oca.model_account_reconcile_model | ||
msgid "" | ||
"Preset to create journal entries during a invoices and payments matching" | ||
msgstr "" | ||
"Preimpostazione per creare registrazioni contabili durante la corrispondenza " | ||
"tra fatture e pagamenti" |
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,28 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * account_reconcile_model_oca | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 17.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"PO-Revision-Date: 2024-06-12 03:25+0000\n" | ||
"Last-Translator: xtanuiha <feihu.zhang@live.com>\n" | ||
"Language-Team: none\n" | ||
"Language: zh_CN\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: nplurals=1; plural=0;\n" | ||
"X-Generator: Weblate 4.17\n" | ||
|
||
#. module: account_reconcile_model_oca | ||
#: model:ir.model,name:account_reconcile_model_oca.model_account_bank_statement_line | ||
msgid "Bank Statement Line" | ||
msgstr "银行对账单明细" | ||
|
||
#. module: account_reconcile_model_oca | ||
#: model:ir.model,name:account_reconcile_model_oca.model_account_reconcile_model | ||
msgid "" | ||
"Preset to create journal entries during a invoices and payments matching" | ||
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,2 @@ | ||
from . import account_reconcile_model | ||
from . import account_bank_statement_line |
140 changes: 140 additions & 0 deletions
140
account_reconcile_model_oca/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,140 @@ | ||
# Copyright 2023 Dixmit | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
from odoo.tools import SQL, html2plaintext | ||
|
||
from odoo.addons.base.models.res_bank import sanitize_account_number | ||
|
||
|
||
class AccountBankStatementLine(models.Model): | ||
_inherit = "account.bank.statement.line" | ||
|
||
def _retrieve_partner(self): | ||
self.ensure_one() | ||
|
||
# Retrieve the partner from the statement line. | ||
if self.partner_id: | ||
return self.partner_id | ||
|
||
# Retrieve the partner from the bank account. | ||
if self.account_number: | ||
account_number_nums = sanitize_account_number(self.account_number) | ||
if account_number_nums: | ||
domain = [("sanitized_acc_number", "ilike", account_number_nums)] | ||
for extra_domain in ([("company_id", "=", self.company_id.id)], []): | ||
bank_accounts = self.env["res.partner.bank"].search( | ||
extra_domain + domain | ||
) | ||
if len(bank_accounts.partner_id) == 1: | ||
return bank_accounts.partner_id | ||
|
||
# Retrieve the partner from the partner name. | ||
if self.partner_name: | ||
domain = [ | ||
("parent_id", "=", False), | ||
("name", "ilike", self.partner_name), | ||
] | ||
for extra_domain in ([("company_id", "=", self.company_id.id)], []): | ||
partner = self.env["res.partner"].search(extra_domain + domain, limit=1) | ||
if partner: | ||
return partner | ||
|
||
# Retrieve the partner from the 'reconcile models'. | ||
rec_models = self.env["account.reconcile.model"].search( | ||
[ | ||
("rule_type", "!=", "writeoff_button"), | ||
("company_id", "=", self.company_id.id), | ||
] | ||
) | ||
for rec_model in rec_models: | ||
partner = rec_model._get_partner_from_mapping(self) | ||
if partner and rec_model._is_applicable_for(self, partner): | ||
return partner | ||
|
||
# Retrieve the partner from statement line text values. | ||
st_line_text_values = self._get_st_line_strings_for_matching() | ||
unaccent = self.env.registry.unaccent | ||
sub_queries = [] | ||
params = [] | ||
for text_value in st_line_text_values: | ||
if not text_value: | ||
continue | ||
|
||
# Find a partner having a name contained inside the statement line values. | ||
# Take care a partner could contain some special characters in its name that | ||
# needs to be escaped. | ||
sub_queries.append( | ||
SQL( | ||
rf""" | ||
{unaccent("%s")} ~* ('^' || ( | ||
SELECT STRING_AGG(CONCAT('(?=.*\m', chunk[1], '\M)'), '') | ||
FROM regexp_matches({unaccent('partner.name')}, '\w{{3,}}', 'g') | ||
AS chunk | ||
)) | ||
""", | ||
text_value, | ||
) | ||
) | ||
params.append(text_value) | ||
|
||
if sub_queries: | ||
self.env["res.partner"].flush_model(["company_id", "name"]) | ||
self.env["account.move.line"].flush_model(["partner_id", "company_id"]) | ||
query = SQL(""" | ||
SELECT aml.partner_id | ||
FROM account_move_line aml | ||
JOIN res_partner partner ON | ||
aml.partner_id = partner.id | ||
AND partner.name IS NOT NULL | ||
AND partner.active | ||
AND ( | ||
""") | ||
query_parts = SQL(") OR (").join(sub_queries) | ||
final_query = SQL( | ||
""" | ||
%s | ||
%s | ||
) | ||
WHERE aml.company_id = %s | ||
LIMIT 1 | ||
""", | ||
query, | ||
query_parts, | ||
self.company_id.id, | ||
) | ||
self._cr.execute(final_query) | ||
row = self._cr.fetchone() | ||
if row: | ||
return self.env["res.partner"].browse(row[0]) | ||
|
||
return self.env["res.partner"] | ||
|
||
def _get_st_line_strings_for_matching(self, allowed_fields=None): | ||
"""Collect the strings that could be used on the statement line to perform some | ||
matching. | ||
:param allowed_fields: A explicit list of fields to consider. | ||
:return: A list of strings. | ||
""" | ||
self.ensure_one() | ||
|
||
def _get_text_value(field_name): | ||
if self._fields[field_name].type == "html": | ||
return self[field_name] and html2plaintext(self[field_name]) | ||
else: | ||
return self[field_name] | ||
|
||
st_line_text_values = [] | ||
if allowed_fields is None or "payment_ref" in allowed_fields: | ||
value = _get_text_value("payment_ref") | ||
if value: | ||
st_line_text_values.append(value) | ||
if allowed_fields is None or "narration" in allowed_fields: | ||
value = _get_text_value("narration") | ||
if value: | ||
st_line_text_values.append(value) | ||
if allowed_fields is None or "ref" in allowed_fields: | ||
value = _get_text_value("ref") | ||
if value: | ||
st_line_text_values.append(value) | ||
return st_line_text_values |
Oops, something went wrong.