forked from OCA/credit-control
-
Notifications
You must be signed in to change notification settings - Fork 0
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 pedrobaeza
- Loading branch information
Showing
27 changed files
with
450 additions
and
159 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
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2020 Tecnativa - Jairo Llopis | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
|
||
<data noupdate="1"> | ||
|
||
<record id="base.user_demo" model="res.users"> | ||
<field name="groups_id" eval="[(4, ref('group_account_credit_control_user'))]"/> | ||
</record> | ||
|
||
</data> |
47 changes: 47 additions & 0 deletions
47
account_credit_control/migrations/12.0.3.0.0/post-migration.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,47 @@ | ||
# Copyright 2020 Tecnativa - Jairo Llopis | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
# Update mail.template records for credit.control.communication | ||
communication_model = env.ref( | ||
"account_credit_control.model_credit_control_communication" | ||
) | ||
replacements = ( | ||
("object.contact_address", "object.contact_address_id"), | ||
("object.current_policy_level", "object.policy_level_id"), | ||
("object.get_contact_address()", "object.contact_address_id"), | ||
) | ||
for from_, to in replacements: | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE mail_template SET | ||
subject = REPLACE(subject, %(from)s, %(to)s), | ||
body_html = REPLACE(body_html, %(from)s, %(to)s) | ||
WHERE model_id = %(model_id)s | ||
""", | ||
{"from": from_, "to": to, "model_id": communication_model.id}, | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE ir_translation SET | ||
value = REPLACE(value, %(from)s, %(to)s) | ||
WHERE module = 'account_credit_control' | ||
AND name ilike 'mail.template%%' | ||
""", | ||
{"from": from_, "to": to}, | ||
) | ||
# Update the recipients config just for this template, others should be | ||
# manually changed if desired althoug they'll keep working as there's | ||
# backward compatibility with the old method | ||
communication_template = env.ref( | ||
"account_credit_control.email_template_credit_control_base") | ||
communication_template.email_to = False | ||
communication_template.partner_to = ( | ||
"${object.get_emailing_contact().id or ''}") |
24 changes: 24 additions & 0 deletions
24
account_credit_control/migrations/12.0.3.0.0/pre-migration.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,24 @@ | ||
# Copyright 2020 Tecnativa - Jairo Llopis | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
# Preserve mail_message_id historic data from credit.control.line records | ||
mail_message_legacy = openupgrade.get_legacy_name("mail_message_id") | ||
openupgrade.copy_columns( | ||
env.cr, | ||
{ | ||
"credit_control_line": [ | ||
("mail_message_id", mail_message_legacy, None), | ||
] | ||
}, | ||
) | ||
# Vacuum meaningless transient data from credit.control.communication | ||
openupgrade.logged_query( | ||
env.cr, | ||
"DELETE FROM credit_control_communication", | ||
) |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). | ||
from . import account_account | ||
from . import account_invoice | ||
from . import credit_control_communication | ||
from . import credit_control_line | ||
from . import credit_control_policy | ||
from . import credit_control_run | ||
from . import mail_mail | ||
from . import mail_message | ||
from . import res_company | ||
from . import res_partner | ||
from . import res_config_settings |
Oops, something went wrong.