If you have any question, do not hesitate to contact us.
${object.user_id.name} ${object.user_id.user_email and '<%s>'%(object.user_id.user_email) or ''}
\n"
-" ${object.company_id.name}
\n"
-" % if object.company_id.street:\n"
-" ${object.company_id.street or ''}
\n"
-"\n"
-" % endif\n"
-"\n"
-" % if object.company_id.street2:\n"
-" ${object.company_id.street2}
\n"
-" % endif\n"
-" % if object.company_id.city or object.company_id.zip:\n"
-" ${object.company_id.zip or ''} ${object.company_id.city or ''}
\n"
-" % endif\n"
-" % if object.company_id.country_id:\n"
-" ${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}
\n"
-" % endif\n"
-" % if object.company_id.phone:\n"
-" Phone: ${object.company_id.phone}
\n"
-" % endif\n"
-" % if object.company_id.website:\n"
-" ${object.company_id.website or ''}
\n"
-" % endif\n"
-" "
-msgstr ""
-"\n"
-" <%page args=\"object, user=None, ctx=None, quote=None, format_exception=True, mode='mail'\" />\n"
-" %if mode != 'pdf':\n"
-" \n"
-" \n"
-" %endif\n"
-"
\n"
-"\n"
-"
Cher ${object.partner_id.name or ''},
\n"
-"\n"
-"
${object.current_policy_level.custom_text}\n"
-"\n"
-"
\n"
-" Summary\n"
-" \n"
-" | Date due | \n"
-" Somme due | \n"
-" Solde du | \n"
-" Numéro de facture | \n"
-"
\n"
-"%for line in object.credit_control_line_ids:\n"
-" \n"
-" | ${line.date_due} | \n"
-" ${line.amount_due} | \n"
-" ${line.balance_due} | \n"
-" %if line.invoice_id:\n"
-" ${line.invoice_id.number} | \n"
-" %else:\n"
-" n/a | \n"
-" %endif\n"
-"%endfor\n"
-"
\n"
-"
\n"
-"
\n"
-"\n"
-"
Si vous avez des questions n'hésitez pas à nous contacter.
\n"
-"\n"
-"
Merci d'avoir choisi ${object.company_id.name}!
\n"
-"\n"
-" -- more info here --\n"
-"
${object.user_id.name} ${object.user_id.user_email and '<%s>'%(object.user_id.user_email) or ''}
\n"
-" ${object.company_id.name}
\n"
-" % if object.company_id.street:\n"
-" ${object.company_id.street or ''}
\n"
-"\n"
-" % endif\n"
-"\n"
-" % if object.company_id.street2:\n"
-" ${object.company_id.street2}
\n"
-" % endif\n"
-" % if object.company_id.city or object.company_id.zip:\n"
-" ${object.company_id.zip or ''} ${object.company_id.city or ''}
\n"
-" % endif\n"
-" % if object.company_id.country_id:\n"
-" ${object.company_id.state_id and ('%s, ' % object.company_id.state_id.name) or ''} ${object.company_id.country_id.name or ''}
\n"
-" % endif\n"
-" % if object.company_id.phone:\n"
-" Téléphone : ${object.company_id.phone}
\n"
-" % endif\n"
-" % if object.company_id.website:\n"
-" ${object.company_id.website or ''}
\n"
-" % endif\n"
-" "
-
#. module: account_credit_control
#: constraint:account.move.line:0
msgid "Company must be the same for its related account and period."
@@ -962,4 +829,3 @@ msgstr "Niveau de créance"
#~ msgstr "Contrôle de crédit"
#~ msgid "New lines"
#~ msgstr "Nouvelles lignes"
-
diff --git a/account_credit_control/line.py b/account_credit_control/line.py
index 7afb553b1..46ce0a35b 100644
--- a/account_credit_control/line.py
+++ b/account_credit_control/line.py
@@ -75,7 +75,7 @@ class CreditControlLine(orm.Model):
'partner_id': fields.many2one('res.partner', "Partner", required=True),
'amount_due': fields.float('Due Amount Tax incl.', required=True, readonly=True),
'balance_due': fields.float('Due balance', required=True, readonly=True),
- 'mail_message_id': fields.many2one('mail.message', 'Sent Email', readonly=True),
+ 'mail_message_id': fields.many2one('mail.mail', 'Sent Email', readonly=True),
'move_line_id': fields.many2one('account.move.line', 'Move line',
required=True, readonly=True),
diff --git a/account_credit_control/mail.py b/account_credit_control/mail.py
new file mode 100644
index 000000000..24ce0faac
--- /dev/null
+++ b/account_credit_control/mail.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Nicolas Bessi, Guewen Baconnier
+# Copyright 2012 Camptocamp SA
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+from openerp.osv import orm, fields
+
+class Mail(orm.Model):
+ _inherit = 'mail.mail'
+
+ # use HTML fields instead of text
+ _columns = {'body_html': fields.html('Rich-text Contents',
+ help="Rich-text/HTML message"),}
diff --git a/account_credit_control/report/credit_control_summary.html.mako b/account_credit_control/report/credit_control_summary.html.mako
index 5f3b602f4..e3a597cd0 100644
--- a/account_credit_control/report/credit_control_summary.html.mako
+++ b/account_credit_control/report/credit_control_summary.html.mako
@@ -2,16 +2,156 @@
%for comm in objects :
+
+
+ | ${comm.partner_id.title and comm.partner_id.title.name or ''} ${comm.partner_id.name } |
+ %for part in comm.partner_id.contact_address.split("\n")[1:]:
+ %if part:
+ | ${part} |
+ %endif
+ %endfor
+
+
+
+
+
+
+
+
<%
setLang(comm.partner_id.lang)
current_uri = '%s_policy_template' % (comm.partner_id.lang)
if not context.lookup.has_template(current_uri):
- context.lookup.put_string(current_uri, comm.current_policy_level.email_template_id.body_html)
+ # awfully horrible we add page tags here beacause openerp replaced
+ # mako by Jinga but not everywere so they sandbox mako into jinga
+ # and jinga prevent %page tag to wwork
+ context.lookup.put_string(current_uri,
+ """<%page args="object, user=None, ctx=None, quote=None, format_exception=True, mode='email'" />
+ """ + comm.current_policy_level.email_template_id.body_html)
%>
<%include file="${current_uri}" args="object=comm,user=user,ctx=ctx,quote=quote,format_exception=format_exception,mode='pdf'"/>
diff --git a/account_credit_control/scenarios/features/00_credit_control_param.feature b/account_credit_control/scenarios/features/00_credit_control_param.feature
index c32e47fb5..4757bc081 100644
--- a/account_credit_control/scenarios/features/00_credit_control_param.feature
+++ b/account_credit_control/scenarios/features/00_credit_control_param.feature
@@ -10,6 +10,12 @@
Feature: General parameters in order to test the credit control module
+ @deactivate_journal_control
+ Scenario: Journal setup to vaoid unfixed voucher bug
+ Given I execute the SQL commands
+ """
+ UPDATE account_journal SET allow_date = false;
+ """
@account_credit_control_setup_install_modules
Scenario: MODULES INSTALLATION
diff --git a/account_credit_control/scenarios/features/04_credit_control_run_feb.feature b/account_credit_control/scenarios/features/04_credit_control_run_feb.feature
index b76198f3a..563c4e7b7 100644
--- a/account_credit_control/scenarios/features/04_credit_control_run_feb.feature
+++ b/account_credit_control/scenarios/features/04_credit_control_run_feb.feature
@@ -8,7 +8,7 @@
# Features Generic tags (none for all)
##############################################################################
-@account_credit_control_run @account_credit_control_run_feb
+@account_credit_control @account_credit_control_run @account_credit_control_run_feb
Feature: Ensure that mail credit line generation first pass is correct
@@ -23,11 +23,11 @@ Feature: Ensure that mail credit line generation first pass is correct
Given I need a "credit.control.run" with oid: credit_control.run2
And having:
| name | value |
- | date | 2012-02-29 |
+ | date | %Y-02-28 |
When I launch the credit run
Then my credit run should be in state "done"
And the generated credit lines should have the following values:
- | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
- | 360 | 2012-02-15 | Debtors | 3 time policy | 2012-02-29 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 360 | USD |
- | 1000 | 2012-02-17 | Debtors USD | 3 time policy | 2012-02-29 | customer_5_usd | email | 1 | SI_13 | 10 days net | draft | 1000 | USD |
- | 300 | 2012-01-18 | Debtors | 3 time policy | 2012-02-29 | customer_4 | email | 2 | SI_10 | 30 days end of month | draft | 300 | |
+ | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
+ | 360 | %Y-02-15 | Debtors | 3 time policy | %Y-02-28 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 360 | USD |
+ | 1000 | %Y-02-17 | Debtors USD | 3 time policy | %Y-02-28 | customer_5_usd | email | 1 | SI_13 | 10 days net | draft | 1000 | USD |
+ | 300 | %Y-01-18 | Debtors | 3 time policy | %Y-02-28 | customer_4 | email | 2 | SI_10 | 30 days end of month | draft | 300 | |
diff --git a/account_credit_control/scenarios/features/05_credit_control_run_mar.feature b/account_credit_control/scenarios/features/05_credit_control_run_mar.feature
index c43c7fcd5..4de33b86c 100644
--- a/account_credit_control/scenarios/features/05_credit_control_run_mar.feature
+++ b/account_credit_control/scenarios/features/05_credit_control_run_mar.feature
@@ -8,7 +8,7 @@
# Features Generic tags (none for all)
##############################################################################
-@account_credit_control_run @account_credit_control_run_mar
+@account_credit_control @account_credit_control_run @account_credit_control_run_mar
Feature: Ensure that email credit line generation first pass is correct
@@ -20,47 +20,43 @@ Feature: Ensure that email credit line generation first pass is correct
@pay_invoice_si_19_part1
Scenario: I pay a part of the first part of the invoice SI 19,
- Given I need a "account.bank.statement" with oid: scen.voucher_statement_si_19
+ Given I need a "account.bank.statement" with oid: scen.state_control_eur_1
And having:
- | name | value |
- | name | Bk.St.si_19_part1 |
- | date | 2012-03-31 |
- | currency_id | by name: EUR |
- | journal_id | by oid: scen.voucher_eur_journal |
- And the bank statement is linked to period "03/2012"
+ | name | value |
+ | name | Bk.St.si_19_part1 |
+ | date | %Y-03-31 |
+ | journal_id | by oid: scen.eur_journal |
+
And I import invoice "SI_19" using import invoice button
- And I should have a "account.bank.statement.line" with name: SI_19 and amount: 450
- And the line amount should be 450
+ And I should have a "account.bank.statement.line" with name: "SI_19" and amount: "450"
And I set the voucher paid amount to "300"
And I save the voucher
- Then I modify the line amount to 300
- And I should have a "account.bank.statement.line" with name: SI_19 and amount: 1050
- And the line amount should be 1050
+ And I should have a "account.bank.statement.line" with name: "SI_19" and amount: "1050"
And I set the voucher paid amount to "0"
And I save the voucher
- Then I modify the line amount to 0
- And I should have a "account.bank.statement" with oid: scen.voucher_statement_si_19
+ Then I modify the line amount to "0"
+ Given I need a "account.bank.statement" with oid: scen.state_control_eur_1
And I set bank statement end-balance
When I confirm bank statement
Then My invoice "SI_19" is in state "open" reconciled with a residual amount of "1200.0"
- @account_credit_control_run_month
+ @account_credit_control_run_month_mar
Scenario: Create run
Given I need a "credit.control.run" with oid: credit_control.run3
And having:
| name | value |
- | date | 2012-03-31 |
+ | date | %Y-03-31 |
When I launch the credit run
Then my credit run should be in state "done"
And the generated credit lines should have the following values:
- | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
- | 1000 | 2012-02-29 | Debtors | 2 time policy | 2012-03-31 | customer_2 | email | 1 | SI_4 | 30 days end of month | draft | 1000 | |
- | 1000 | 2012-02-17 | Debtors | 2 time policy | 2012-03-31 | customer_3 | email | 1 | SI_7 | 30 days end of month | draft | 1000 | |
- | 700 | 2012-02-29 | Debtors | 3 time policy | 2012-03-31 | customer_4 | email | 1 | SI_10 | 10 days net | draft | 700 | |
- | 450 | 2012-03-15 | Debtors | 3 time policy | 2012-03-31 | customer_4 | email | 1 | SI_12 | 10 days net | draft | 450 | |
- | 1200 | 2012-03-16 | Debtors USD | 3 time policy | 2012-03-31 | customer_5_usd | email | 1 | SI_14 | 10 days net | draft | 1200 | USD |
- | 360 | 2012-02-15 | Debtors | 3 time policy | 2012-03-31 | customer_4 | email | 2 | SI_11 | 30 days end of month | draft | 360 | USD |
- | 1000 | 2012-02-17 | Debtors USD | 3 time policy | 2012-03-31 | customer_5_usd | email | 2 | SI_13 | 30 days end of month | draft | 1000 | USD |
- | 300 | 2012-01-18 | Debtors | 3 time policy | 2012-03-31 | customer_4 | letter | 3 | SI_10 | 10 days last reminder | draft | 300 | |
- | 450 | 2012-03-15 | Debtors | 3 time policy | 2012-03-31 | Donald Duck | email | 1 | SI_18 | 10 days net | draft | 450 | |
- | 150 | 2012-03-15 | Debtors | 3 time policy | 2012-03-31 | Gus Goose | email | 1 | SI_19 | 10 days net | draft | 450 | |
+ | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
+ | 1000 | %Y-02-28 | Debtors | 2 time policy | %Y-03-31 | customer_2 | email | 1 | SI_4 | 30 days end of month | draft | 1000 | |
+ | 1000 | %Y-02-17 | Debtors | 2 time policy | %Y-03-31 | customer_3 | email | 1 | SI_7 | 30 days end of month | draft | 1000 | |
+ | 700 | %Y-02-28 | Debtors | 3 time policy | %Y-03-31 | customer_4 | email | 1 | SI_10 | 10 days net | draft | 700 | |
+ | 450 | %Y-03-15 | Debtors | 3 time policy | %Y-03-31 | customer_4 | email | 1 | SI_12 | 10 days net | draft | 450 | |
+ | 1200 | %Y-03-17 | Debtors USD | 3 time policy | %Y-03-31 | customer_5_usd | email | 1 | SI_14 | 10 days net | draft | 1200 | USD |
+ | 360 | %Y-02-15 | Debtors | 3 time policy | %Y-03-31 | customer_4 | email | 2 | SI_11 | 30 days end of month | draft | 360 | USD |
+ | 1000 | %Y-02-17 | Debtors USD | 3 time policy | %Y-03-31 | customer_5_usd | email | 2 | SI_13 | 30 days end of month | draft | 1000 | USD |
+ | 300 | %Y-01-18 | Debtors | 3 time policy | %Y-03-31 | customer_4 | letter | 3 | SI_10 | 10 days last reminder | draft | 300 | |
+ | 450 | %Y-03-15 | Debtors | 3 time policy | %Y-03-31 | Donald Duck | email | 1 | SI_18 | 10 days net | draft | 450 | |
+ | 150 | %Y-03-15 | Debtors | 3 time policy | %Y-03-31 | Gus Goose | email | 1 | SI_19 | 10 days net | draft | 450 | |
diff --git a/account_credit_control/scenarios/features/06_credit_control_run_apr.feature b/account_credit_control/scenarios/features/06_credit_control_run_apr.feature
index 76c8cec90..300359edd 100644
--- a/account_credit_control/scenarios/features/06_credit_control_run_apr.feature
+++ b/account_credit_control/scenarios/features/06_credit_control_run_apr.feature
@@ -8,7 +8,7 @@
# Features Generic tags (none for all)
##############################################################################
-@account_credit_control_run @account_credit_control_run_apr
+@account_credit_control @account_credit_control_run @account_credit_control_run_apr
Feature: Ensure that email credit line generation first pass is correct
@@ -22,22 +22,23 @@ Feature: Ensure that email credit line generation first pass is correct
Scenario: Create run
Given I need a "credit.control.run" with oid: credit_control.run4
And having:
- | name | value |
- | date | 2012-04-30 |
+ | name | value |
+ | date | %Y-04-30 |
+
When I launch the credit run
Then my credit run should be in state "done"
And the generated credit lines should have the following values:
- | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
- | 1200 | 2012-03-31 | Debtors | 2 time policy | 2012-04-30 | customer_2 | email | 1 | SI_5 | 30 days end of month | draft | 1200 | USD |
- | 1200 | 2012-03-16 | Debtors | 2 time policy | 2012-04-30 | customer_3 | email | 1 | SI_8 | 30 days end of month | draft | 1200 | USD |
- | 840 | 2012-03-31 | Debtors | 3 time policy | 2012-04-30 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 840 | USD |
- | 1500 | 2012-04-14 | Debtors USD | 3 time policy | 2012-04-30 | customer_5_usd | email | 1 | SI_15 | 10 days net | draft | 1500 | USD |
- | 700 | 2012-02-29 | Debtors | 3 time policy | 2012-04-30 | customer_4 | email | 2 | SI_10 | 30 days end of month | draft | 700 | |
- | 450 | 2012-03-15 | Debtors | 3 time policy | 2012-04-30 | customer_4 | email | 2 | SI_12 | 30 days end of month | draft | 450 | USD |
- | 1200 | 2012-03-16 | Debtors USD | 3 time policy | 2012-04-30 | customer_5_usd | email | 2 | SI_14 | 30 days end of month | draft | 1200 | USD |
- | 360 | 2012-02-15 | Debtors | 3 time policy | 2012-04-30 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 360 | USD |
- | 1000 | 2012-02-17 | Debtors USD | 3 time policy | 2012-04-30 | customer_5_usd | letter | 3 | SI_14 | 10 days last reminder | draft | 1000 | USD |
- | 1500 | 2012-04-14 | Debtors | 3 time policy | 2012-04-30 | customer_4 | email | 1 | SI_16 | 10 days net | draft | 1500 | |
- | 1500 | 2012-04-14 | Debtors | 3 time policy | 2012-04-30 | customer_4 | email | 1 | SI_17 | 10 days net | draft | 1500 | |
- | 450 | 2012-03-15 | Debtors | 3 time policy | 2012-04-30 | Donald Duck | email | 2 | SI_18 | 30 days end of month | draft | 450 | |
- | 150 | 2012-03-15 | Debtors | 3 time policy | 2012-04-30 | Gus Goose | email | 2 | SI_19 | 30 days end of month | draft | 450 | |
+ | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
+ | 360 | %Y-02-15 | Debtors | 3 time policy | %Y-04-30 | customer_4 | letter | 3 | SI_11 | 10 days last reminder | draft | 360 | USD |
+ | 1200 | %Y-03-31 | Debtors | 2 time policy | %Y-04-30 | customer_2 | email | 1 | SI_5 | 30 days end of month | draft | 1200 | USD |
+ | 1200 | %Y-03-17 | Debtors | 2 time policy | %Y-04-30 | customer_3 | email | 1 | SI_8 | 30 days end of month | draft | 1200 | USD |
+ | 700 | %Y-02-28 | Debtors | 3 time policy | %Y-04-30 | customer_4 | email | 2 | SI_10 | 30 days end of month | draft | 700 | |
+ | 840 | %Y-03-31 | Debtors | 3 time policy | %Y-04-30 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 840 | USD |
+ | 450 | %Y-03-15 | Debtors | 3 time policy | %Y-04-30 | customer_4 | email | 2 | SI_12 | 30 days end of month | draft | 450 | USD |
+ | 1500 | %Y-04-14 | Debtors USD | 3 time policy | %Y-04-30 | customer_5_usd | email | 1 | SI_15 | 10 days net | draft | 1500 | USD |
+ | 1200 | %Y-03-17 | Debtors USD | 3 time policy | %Y-04-30 | customer_5_usd | email | 2 | SI_14 | 30 days end of month | draft | 1200 | USD |
+ | 1500 | %Y-04-14 | Debtors USD | 3 time policy | %Y-04-30 | customer_5_usd | email | 1 | SI_15 | 10 days net | draft | 1500 | USD |
+ | 1500 | %Y-04-14 | Debtors | 3 time policy | %Y-04-30 | customer_4 | email | 1 | SI_16 | 10 days net | draft | 1500 | |
+ | 1500 | %Y-04-14 | Debtors | 3 time policy | %Y-04-30 | Scrooge McDuck | email | 1 | SI_17 | 10 days net | draft | 1500 | |
+ | 450 | %Y-03-15 | Debtors | 3 time policy | %Y-04-30 | Donald Duck | email | 2 | SI_18 | 30 days end of month | draft | 450 | |
+ | 150 | %Y-03-15 | Debtors | 3 time policy | %Y-04-30 | Gus Goose | email | 2 | SI_19 | 30 days end of month | draft | 450 | |
diff --git a/account_credit_control/scenarios/features/07_credit_control_run_may.feature b/account_credit_control/scenarios/features/07_credit_control_run_may.feature
index 77b02fac1..535dc8fbb 100644
--- a/account_credit_control/scenarios/features/07_credit_control_run_may.feature
+++ b/account_credit_control/scenarios/features/07_credit_control_run_may.feature
@@ -8,7 +8,7 @@
# Features Generic tags (none for all)
##############################################################################
-@account_credit_control_run @account_credit_control_run_may
+@account_credit_control @account_credit_control_run @account_credit_control_run_may
Feature: Ensure that email credit line generation first pass is correct
@@ -22,12 +22,10 @@ Feature: Ensure that email credit line generation first pass is correct
Scenario: I pay entirely the invoice SI 16, so it should no longer appear in the credit control lines
Given I need a "account.bank.statement" with oid: scen.voucher_statement_si_16
And having:
- | name | value |
- | name | Bk.St.si_16 |
- | date | 2012-05-30 |
- | currency_id | by name: EUR |
- | journal_id | by oid: scen.voucher_eur_journal |
- And the bank statement is linked to period "05/2012"
+ | name | value |
+ | name | Bk.St.si_16 |
+ | date | %Y-05-30 |
+ | journal_id | by oid: scen.eur_journal |
And I import invoice "SI_16" using import invoice button
And I set bank statement end-balance
When I confirm bank statement
@@ -37,19 +35,16 @@ Feature: Ensure that email credit line generation first pass is correct
Scenario: I pay entirely the invoice SI 17, so it should no longer appear in the credit control lines
Given I need a "account.bank.statement" with oid: scen.voucher_statement_si_17
And having:
- | name | value |
- | name | Bk.St.si_17 |
- | date | 2012-05-30 |
- | currency_id | by name: EUR |
- | journal_id | by oid: scen.voucher_eur_journal |
- And the bank statement is linked to period "05/2012"
+ | name | value |
+ | name | Bk.St.si_17 |
+ | date | %Y-05-30 |
+ | journal_id | by oid: scen.eur_journal |
And I import invoice "SI_17" using import invoice button
- And I need a "account.bank.statement.line" with name: SI_17
- And the line amount should be 1500
+ And I should have a "account.bank.statement.line" with name: "SI_17" and amount: "1500"
And I set the voucher paid amount to "1000"
And I save the voucher
- Then I modify the line amount to 1000
- And I should have a "account.bank.statement" with oid: scen.voucher_statement_si_17
+ And I modify the line amount to "1000"
+ And I need a "account.bank.statement" with oid: scen.voucher_statement_si_17
And I set bank statement end-balance
When I confirm bank statement
Then My invoice "SI_17" is in state "open" reconciled with a residual amount of "500.0"
@@ -58,24 +53,20 @@ Feature: Ensure that email credit line generation first pass is correct
Scenario: I pay the first part of the invoice SI 18, so it should no longer appear in the credit control lines however, the second move lines should still appears
Given I need a "account.bank.statement" with oid: scen.voucher_statement_si_18
And having:
- | name | value |
- | name | Bk.St.si_18_part1 |
- | date | 2012-05-30 |
- | currency_id | by name: EUR |
- | journal_id | by oid: scen.voucher_eur_journal |
- And the bank statement is linked to period "05/2012"
+ | name | value |
+ | name | Bk.St.si_18_part1 |
+ | date | %Y-05-30 |
+ | journal_id | by oid: scen.eur_journal |
And I import invoice "SI_18" using import invoice button
- And I should have a "account.bank.statement.line" with name: SI_18 and amount: 450
- And the line amount should be 450
+ And I should have a "account.bank.statement.line" with name: "SI_18" and amount: "450"
And I set the voucher paid amount to "450"
And I save the voucher
- Then I modify the line amount to 450
- And I should have a "account.bank.statement.line" with name: SI_18 and amount: 1050
- And the line amount should be 1050
+ And I modify the line amount to "450"
+ And I should have a "account.bank.statement.line" with name: "SI_18" and amount: "1050"
And I set the voucher paid amount to "0"
And I save the voucher
- Then I modify the line amount to 0
- And I should have a "account.bank.statement" with oid: scen.voucher_statement_si_18
+ Then I modify the line amount to "0"
+ And I need a "account.bank.statement" with oid: scen.voucher_statement_si_18
And I set bank statement end-balance
When I confirm bank statement
Then My invoice "SI_18" is in state "open" reconciled with a residual amount of "1050.0"
@@ -85,22 +76,22 @@ Feature: Ensure that email credit line generation first pass is correct
Given I need a "credit.control.run" with oid: credit_control.run5
And having:
| name | value |
- | date | 2012-05-31 |
+ | date | %Y-05-31 |
When I launch the credit run
Then my credit run should be in state "done"
And the generated credit lines should have the following values:
- | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
- | 1500 | 2012-04-30 | Debtors | 2 time policy | 2012-05-31 | customer_2 | email | 1 | SI_6 | 30 days end of month | draft | 1500 | USD |
- | 1500 | 2012-04-14 | Debtors | 2 time policy | 2012-05-31 | customer_3 | email | 1 | SI_8 | 30 days end of month | draft | 1500 | USD |
- | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-05-31 | customer_4 | email | 1 | SI_11 | 10 days net | draft | 1050 | USD |
- | 1000 | 2012-02-29 | Debtors | 2 time policy | 2012-05-31 | customer_2 | letter | 2 | SI_4 | 60 days last reminder | draft | 1000 | |
- | 1000 | 2012-02-17 | Debtors | 2 time policy | 2012-05-31 | customer_3 | letter | 2 | SI_7 | 60 days last reminder | draft | 1000 | |
- | 840 | 2012-03-31 | Debtors | 3 time policy | 2012-05-31 | customer_4 | email | 2 | SI_11 | 30 days end of month | draft | 840 | USD |
- | 1500 | 2012-04-14 | Debtors USD | 3 time policy | 2012-05-31 | customer_5_usd | email | 2 | SI_15 | 30 days end of month | draft | 1500 | USD |
- | 700 | 2012-02-29 | Debtors | 3 time policy | 2012-05-31 | customer_4 | letter | 3 | SI_10 | 10 days last reminder | draft | 700 | |
- | 450 | 2012-03-15 | Debtors | 3 time policy | 2012-05-31 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 450 | USD |
- | 1200 | 2012-03-16 | Debtors USD | 3 time policy | 2012-05-31 | customer_5_usd | letter | 3 | SI_14 | 10 days last reminder | draft | 1200 | USD |
- | 500 | 2012-04-14 | Debtors | 3 time policy | 2012-05-31 | Scrooge McDuck | email | 2 | SI_17 | 30 days end of month | draft | 1500 | |
- | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-05-31 | Donald Duck | email | 1 | SI_18 | 10 days net | draft | 1050 | |
- | 150 | 2012-03-15 | Debtors | 3 time policy | 2012-05-31 | Gus Goose | letter | 3 | SI_19 | 10 days last reminder | draft | 450 | |
- | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-05-31 | Gus Goose | email | 1 | SI_19 | 10 days net | draft | 1050 | |
+ | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
+ | 1500 | %Y-04-30 | Debtors | 2 time policy | %Y-05-31 | customer_2 | email | 1 | SI_6 | 30 days end of month | draft | 1500 | USD |
+ | 1000 | %Y-02-28 | Debtors | 2 time policy | %Y-05-31 | customer_2 | letter | 2 | SI_4 | 60 days last reminder | draft | 1000 | |
+ | 1000 | %Y-02-17 | Debtors | 2 time policy | %Y-05-31 | customer_3 | letter | 2 | SI_7 | 60 days last reminder | draft | 1000 | |
+ | 1500 | %Y-04-14 | Debtors | 2 time policy | %Y-05-31 | customer_3 | email | 1 | SI_9 | 30 days end of month | draft | 1500 | |
+ | 840 | %Y-03-31 | Debtors | 3 time policy | %Y-05-31 | customer_4 | email | 2 | SI_11 | 30 days end of month | draft | 840 | USD |
+ | 1500 | %Y-04-14 | Debtors USD | 3 time policy | %Y-05-31 | customer_5_usd | email | 2 | SI_15 | 30 days end of month | draft | 1500 | USD |
+ | 700 | %Y-02-28 | Debtors | 3 time policy | %Y-05-31 | customer_4 | letter | 3 | SI_10 | 10 days last reminder | draft | 700 | |
+ | 450 | %Y-03-15 | Debtors | 3 time policy | %Y-05-31 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 450 | USD |
+ | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-05-31 | customer_4 | email | 1 | SI_12 | 10 days net | draft | 1050 | USD |
+ | 1200 | %Y-03-17 | Debtors USD | 3 time policy | %Y-05-31 | customer_5_usd | letter | 3 | SI_14 | 10 days last reminder | draft | 1200 | USD |
+ | 500 | %Y-04-14 | Debtors | 3 time policy | %Y-05-31 | Scrooge McDuck | email | 2 | SI_17 | 30 days end of month | draft | 1500 | |
+ | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-05-31 | Donald Duck | email | 1 | SI_18 | 10 days net | draft | 1050 | |
+ | 150 | %Y-03-15 | Debtors | 3 time policy | %Y-05-31 | Gus Goose | letter | 3 | SI_19 | 10 days last reminder | draft | 450 | |
+ | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-05-31 | Gus Goose | email | 1 | SI_19 | 10 days net | draft | 1050 | |
diff --git a/account_credit_control/scenarios/features/08_credit_control_run_jun.feature b/account_credit_control/scenarios/features/08_credit_control_run_jun.feature
index fa02a20a5..6d093af4c 100644
--- a/account_credit_control/scenarios/features/08_credit_control_run_jun.feature
+++ b/account_credit_control/scenarios/features/08_credit_control_run_jun.feature
@@ -8,7 +8,7 @@
# Features Generic tags (none for all)
##############################################################################
-@account_credit_control_run @account_credit_control_run_jun
+@account_credit_control @account_credit_control_run @account_credit_control_run_jun
Feature: Ensure that email credit line generation first pass is correct
@@ -23,16 +23,16 @@ Feature: Ensure that email credit line generation first pass is correct
Given I need a "credit.control.run" with oid: credit_control.run6
And having:
| name | value |
- | date | 2012-06-30 |
+ | date | %Y-06-30 |
When I launch the credit run
Then my credit run should be in state "done"
And the generated credit lines should have the following values:
- | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
- | 1200 | 2012-03-31 | Debtors | 2 time policy | 2012-06-30 | customer_2 | letter | 2 | SI_5 | 60 days last reminder | draft | 1200 | USD |
- | 1200 | 2012-03-16 | Debtors | 2 time policy | 2012-06-30 | customer_3 | letter | 2 | SI_8 | 60 days last reminder | draft | 1200 | USD |
- | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-06-30 | customer_4 | email | 2 | SI_12 | 30 days end of month | draft | 1050 | USD |
- | 840 | 2012-03-31 | Debtors | 3 time policy | 2012-06-30 | customer_4 | letter | 3 | SI_11 | 10 days last reminder | draft | 840 | USD |
- | 1500 | 2012-04-14 | Debtors USD | 3 time policy | 2012-06-30 | customer_5_usd | letter | 3 | SI_15 | 10 days last reminder | draft | 1500 | USD |
- | 500 | 2012-04-14 | Debtors | 3 time policy | 2012-06-30 | Scrooge McDuck | letter | 3 | SI_17 | 10 days last reminder | draft | 1500 | |
- | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-06-30 | Donald Duck | email | 2 | SI_18 | 30 days end of month | draft | 1050 | |
- | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-06-30 | Gus Goose | email | 2 | SI_19 | 30 days end of month | draft | 1050 | |
+ | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
+ | 1200 | %Y-03-31 | Debtors | 2 time policy | %Y-06-30 | customer_2 | letter | 2 | SI_5 | 60 days last reminder | draft | 1200 | USD |
+ | 1200 | %Y-03-17 | Debtors | 2 time policy | %Y-06-30 | customer_3 | letter | 2 | SI_8 | 60 days last reminder | draft | 1200 | USD |
+ | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-06-30 | customer_4 | email | 2 | SI_12 | 30 days end of month | draft | 1050 | USD |
+ | 840 | %Y-03-31 | Debtors | 3 time policy | %Y-06-30 | customer_4 | letter | 3 | SI_11 | 10 days last reminder | draft | 840 | USD |
+ | 1500 | %Y-04-14 | Debtors USD | 3 time policy | %Y-06-30 | customer_5_usd | letter | 3 | SI_15 | 10 days last reminder | draft | 1500 | USD |
+ | 500 | %Y-04-14 | Debtors | 3 time policy | %Y-06-30 | Scrooge McDuck | letter | 3 | SI_17 | 10 days last reminder | draft | 1500 | |
+ | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-06-30 | Donald Duck | email | 2 | SI_18 | 30 days end of month | draft | 1050 | |
+ | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-06-30 | Gus Goose | email | 2 | SI_19 | 30 days end of month | draft | 1050 | |
diff --git a/account_credit_control/scenarios/features/09_credit_control_run_jul.feature b/account_credit_control/scenarios/features/09_credit_control_run_jul.feature
index e20728554..f886b8f26 100644
--- a/account_credit_control/scenarios/features/09_credit_control_run_jul.feature
+++ b/account_credit_control/scenarios/features/09_credit_control_run_jul.feature
@@ -8,7 +8,7 @@
# Features Generic tags (none for all)
##############################################################################
-@account_credit_control_run @account_credit_control_run_jul
+@account_credit_control @account_credit_control_run @account_credit_control_run_jul
Feature: Ensure that email credit line generation first pass is correct
@@ -23,13 +23,13 @@ Feature: Ensure that email credit line generation first pass is correct
Given I need a "credit.control.run" with oid: credit_control.run7
And having:
| name | value |
- | date | 2012-07-31 |
+ | date | %Y-07-31 |
When I launch the credit run
Then my credit run should be in state "done"
And the generated credit lines should have the following values:
- | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
- | 1500 | 2012-04-30 | Debtors | 2 time policy | 2012-07-31 | customer_2 | letter | 2 | SI_6 | 60 days last reminder | draft | 1500 | USD |
- | 1500 | 2012-04-14 | Debtors | 2 time policy | 2012-07-31 | customer_3 | letter | 2 | SI_9 | 60 days last reminder | draft | 1500 | USD |
- | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-07-31 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 1050 | USD |
- | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-07-31 | Donald Duck | letter | 3 | SI_18 | 10 days last reminder | draft | 1050 | |
- | 1050 | 2012-04-30 | Debtors | 3 time policy | 2012-07-31 | Gus Goose | letter | 3 | SI_19 | 10 days last reminder | draft | 1050 | |
+ | balance | date due | account | policy | date | partner | channel | level | move line | policy level | state | amount due | currency |
+ | 1500 | %Y-04-30 | Debtors | 2 time policy | %Y-07-31 | customer_2 | letter | 2 | SI_6 | 60 days last reminder | draft | 1500 | USD |
+ | 1500 | %Y-04-14 | Debtors | 2 time policy | %Y-07-31 | customer_3 | letter | 2 | SI_9 | 60 days last reminder | draft | 1500 | USD |
+ | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-07-31 | customer_4 | letter | 3 | SI_12 | 10 days last reminder | draft | 1050 | USD |
+ | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-07-31 | Donald Duck | letter | 3 | SI_18 | 10 days last reminder | draft | 1050 | |
+ | 1050 | %Y-04-30 | Debtors | 3 time policy | %Y-07-31 | Gus Goose | letter | 3 | SI_19 | 10 days last reminder | draft | 1050 | |
diff --git a/account_credit_control/scenarios/features/steps/account_credit_control.py b/account_credit_control/scenarios/features/steps/account_credit_control.py
index 02cdeb694..dda9a07bd 100644
--- a/account_credit_control/scenarios/features/steps/account_credit_control.py
+++ b/account_credit_control/scenarios/features/steps/account_credit_control.py
@@ -11,8 +11,8 @@ def impl(ctx, policy_oid):
for row in ctx.table:
acc = acc_obj.get(['code = %s' % row['account code']])
assert acc, "Account with code %s not found" % row['account code']
- accounts.append(accounts)
- policy.write({'account_ids': accounts})
+ accounts.append(acc)
+ policy.write({'account_ids': [x.id for x in accounts]})
@when(u'I launch the credit run')
@@ -44,16 +44,22 @@ def impl(ctx):
for row in rows:
account = model('account.account').get(['name = %s' % row['account']])
assert account, "no account named %s found" % row['account']
- import pdb; pdb.set_trace()
policy = model('credit.control.policy').get(['name = %s' % row['policy']])
assert policy, "No policy %s found" % row['policy']
+
partner = model('res.partner').get(['name = %s' % row['partner']])
assert partner, "No partner %s found" % row['partner']
- move_line = model('account.move.line').get(['name = %s' % row['move line']])
+
+ maturity_date = _parse_date(row['date due'])
+ move_line = model('account.move.line').get(['name = %s' % row['move line'],
+ 'date_maturity = %s' % maturity_date])
assert move_line, "No move line %s found" % row['move line']
- level = model('credit.control.policy.level').get(['name = %s' % row['policy level'], 'policy_id = %s' % policy.id])
+
+ level = model('credit.control.policy.level').get(['name = %s' % row['policy level'],
+ 'policy_id = %s' % policy.id])
assert level, "No level % found" % row['policy level']
+
domain = [['account_id', '=', account.id],
['policy_id', '=', policy.id],
['partner_id', '=', partner.id],
@@ -65,8 +71,9 @@ def impl(ctx):
['balance_due', '=', row.get('balance', 0.0)],
['date_due', '=', _parse_date(row['date due'])],
['date', '=', _parse_date(row['date'])],
+ ['move_line_id', '=', move_line.id],
]
- if row.get('currrency'):
+ if row.get('currency'):
curreny = model('res.currency').get(['name = %s' % row['currency']])
assert curreny, "No currency %s found" % row['currency']
domain.append(('currency_id', '=', curreny.id))
@@ -74,8 +81,9 @@ def impl(ctx):
lines = model('credit.control.line').search(domain)
assert lines, "no line found for %s" % repr(row)
assert len(lines) == 1, "Too many lines found for %s" % repr(row)
- date_lines = model('credit.control.lines').search([('date', '=', ctx.found_item.date)])
- assert len(date_lines) == len(ctx.table), "Too many lines generated"
+ date_lines = model('credit.control.line').search([('date', '=', ctx.found_item.date)])
+ assert len(date_lines) == len(ctx.table.rows), "Too many lines generated"
+
def open_invoice(ctx):
assert ctx.found_item
@@ -90,3 +98,23 @@ def impl(ctx):
@given(u'I open the credit invoice')
def impl(ctx):
open_invoice(ctx)
+
+@given(u'there is "{state}" credit lines')
+def impl(ctx, state):
+ assert model('credit.control.line').search(['state = %s' % state])
+
+@given(u'I mark all draft email to state "{state}"')
+def impl(ctx, state):
+ wiz = model('credit.control.marker').create({'name': state})
+ lines = model('credit.control.line').search([('state', '=', 'draft')])
+ assert lines
+ ctx.lines = lines
+ wiz.write({'line_ids': lines})
+ wiz.mark_lines()
+
+@then(u'the draft line should be in state "{state}"')
+def impl(ctx, state):
+ assert ctx.lines
+ lines = model('credit.control.line').search([('state', '!=', state),
+ ('id', 'in', ctx.lines)])
+ assert not lines
diff --git a/account_credit_control/scenarios/features/steps/account_voucher.py b/account_credit_control/scenarios/features/steps/account_voucher.py
new file mode 100644
index 000000000..f89ce5721
--- /dev/null
+++ b/account_credit_control/scenarios/features/steps/account_voucher.py
@@ -0,0 +1,97 @@
+from support import *
+import datetime
+
+@step('I import invoice "{inv_name}" using import invoice button')
+def impl(ctx, inv_name):
+ invoice = model('account.invoice').get([('name', '=', inv_name)])
+ assert invoice
+ bank_statement = ctx.found_item
+ for line in bank_statement.line_ids:
+ line.unlink()
+ lines = model('account.move.line').browse([('move_id', '=', invoice.move_id.id),
+ ('account_id', '=', invoice.account_id.id)])
+
+ wizard = model('account.statement.from.invoice.lines').create({'line_ids': lines})
+ wizard.populate_statement({'statement_id': bank_statement.id})
+
+@given(u'I should have a "account.bank.statement.line" with name: "{name}" and amount: "{amount}"')
+def impl(ctx, name, amount):
+ assert ctx.found_item
+ line = model('account.bank.statement.line').get([('name', '=', name),
+ ('amount', '=', amount),
+ ('statement_id', '=', ctx.found_item.id)])
+ assert line
+ ctx.line = line
+
+@given(u'I set the voucher paid amount to "{amount}"')
+def impl(ctx, amount):
+ assert ctx.line
+ voucher = model('account.voucher').get(ctx.line.voucher_id.id)
+ assert voucher
+
+ vals = voucher.onchange_amount(float(amount),
+ voucher.payment_rate,
+ voucher.partner_id.id,
+ voucher.journal_id.id if voucher.journal_id else False,
+ voucher.currency_id.id if voucher.currency_id else False,
+ voucher.type,
+ voucher.date,
+ voucher.payment_rate,
+ voucher.company_id.id if voucher.company_id else false)
+ vals = vals['value']
+ vals.update({'amount': ctx.line.voucher_id.amount})
+ voucher_line_ids = []
+ voucher_line_dr_ids = []
+ v_l_obj = model('account.voucher.line')
+ for v_line_vals in vals.get('line_cr_ids', []) or []:
+ v_line_vals['voucher_id'] = voucher.id
+ voucher_line_ids.append(v_l_obj.create(v_line_vals).id)
+ vals['line_cr_ids'] = voucher_line_ids
+
+ for v_line_vals in vals.get('line_dr_ids', []) or []:
+ v_line_vals['voucher_id'] = voucher.id
+ voucher_line_dr_ids.append(v_l_obj.create(v_line_vals).id)
+ vals['line_dr_ids'] = voucher_line_ids
+
+ voucher.write(vals)
+ ctx.vals = vals
+ ctx.voucher = voucher
+
+@given(u'I save the voucher')
+def impl(ctx):
+ assert True
+
+@given(u'I modify the line amount to "{amount}"')
+@then(u'I modify the line amount to "{amount}"')
+def impl(ctx, amount):
+ assert ctx.line
+ # we have to change voucher amount before chaning statement line amount
+ if ctx.line.voucher_id:
+ model('account.voucher').write([ctx.line.voucher_id.id],
+ {'amount': float(amount)})
+ ctx.line.write({'amount': float(amount)})
+
+@step('My invoice "{inv_name}" is in state "{state}" reconciled with a residual amount of "{amount:f}"')
+def impl(ctx, inv_name, state, amount):
+ invoice = model('account.invoice').get([('name', '=', inv_name)])
+ assert_almost_equal(invoice.residual, amount)
+ assert_equal(invoice.state, state)
+
+@step('I modify the bank statement line amount to {amount:f}')
+def impl(ctx, amount):
+ line = ctx.found_item.voucher_id.line_cr_ids[0]
+ #ctx.voucher = model('account.voucher').get(ctx.found_item.voucher_id.id)
+ ctx.found_item.on_change('onchange_amount', 'amount', (), amount)
+
+@then(u'I set bank statement end-balance')
+@given(u'I set bank statement end-balance')
+def impl(ctx):
+ assert ctx.found_item, "No statement found"
+ ctx.found_item.write({'balance_end_real': ctx.found_item.balance_end})
+ assert ctx.found_item.balance_end == ctx.found_item.balance_end_real
+
+@when(u'I confirm bank statement')
+def impl(ctx):
+ assert ctx.found_item
+ assert_equal(ctx.found_item._model._name, 'account.bank.statement')
+ ctx.found_item.button_confirm_bank()
diff --git a/account_credit_control/wizard/credit_control_communication.py b/account_credit_control/wizard/credit_control_communication.py
index 8f4ac37b2..be64414f6 100644
--- a/account_credit_control/wizard/credit_control_communication.py
+++ b/account_credit_control/wizard/credit_control_communication.py
@@ -20,9 +20,7 @@
##############################################################################
import netsvc
import logging
-from openerp.osv.orm import TransientModel, fields
-from openerp.osv.osv import except_osv
-from openerp.tools.translate import _
+from openerp.osv.orm import TransientModel, fields
logger = logging.getLogger('credit.control.line.mailing')
@@ -51,24 +49,6 @@ class CreditCommunication(TransientModel):
cr, uid, 'credit.control.policy', context=c),
'user_id': lambda s, cr, uid, c: uid}
- def get_address(self, cr, uid, com_id, context=None):
- """Return a valid address for customer"""
- assert not (isinstance(com_id, list) and len(com_id) > 1), \
- "com_id: only one id expected"
- if isinstance(com_id, list):
- com_id = com_id[0]
- form = self.browse(cr, uid, com_id, context=context)
- part_obj = self.pool.get('res.partner')
- adds = part_obj.address_get(cr, uid, [form.partner_id.id],
- adr_pref=['invoice', 'default'])
-
- add = adds.get('invoice', adds.get('default'))
- add_obj = self.pool.get('res.partner.address')
- if add:
- return add_obj.browse(cr, uid, add, context=context)
- else:
- return False
-
def get_email(self, cr, uid, com_id, context=None):
"""Return a valid email for customer"""
assert not (isinstance(com_id, list) and len(com_id) > 1), \
@@ -76,10 +56,7 @@ class CreditCommunication(TransientModel):
if isinstance(com_id, list):
com_id = com_id[0]
form = self.browse(cr, uid, com_id, context=context)
- address = form.get_address()
- email = ''
- if address and address.email:
- email = address.email
+ email = form.partner_id.email or False
return email
def _get_credit_lines(self, cr, uid, line_ids, partner_id, level_id, context=None):
@@ -124,15 +101,12 @@ class CreditCommunication(TransientModel):
"""Generate email message using template related to level"""
cr_line_obj = self.pool.get('credit.control.line')
email_temp_obj = self.pool.get('email.template')
- email_message_obj = self.pool.get('mail.message')
+ email_message_obj = self.pool.get('mail.mail')
email_ids = []
-
- essential_fields = [
- 'subject',
- 'body_html',
- 'email_from',
- 'email_to'
- ]
+ essential_fields = ['subject',
+ 'body_html',
+ 'email_from',
+ 'email_to']
for comm in comms:
# we want to use a local cr in order to send the maximum
@@ -141,9 +115,11 @@ class CreditCommunication(TransientModel):
email_values = {}
cl_ids = [cl.id for cl in comm.credit_control_line_ids]
email_values = email_temp_obj.generate_email(cr, uid,
- template,
- comm.id,
- context=context)
+ template,
+ comm.id,
+ context=context)
+ email_values['body_html'] = email_values['body']
+ email_values['type'] = 'email'
email_id = email_message_obj.create(cr, uid, email_values, context=context)
@@ -178,4 +154,3 @@ class CreditCommunication(TransientModel):
l_obj = self.pool.get('credit.control.line')
l_obj.write(cr, uid, line_ids, {'state': 'sent'}, context=context)
return line_ids
-
diff --git a/account_credit_control/wizard/credit_control_printer.py b/account_credit_control/wizard/credit_control_printer.py
index 9ff1ad0b3..0435d2271 100644
--- a/account_credit_control/wizard/credit_control_printer.py
+++ b/account_credit_control/wizard/credit_control_printer.py
@@ -65,7 +65,7 @@ class CreditControlPrinter(TransientModel):
def print_lines(self, cr, uid, wiz_id, context=None):
assert not (isinstance(wiz_id, list) and len(wiz_id) > 1), \
- "wiz_id: only one id expected"
+ "wiz_id: only one id expected"
comm_obj = self.pool.get('credit.control.communication')
if isinstance(wiz_id, list):
wiz_id = wiz_id[0]
@@ -75,15 +75,20 @@ class CreditControlPrinter(TransientModel):
raise except_osv(_('Error'), _('No credit control lines selected.'))
line_ids = [l.id for l in form.line_ids]
- comms = comm_obj._generate_comm_from_credit_line_ids(
- cr, uid, line_ids, context=context)
+ comms = comm_obj._generate_comm_from_credit_line_ids(cr, uid, line_ids,
+ context=context)
report_file = comm_obj._generate_report(cr, uid, comms, context=context)
form.write({'report_file': base64.b64encode(report_file), 'state': 'done'})
if form.mark_as_sent:
- filtered_ids = self._filter_line_ids(cr, uid, line_ids, context)
comm_obj._mark_credit_line_as_sent(cr, uid, comms, context=context)
- return False # do not close the window, we need it to download the report
-
+ return {'type': 'ir.actions.act_window',
+ 'res_model': 'credit.control.printer',
+ 'view_mode': 'form',
+ 'view_type': 'form',
+ 'res_id': form.id,
+ 'views': [(False, 'form')],
+ 'target': 'new',
+ }