Skip to content

Commit 0517851

Browse files
[MIG] sync_multi_company_bank_account: Migration to 16.0
1 parent 4be2b6f commit 0517851

File tree

8 files changed

+119
-70
lines changed

8 files changed

+119
-70
lines changed

sync_multi_company_bank_account/README.rst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
15
===============================
26
Sync Multi Company Bank Account
37
===============================
48

5-
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9+
..
10+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
611
!! This file is generated by oca-gen-addon-readme !!
712
!! changes will be overwritten. !!
813
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14+
!! source digest: sha256:2cb1117e7eeae500370f540a90494e7d195242b9492ae0ffc2f344857e97e33a
15+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
916
1017
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
1118
:target: https://odoo-community.org/page/development-status
1219
:alt: Beta
13-
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
1421
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
1522
:alt: License: AGPL-3
16-
.. |badge3| image:: https://img.shields.io/badge/github-escodoo%2Faccount--addons-lightgray.png?logo=github
17-
:target: https://github.com/escodoo/account-addons/tree/14.0/sync_multi_company_bank_account
18-
:alt: escodoo/account-addons
23+
.. |badge3| image:: https://img.shields.io/badge/github-Escodoo%2Faccount--addons-lightgray.png?logo=github
24+
:target: https://github.com/Escodoo/account-addons/tree/16.0/sync_multi_company_bank_account
25+
:alt: Escodoo/account-addons
1926

20-
|badge1| |badge2| |badge3|
27+
|badge1| |badge2| |badge3|
2128

2229
The Multi-Company Bank Account Synchronization module aims to ensure that all companies within a business group have the same bank accounts registered and updated, so that all of them can carry out financial transactions without data compatibility issues.
2330

@@ -38,10 +45,10 @@ Install the module in your Odoo system.
3845
Bug Tracker
3946
===========
4047

41-
Bugs are tracked on `GitHub Issues <https://github.com/escodoo/account-addons/issues>`_.
48+
Bugs are tracked on `GitHub Issues <https://github.com/Escodoo/account-addons/issues>`_.
4249
In case of trouble, please check there if your issue has already been reported.
43-
If you spotted it first, help us smashing it by providing a detailed and welcomed
44-
`feedback <https://github.com/escodoo/account-addons/issues/new?body=module:%20sync_multi_company_bank_account%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
50+
If you spotted it first, help us to smash it by providing a detailed and welcomed
51+
`feedback <https://github.com/Escodoo/account-addons/issues/new?body=module:%20sync_multi_company_bank_account%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
4552

4653
Do not contact contributors directly about support or help with technical issues.
4754

@@ -59,10 +66,11 @@ Contributors
5966
* `Escodoo <https://www.escodoo.com.br>`_:
6067

6168
* Marcel Savegnago <marcel.savegnago@escodoo.com.br>
69+
* Cristiano Mafra Junior <cristiano.mafra@escodoo.com.br>
6270

6371
Maintainers
6472
~~~~~~~~~~~
6573

66-
This module is part of the `escodoo/account-addons <https://github.com/escodoo/account-addons/tree/14.0/sync_multi_company_bank_account>`_ project on GitHub.
74+
This module is part of the `Escodoo/account-addons <https://github.com/Escodoo/account-addons/tree/16.0/sync_multi_company_bank_account>`_ project on GitHub.
6775

6876
You are welcome to contribute.

sync_multi_company_bank_account/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Sync Multi Company Bank Account",
66
"summary": """
77
Sync Multi Company Bank Accounts""",
8-
"version": "15.0.1.0.0",
8+
"version": "16.0.1.0.0",
99
"license": "AGPL-3",
1010
"author": "Escodoo",
1111
"website": "https://github.com/Escodoo/account-addons",

sync_multi_company_bank_account/models/res_company.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright 2023 - TODAY, Marcel Savegnago <marcel.savegnago@escodoo.com.br>
2+
# Copyright 2025 - TODAY, Cristiano Mafra Junior <cristiano.mafra@escodoo.com.br>
23
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
34

45
from odoo import api, models
@@ -21,11 +22,21 @@ def copy_bank_accounts(self):
2122
)
2223

