-
Notifications
You must be signed in to change notification settings - Fork 6
/
hooks.py
25 lines (22 loc) · 1.01 KB
/
hooks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright 2023 - TODAY, Marcel Savegnago <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import SUPERUSER_ID, api
def post_init_hook(cr, registry):
env = api.Environment(cr, SUPERUSER_ID, {})
cr.execute("SELECT * FROM res_partner_bank")
res_partner_bank = []
res_partner_bank = cr.dictfetchall()
if res_partner_bank:
bank_accounts = env["res.partner.bank"]
companies = env["res.company"].search([])
for company in companies:
bank_accounts |= company.bank_ids
for bank_account in bank_accounts:
for company in companies:
if company.id != bank_account.company_id.id:
if bank_account.acc_number not in company.bank_ids.mapped(
"acc_number"
):
bank_account.sudo().with_context(
no_sync_partner_bank=True
).copy({"company_id": company.id})