Skip to content

Commit

Permalink
[MIG] account_invoice_overdue_reminder: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
NICO-SOLUTIONS committed May 16, 2024
1 parent 4ed4ba9 commit 508282a
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 151 deletions.
1 change: 1 addition & 0 deletions account_invoice_overdue_reminder/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ Contributors
------------

- Alexis de Lattre <alexis.delattre@akretion.com>
- Nils Coenen <nils.coenen@nico-solutions.de>

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion account_invoice_overdue_reminder/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Overdue Invoice Reminder",
"version": "16.0.1.3.0",
"version": "17.0.1.0.0",
"category": "Accounting",
"license": "AGPL-3",
"summary": "Simple mail/letter/phone overdue customer invoice reminder ",
Expand Down
8 changes: 4 additions & 4 deletions account_invoice_overdue_reminder/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
_logger = logging.getLogger(__name__)


def pre_init_hook(cr):
def pre_init_hook(env):
_logger.info(
"Pre-creating column overdue_reminder_last_date for table account_move"
)
cr.execute(
env.cr.execute(
"""
ALTER TABLE account_move
ADD COLUMN IF NOT EXISTS overdue_reminder_last_date Date;
"""
)
_logger.info("Pre-creating column overdue_reminder_counter for table account_move")
cr.execute(
env.cr.execute(
"""
ALTER TABLE account_move
ADD COLUMN IF NOT EXISTS overdue_reminder_counter INTEGER DEFAULT 0;
ALTER TABLE account_move ALTER COLUMN overdue_reminder_counter DROP DEFAULT;
"""
)
_logger.info("Pre-creating column no_overdue_reminder for table account_move")
cr.execute(
env.cr.execute(
"""
ALTER TABLE account_move
ADD COLUMN IF NOT EXISTS no_overdue_reminder BOOL DEFAULT False;
Expand Down
1 change: 1 addition & 0 deletions account_invoice_overdue_reminder/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Alexis de Lattre \<<alexis.delattre@akretion.com>\>
- Nils Coenen \<<nils.coenen@nico-solutions.de>\>
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -503,6 +502,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<ul class="simple">
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li>
<li>Nils Coenen &lt;<a class="reference external" href="mailto:nils.coenen&#64;nico-solutions.de">nils.coenen&#64;nico-solutions.de</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
<field name="arch" type="xml">
<form>
<group name="main">
<field
name="counter"
attrs="{'invisible': [('action_reminder_type', '=', 'phone')]}"
/>
<field name="counter" invisible="action_reminder_type == 'phone'" />
<field
name="action_commercial_partner_id"
invisible="not context.get('overdue_reminder_main_view')"
Expand All @@ -31,15 +28,15 @@
<field name="action_reminder_type" />
<field
name="action_mail_id"
attrs="{'invisible': [('action_reminder_type', '!=', 'mail')]}"
invisible="action_reminder_type != 'mail'"
/>
<field
name="action_mail_cc"
attrs="{'invisible': [('action_reminder_type', '!=', 'mail')]}"
invisible="action_reminder_type != 'mail'"
/>
<field
name="action_mail_state"
attrs="{'invisible': [('action_reminder_type', '!=', 'mail')]}"
invisible="action_reminder_type != 'mail'"
/>
</group>
<group string="Info/Result" name="result">
Expand All @@ -59,10 +56,7 @@
<group name="main">
<field name="invoice_id" />
<field name="action_reminder_type" invisible="1" />
<field
name="counter"
attrs="{'invisible': [('action_reminder_type', '=', 'phone')]}"
/>
<field name="counter" invisible="action_reminder_type == 'phone'" />
</group>
</form>
</field>
Expand All @@ -73,10 +67,7 @@
<field name="model">account.invoice.overdue.reminder</field>
<field name="arch" type="xml">
<tree>
<field
name="counter"
attrs="{'invisible': [('action_reminder_type', '=', 'phone')]}"
/>
<field name="counter" invisible="action_reminder_type == 'phone'" />
<field name="action_date" />
<field
name="action_partner_id"
Expand Down
10 changes: 3 additions & 7 deletions account_invoice_overdue_reminder/views/account_move.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@
<field name="inherit_id" ref="account.view_move_form" />
<field name="arch" type="xml">
<div role="alert" position="after">
<div
class="alert alert-warning"
role="alert"
attrs="{'invisible': [('overdue', '=', False)]}"
>
<div class="alert alert-warning" role="alert" invisible="not overdue">
This customer invoice is overdue.
<button
name="%(overdue_reminder_start_action)d"
string="Send an overdue reminder"
type="action"
context="{'default_partner_ids': [commercial_partner_id]}"
attrs="{'invisible': ['|', '|', ('overdue', '=', False), ('no_overdue_reminder', '=', True), ('overdue_remind_sent', '=', True)]}"
invisible="not overdue or no_overdue_reminder or overdue_remind_sent"
class="oe_link"
/>

Expand All @@ -34,7 +30,7 @@
<page
name="overdue_reminder"
string="Overdue Reminder"
attrs="{'invisible': [('overdue', '=', False)]}"
invisible="not overdue"
>
<group name="overdue_reminder_main" col="4">
<field name="overdue_reminder_counter" />
Expand Down
15 changes: 3 additions & 12 deletions account_invoice_overdue_reminder/views/overdue_reminder_action.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,9 @@
<field name="date" />
<field name="user_id" />
<field name="reminder_type" />
<field
name="mail_id"
attrs="{'invisible': [('reminder_type', '!=', 'mail')]}"
/>
<field
name="mail_cc"
attrs="{'invisible': [('reminder_type', '!=', 'mail')]}"
/>
<field
name="mail_state"
attrs="{'invisible': [('reminder_type', '!=', 'mail')]}"
/>
<field name="mail_id" invisible="reminder_type != 'mail'" />
<field name="mail_cc" invisible="reminder_type != 'mail'" />
<field name="mail_state" invisible="reminder_type != 'mail'" />
</group>
<group name="result" string="Info/Result">
<field name="result_id" widget="selection" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active"
/>
<group name="main">
<field name="name" />
Expand Down
4 changes: 2 additions & 2 deletions account_invoice_overdue_reminder/views/res_partner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<group
name="overdue_reminder"
string="Overdue Reminder"
attrs="{'invisible': [('customer_rank', '&lt;=', 0)]}"
invisible="customer_rank &lt;= 0"
>
<field name="no_overdue_reminder" />
<field name="customer_rank" invisible="1" />
Expand All @@ -27,7 +27,7 @@

<record id="action_overdue_reminder_action" model="ir.actions.act_window">
<field name="name">Overdue Reminder Actions</field>
<field name="context">{'search_default_commercial_partner_id': [active_id]}</field>
<field name="context">{'search_default_commercial_partner_id': [id]}</field>
<field name="res_model">overdue.reminder.action</field>
<field name="binding_model_id" ref="base.model_res_partner" />
<field name="binding_view_types">form</field>
Expand Down
45 changes: 18 additions & 27 deletions account_invoice_overdue_reminder/wizard/overdue_reminder_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,38 +567,29 @@ def validate_mail(self):
def generate_mail_vals(self):
self.ensure_one()
xmlid = self._get_overdue_invoice_reminder_template()
mvals = self.env.ref(xmlid).generate_email(
self.id, ["email_from", "email_to", "partner_to", "reply_to"]
)
template = self.env.ref(xmlid)
cc_list = [p.email for p in self.mail_cc_partner_ids if p.email]
if mvals.get("email_cc"):
cc_list.append(mvals["email_cc"])
mvals.update(
{
"subject": self.mail_subject,
"body_html": self.mail_body,
"email_cc": ", ".join(cc_list),
"model": "res.partner",
"res_id": self.commercial_partner_id.id,
}
)
mvals.pop("attachment_ids", None)
mvals.pop("attachments", None)
mail = self.env["mail.mail"].sudo().create(mvals)
if template.email_cc:
cc_list.append(template.email_cc)
cc = ", ".join(cc_list)
mail_vals = {
"email_from": self.user_id.email,
"email_to": self.partner_id.email,
"subject": self.mail_subject,
"body_html": self.mail_body,
"email_cc": cc,
"model": "res.partner",
"res_id": self.commercial_partner_id.id,
}
mail_vals.pop("attachment_ids", None)
mail_vals.pop("attachments", None)
mail = self.env["mail.mail"].sudo().create(mail_vals)

if self.company_id.overdue_reminder_attach_invoice:
attachment_ids = self._get_attachment_ids(mail)
mail.write({"attachment_ids": [(6, 0, attachment_ids)]})
vals = {"mail_id": mail.id}
return vals

def validate_phone(self):
self.ensure_one()
assert self.reminder_type == "phone"
vals = {
"result_id": self.result_id.id or False,
"result_notes": self.result_notes,
}
return vals
return {"mail_id": mail.id}

def validate_post(self):
self.ensure_one()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<field name="company_id" invisible="1" />
</group>
<group
attrs="{'invisible': [('warn_unreconciled_move_line_ids', '=', [])]}"
invisible="not warn_unreconciled_move_line_ids"
string="WARNING: unreconciled payments/refunds"
col="1"
>
Expand Down Expand Up @@ -157,8 +157,8 @@
string="Amount Due"
sum="Amount Due"
/>
<field name="currency_id" invisible="1" />
<field name="company_currency_id" invisible="1" />
<field name="currency_id" column_invisible="1" />
<field name="company_currency_id" column_invisible="1" />
<field
name="overdue_reminder_counter"
string="Current Remind Counter"
Expand All @@ -167,47 +167,35 @@
name="overdue_reminder_last_date"
string="Last Reminder"
/>
<field name="state" invisible="1" />
<field name="payment_state" invisible="1" />
<field name="state" column_invisible="1" />
<field name="payment_state" column_invisible="1" />
</tree>
</field>
</group>
<group name="reminder_type">
<field name="reminder_type" />
</group>
<group
name="phone"
attrs="{'invisible': [('reminder_type', '!=', 'phone')]}"
>
<group name="phone" invisible="reminder_type != 'phone'">
<field
name="result_id"
widget="selection"
attrs="{'required': [('reminder_type', '=', 'phone')]}"
required="reminder_type == 'phone'"
/>
<field name="result_notes" />
<field name="create_activity" />
</group>
<group
name="phone_activity"
attrs="{'invisible': ['|', ('reminder_type', '!=', 'phone'), ('create_activity', '=', False)]}"
invisible="reminder_type != 'phone' or create_activity == 'False'"
col="4"
>
<field
name="activity_type_id"
attrs="{'required': [('create_activity', '=', True)]}"
/>
<field
name="activity_deadline"
attrs="{'required': [('create_activity', '=', True)]}"
/>
<field name="activity_type_id" required="create_activity" />
<field name="activity_deadline" required="create_activity" />
<field name="activity_summary" />
<field
name="activity_user_id"
attrs="{'required': [('create_activity', '=', True)]}"
/>
<field name="activity_user_id" required="create_activity" />
<field name="activity_note" colspan="4" nolabel="1" />
</group>
<group name="mail" attrs="{'invisible': [('reminder_type', '!=', 'mail')]}">
<group name="mail" invisible="reminder_type != 'mail'">
<field
name="mail_cc_partner_ids"
domain="[('id', 'child_of', commercial_partner_id), ('id', '!=', partner_id), ('email', '!=', False)]"
Expand All @@ -216,7 +204,7 @@
<field name="mail_subject" />
<field name="mail_body" colspan="2" nolabel="1" />
</group>
<group attrs="{'invisible': [('reminder_type', '!=', 'post')]}" col="1">
<group invisible="reminder_type != 'post'" col="1">
<button
name="print_letter"
type="object"
Expand Down Expand Up @@ -272,7 +260,7 @@
<field name="reminder_type" />
<field name="invoice_ids" />
<field name="warn_unreconciled_move_line_ids" />
<field name="state" invisible="1" />
<field name="state" column_invisible="1" />
</tree>
</field>
</record>
Expand Down Expand Up @@ -300,7 +288,8 @@
<field name="update_action" />
<field
name="reminder_type"
attrs="{'required': [('update_action', '=', 'reminder_type')], 'invisible': [('update_action', '!=', 'reminder_type')]}"
required="update_action == reminder_type"
invisible="update_action != reminder_type"
/>
</group>
<footer>
Expand Down
Loading

0 comments on commit 508282a

Please sign in to comment.