-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '14.0-imp-cooperator_multi_company_subscription_journal'…
… into 14.0-imp-cooperator_multi_company
- Loading branch information
Showing
10 changed files
with
204 additions
and
59 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
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
60 changes: 60 additions & 0 deletions
60
cooperator/migrations/14.0.1.7.0/post-set_subscription_journal_on_company.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,60 @@ | ||
# Copyright 2023 Coop IT Easy SC | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
import logging | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def migrate(cr, version): | ||
# the subscription journal is now set on the company instead of using the | ||
# global cooperator.subscription_journal xml id. | ||
cr.execute( | ||
""" | ||
select id, res_id | ||
from ir_model_data | ||
where | ||
module = 'cooperator' and | ||
name = 'subscription_journal' | ||
""" | ||
) | ||
row = cr.fetchone() | ||
xml_id = row[0] | ||
journal_id = row[1] | ||
cr.execute( | ||
""" | ||
update res_company as rc | ||
set subscription_journal_id = aj.id | ||
from account_journal as aj | ||
where | ||
rc.subscription_journal_id is null and | ||
aj.company_id = rc.id and | ||
(aj.id = %s or aj.code = 'SUBJ') | ||
""", | ||
(journal_id,), | ||
) | ||
cr.execute( | ||
""" | ||
select id | ||
from res_company | ||
where subscription_journal_id is null | ||
order by id | ||
""" | ||
) | ||
company_rows = cr.fetchall() | ||
company_ids = [row[0] for row in company_rows] | ||
if company_ids: | ||
_logger.warning( | ||
"Could not find the subscription journal for companies with ids: " | ||
"{company_ids}. Please check and set it manually if needed.".format( | ||
company_ids=company_ids | ||
) | ||
) | ||
cr.execute( | ||
""" | ||
delete | ||
from ir_model_data | ||
where id = %s | ||
""", | ||
(xml_id,), | ||
) |
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
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,12 @@ | ||
# Copyright 2023 Coop IT Easy SC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import models | ||
|
||
|
||
class AccountChartTemplate(models.Model): | ||
_inherit = "account.chart.template" | ||
|
||
def _load(self, sale_tax_rate, purchase_tax_rate, company): | ||
super()._load(sale_tax_rate, purchase_tax_rate, company) | ||
company._init_cooperator_data() |
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
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
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 @@ | ||
Create subscription journal per company. |
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
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