2324
for bank_account in bank_accounts:
24-
bank_account.sudo().with_context(no_sync_partner_bank=True).copy(
25-
default={
26-
"company_id": self.id,
27-
}
25+
dst_partner = self.partner_id
26+
existing = self.env["res.partner.bank"].search(
27+
[
28+
("partner_id", "=", dst_partner.id),
29+
("sanitized_acc_number", "=", bank_account.sanitized_acc_number),
30+
],
31+
limit=1,
2832
)
33+
if not existing:
34+
bank_account.sudo().with_context(no_sync_partner_bank=True).copy(
35+
default={
36+
"company_id": self.id,
37+
"partner_id": dst_partner.id,
38+
}
39+
)
2940

3041
@api.model
3142
def create(self, vals):

sync_multi_company_bank_account/models/res_partner_bank.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55

66

77
class ResPartnerBank(models.Model):
8-
98
_inherit = "res.partner.bank"
109

1110
@api.model
1211
def create(self, vals):
13-
res = super(ResPartnerBank, self).create(vals)
12+
res = super().create(vals)
1413
if not self.env.context.get("no_sync_partner_bank"):
1514
res.sudo()._sync_partner_bank(vals)
1615
return res
1716

1817
def write(self, vals):
1918
old_acc_number = self.acc_number
2019
old_partner_id = self.partner_id.id
21-
res = super(ResPartnerBank, self).write(vals)
20+
res = super().write(vals)
2221
if not self.env.context.get("no_sync_partner_bank"):
2322
self.sudo()._sync_partner_bank(vals, old_acc_number, old_partner_id)
2423
return res
@@ -28,11 +27,15 @@ def unlink(self):
2827
for bank in self:
2928
for company in self.env["res.company"].search([]):
3029
if company.id != bank.company_id.id:
30+
dst_partner = company.partner_id
3131
partner_bank = self.env["res.partner.bank"].search(
3232
[
33-
("partner_id", "=", bank.partner_id.id),
34-
("acc_number", "=", bank.acc_number),
35-
("company_id", "=", company.id),
33+
("partner_id", "=", dst_partner.id),
34+
(
35+
"sanitized_acc_number",
36+
"=",
37+
bank.sanitized_acc_number,
38+
),
3639
],
3740
limit=1,
3841
)
@@ -46,17 +49,25 @@ def _sync_partner_bank(self, vals, old_acc_number=None, old_partner_id=None):
4649
for rec in self:
4750
for company in self.env["res.company"].search([]):
4851
if company.id != rec.company_id.id:
52+
dst_partner = company.partner_id
53+
4954
partner_bank = self.env["res.partner.bank"].search(
5055
[
51-
("partner_id", "=", old_partner_id or rec.partner_id.id),
52-
("acc_number", "=", old_acc_number or rec.acc_number),
53-
("company_id", "=", company.id),
56+
("partner_id", "=", dst_partner.id),
57+
(
58+
"sanitized_acc_number",
59+
"=",
60+
rec.sanitized_acc_number,
61+
),
5462
],
5563
limit=1,
5664
)
5765
if partner_bank:
5866
partner_bank.with_context(no_sync_partner_bank=True).write(vals)
5967
else:
60-
rec.with_context(no_sync_partner_bank=True).copy(
61-
{"company_id": company.id}
68+
rec.sudo().with_context(no_sync_partner_bank=True).copy(
69+
{
70+
"company_id": company.id,
71+
"partner_id": dst_partner.id,
72+
}
6273
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["whool"]
3+
build-backend = "whool.buildapi"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
* `Escodoo <https://www.escodoo.com.br>`_:
22

33
* Marcel Savegnago <marcel.savegnago@escodoo.com.br>
4+
* Cristiano Mafra Junior <cristiano.mafra@escodoo.com.br>

sync_multi_company_bank_account/static/description/index.html

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
21
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
32
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
43
<head>
54
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6-
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
7-
<title>Sync Multi Company Bank Account</title>
5+
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6+
<title>README.rst</title>
87
<style type="text/css">
98

109
/*
1110
:Author: David Goodger (goodger@python.org)
12-
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
11+
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
1312
:Copyright: This stylesheet has been placed in the public domain.
1413
1514
Default cascading style sheet for the HTML output of Docutils.
1615
17-
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
16+
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
1817
customize this style sheet.
1918
*/
2019

@@ -360,65 +359,72 @@
360359
</style>
361360
</head>
362361
<body>
363-
<div class="document" id="sync-multi-company-bank-account">
364-
<h1 class="title">Sync Multi Company Bank Account</h1>
362+
<div class="document">
365363

364+
365+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme"><img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" /></a>
366+
<div class="section" id="sync-multi-company-bank-account">
367+
<h1>Sync Multi Company Bank Account</h1>
366368
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367369
!! This file is generated by oca-gen-addon-readme !!
368370
!! changes will be overwritten. !!
371+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
372+
!! source digest: sha256:2cb1117e7eeae500370f540a90494e7d195242b9492ae0ffc2f344857e97e33a
369373
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
370-
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/escodoo/account-addons/tree/14.0/sync_multi_company_bank_account"><img alt="escodoo/account-addons" src="https://img.shields.io/badge/github-escodoo%2Faccount--addons-lightgray.png?logo=github" /></a></p>
374+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/Escodoo/account-addons/tree/16.0/sync_multi_company_bank_account"><img alt="Escodoo/account-addons" src="https://img.shields.io/badge/github-Escodoo%2Faccount--addons-lightgray.png?logo=github" /></a></p>
371375
<p>The Multi-Company Bank Account Synchronization module aims to ensure that all companies within a business group have the same bank accounts registered and updated, so that all of them can carry out financial transactions without data compatibility issues.</p>
372376
<p>The synchronization is performed automatically, so that the addition, update or deletion of a bank account in one of the companies is reflected in all other companies of the group. To ensure data integrity, the module also checks whether the bank account can be deleted without compromising the integrity of the records in other companies.</p>
373377
<p><strong>Table of contents</strong></p>
374378
<div class="contents local topic" id="contents">
375379
<ul class="simple">
376-
<li><a class="reference internal" href="#usage" id="id1">Usage</a></li>
377-
<li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li>
378-
<li><a class="reference internal" href="#credits" id="id3">Credits</a><ul>
379-
<li><a class="reference internal" href="#authors" id="id4">Authors</a></li>
380-
<li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li>
381-
<li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li>
380+
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
381+
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
382+
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
383+
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
384+
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
385+
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
382386
</ul>
383387
</li>
384388
</ul>
385389
</div>
386390
<div class="section" id="usage">
387-
<h1><a class="toc-backref" href="#id1">Usage</a></h1>
391+
<h2><a class="toc-backref" href="#toc-entry-1">Usage</a></h2>
388392
<p>To use the Multi-Company Bank Account Synchronization module, follow these steps:</p>
389393
<p>Install the module in your Odoo system.</p>
390394
</div>
391395
<div class="section" id="bug-tracker">
392-
<h1><a class="toc-backref" href="#id2">Bug Tracker</a></h1>
393-
<p>Bugs are tracked on <a class="reference external" href="https://github.com/escodoo/account-addons/issues">GitHub Issues</a>.
396+
<h2><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h2>
397+
<p>Bugs are tracked on <a class="reference external" href="https://github.com/Escodoo/account-addons/issues">GitHub Issues</a>.
394398
In case of trouble, please check there if your issue has already been reported.
395-
If you spotted it first, help us smashing it by providing a detailed and welcomed
396-
<a class="reference external" href="https://github.com/escodoo/account-addons/issues/new?body=module:%20sync_multi_company_bank_account%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
399+
If you spotted it first, help us to smash it by providing a detailed and welcomed
400+
<a class="reference external" href="https://github.com/Escodoo/account-addons/issues/new?body=module:%20sync_multi_company_bank_account%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
397401
<p>Do not contact contributors directly about support or help with technical issues.</p>
398402
</div>
399403
<div class="section" id="credits">
400-
<h1><a class="toc-backref" href="#id3">Credits</a></h1>
404+
<h2><a class="toc-backref" href="#toc-entry-3">Credits</a></h2>
401405
<div class="section" id="authors">
402-
<h2><a class="toc-backref" href="#id4">Authors</a></h2>
406+
<h3><a class="toc-backref" href="#toc-entry-4">Authors</a></h3>
403407
<ul class="simple">
404408
<li>Escodoo</li>
405409
</ul>
406410
</div>
407411
<div class="section" id="contributors">
408-
<h2><a class="toc-backref" href="#id5">Contributors</a></h2>
412+
<h3><a class="toc-backref" href="#toc-entry-5">Contributors</a></h3>
409413
<ul class="simple">
410414
<li><a class="reference external" href="https://www.escodoo.com.br">Escodoo</a>:<ul>
411415
<li>Marcel Savegnago &lt;<a class="reference external" href="mailto:marcel.savegnago&#64;escodoo.com.br">marcel.savegnago&#64;escodoo.com.br</a>&gt;</li>
416+
<li>Cristiano Mafra Junior &lt;<a class="reference external" href="mailto:cristiano.mafra&#64;escodoo.com.br">cristiano.mafra&#64;escodoo.com.br</a>&gt;</li>
412417
</ul>
413418
</li>
414419
</ul>
415420
</div>
416421
<div class="section" id="maintainers">
417-
<h2><a class="toc-backref" href="#id6">Maintainers</a></h2>
418-
<p>This module is part of the <a class="reference external" href="https://github.com/escodoo/account-addons/tree/14.0/sync_multi_company_bank_account">escodoo/account-addons</a> project on GitHub.</p>
422+
<h3><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h3>
423+
<p>This module is part of the <a class="reference external" href="https://github.com/Escodoo/account-addons/tree/16.0/sync_multi_company_bank_account">Escodoo/account-addons</a> project on GitHub.</p>
419424
<p>You are welcome to contribute.</p>
420425
</div>
421426
</div>
422427
</div>
428+
</div>
423429
</body>
424430
</html>

0 commit comments

Comments
 (0)