Skip to content

Commit

Permalink
Merge PR OCA#86 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Sep 21, 2020
2 parents 0c607c0 + 4359564 commit 1482211
Show file tree
Hide file tree
Showing 27 changed files with 450 additions and 159 deletions.
17 changes: 13 additions & 4 deletions account_credit_control/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,14 @@ You are able to specify a particular policy for one partner or one invoice.
Usage
=====

Menu entries are located in ``Invoicing > Adviser > Credit Control``.
Menu entries are located in *Invoicing > Adviser > Credit Control*.

Create a new "run" in the ``Credit Control Run`` menu with the controlling date.
Then, use the ``Compute Credit Lines`` button. All the credit control lines will
be generated. You can find them in the ``Credit Control Lines`` menu.
Create a new "run" in the *Credit Control Run* menu with the controlling date.
Then, use the *Compute Credit Lines* button. All the credit control lines will
be generated. You can find them in the *Credit Control Lines* menu.

On each generated line, you have many choices:

* Send a email
* Print a letter
* Change the state (so you can ignore or reopen lines)
Expand All @@ -68,6 +69,13 @@ On each generated line, you have many choices:
* Mark one line as Manual followup will also mark all the lines of the
partner. The partner will be visible in "Do Manual Follow-ups".

Once your lines are properly set up, go back to the "run" and click on
*Run channel action* to massively generate and queue communication emails or
letters for all linked lines.

Then, use the *Communications* smart button to see all email communication
processes that have been created and follow them.

Bug Tracker
===========

Expand Down Expand Up @@ -105,6 +113,7 @@ Contributors
* Vicent Cubells
* Ernesto Tejeda
* Pedro M. Baeza
* Jairo Llopis

Maintainers
~~~~~~~~~~~
Expand Down
2 changes: 2 additions & 0 deletions account_credit_control/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# Views
"views/account_invoice.xml",
"views/credit_control_line.xml",
"views/credit_control_communication.xml",
"views/credit_control_policy.xml",
"views/credit_control_run.xml",
"views/res_company.xml",
Expand All @@ -49,6 +50,7 @@
"wizard/credit_control_printer_view.xml",
"wizard/credit_control_policy_changer_view.xml",
],
"demo": ["demo/res_users.xml"],
'installable': True,
'license': 'AGPL-3',
'application': True,
Expand Down
26 changes: 16 additions & 10 deletions account_credit_control/data/data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@
<record id="email_template_credit_control_base" model="mail.template">
<field name="name">Credit Control Email</field>
<field name="email_from">${user.company_id.email or ''}</field>
<field name="subject">Credit Control:
(${object.current_policy_level.name or 'n/a'})
</field>
<field name="email_to">${object.get_email() or ''}</field>
<field name="subject">Credit Control: (${object.policy_level_id.name or 'n/a'})</field>
<field name="partner_to">${object.get_emailing_contact().id or ''}</field>
<field name="model_id" ref="model_credit_control_communication"/>
<field name="auto_delete" eval="True"/>
<field name="lang">
${object.get_contact_address().lang or 'en_US'}
</field>
<field name="auto_delete" eval="False"/>
<field name="lang">${object.contact_address_id.lang or 'en_US'}</field>
<field name="report_template" ref="credit_control_summary"/>
<field name="body_html"><![CDATA[
Dear ${object.contact_address.name or ''}
Dear ${object.contact_address_id.name or ''}
<br/>
<br/>
${object.current_policy_level.custom_mail_text | safe}
${object.policy_level_id.custom_mail_text | safe}
]]></field>
</record>

Expand Down Expand Up @@ -221,4 +217,14 @@
<field name="credit_policy_id" ref="credit_control_3_time"/>
</record>

<!-- Mail subtypes -->
<record id="mt_request" model="mail.message.subtype">
<field name="name">Credit control</field>
<field name="description">Credit control notification</field>
<field name="res_model">account.credit.control.communication</field>
<field name="default" eval="True"/>
<field name="hidden" eval="False"/>
<field name="internal" eval="False"/>
</record>

</odoo>
11 changes: 11 additions & 0 deletions account_credit_control/demo/res_users.xml
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 account_credit_control/migrations/12.0.3.0.0/post-migration.py
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 account_credit_control/migrations/12.0.3.0.0/pre-migration.py
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",
)
2 changes: 2 additions & 0 deletions account_credit_control/models/__init__.py
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
Loading

0 comments on commit 1482211

Please sign in to comment.