[MIG] Migration of the module account_credit_control (from v8 to v10)

(cherry picked from commit 811310fd06ca8589fa8e87da6b8bdaea403bf660)

[MIG] Improve the code and fix some bugs

(cherry picked from commit 5bcdfe3f748884d650120f76d1642b820d0a800b)

[FIX] Change the parent for the menu Credit Control (the previous parent menu was not in the Odoo standard)

(cherry picked from commit 826257ce7b5248956d838cae9c94a012d550327e)

[FIX] Fix a lot of errors to respect pep8

(cherry picked from commit bed6cf35d665eea32122c91d33322af141053f29)

[FIX] Respect PEP8

(cherry picked from commit 6353eef0dce1bfe5db8a38d3410d1cc7f833fa10)
This commit is contained in:
Sylvain Van Hoof
2017-03-16 10:00:49 +01:00
committed by Pedro M. Baeza
parent 801aac59a1
commit b3b1a6493b
42 changed files with 1699 additions and 1510 deletions

View File

@@ -18,12 +18,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import mail
from . import run
from . import line
from . import account
from . import partner
from . import policy
from . import company
from . import models
from . import wizard
from . import invoice

View File

@@ -19,32 +19,45 @@
#
##############################################################################
{'name': 'Account Credit Control',
'version': '8.0.0.3.0',
'author': "Camptocamp,Odoo Community Association (OCA)",
'version': '10.0.0.3.0',
'author': "Camptocamp,Odoo Community Association (OCA),Okia",
'maintainer': 'Camptocamp',
'category': 'Finance',
'complexity': "normal",
'depends': ['base',
'account',
'email_template',
],
'depends': [
'base',
'account',
'mail',
],
'website': 'http://www.camptocamp.com',
'data': ["report/report.xml",
"report/report_credit_control_summary.xml",
"data.xml",
"line_view.xml",
"account_view.xml",
"partner_view.xml",
"policy_view.xml",
"run_view.xml",
"company_view.xml",
"wizard/credit_control_emailer_view.xml",
"wizard/credit_control_marker_view.xml",
"wizard/credit_control_printer_view.xml",
"wizard/credit_control_policy_changer_view.xml",
"security/ir.model.access.csv"],
'demo': ["credit_control_demo.xml"],
'tests': [],
'data': [
"security/res_groups.xml",
# Reports
"report/report.xml",
"report/report_credit_control_summary.xml",
# Data
"data/data.xml",
# Views
"views/account_invoice.xml",
"views/credit_control_line.xml",
"views/credit_control_policy.xml",
"views/credit_control_run.xml",
"views/res_company.xml",
"views/res_partner.xml",
# Wizards
"wizard/credit_control_emailer_view.xml",
"wizard/credit_control_marker_view.xml",
"wizard/credit_control_printer_view.xml",
"wizard/credit_control_policy_changer_view.xml",
# Security
"security/ir.model.access.csv",
],
'demo': [
"demo/credit_control_demo.xml"
],
'installable': True,
'license': 'AGPL-3',
'application': True

View File

@@ -1,45 +0,0 @@
<openerp>
<data>
<act_window
id="act_account_credit_relation_relation"
name="Credit Lines"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user"
domain="[('account_id', '=', active_id)]"
res_model="credit.control.line"
src_model="account.account"/>
<record id="invoice_followup_form_view" model="ir.ui.view">
<field name="name">invoice.followup.form.view</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field name="arch" type="xml">
<notebook position="inside">
<page string="Credit Control"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user,account_credit_control.group_account_credit_control_info">
<group>
<field name="credit_policy_id" widget="selection"
string="Manual Credit Control Policy"
attrs="{'invisible': [('credit_policy_id', '=', False)]}"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user,account_credit_control.group_account_credit_control_info"/>
</group>
<separator string="Issued Lines" colspan="4"/>
<field name="credit_control_line_ids" colspan="4" nolabel="1"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user,account_credit_control.group_account_credit_control_info" >
<tree string="Credit Control Lines">
<field name="date"/>
<field name="level"/>
<field name="state"/>
<field name="channel"/>
<field name="balance_due"/>
<field name="policy_level_id"/>
<field name="policy_id"/>
</tree>
</field>
</page>
</notebook>
</field>
</record>
</data>
</openerp>

View File

@@ -1,15 +0,0 @@
<openerp>
<data>
<record id="credit_control_company_form" model="ir.ui.view">
<field name="name">credit.control.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<field name="currency_id" position="after">
<field name="credit_policy_id" widget="selection"/>
<field name="credit_control_tolerance"/>
</field>
</field>
</record>
</data>
</openerp>

View File

@@ -1,30 +0,0 @@
<openerp>
<data>
<record id="a_recv_1" model="account.account">
<field name="code">X11002-a</field>
<field name="name">B2B Debtors - (test)</field>
<field ref="account.cas" name="parent_id"/>
<field name="type">receivable</field>
<field eval="True" name="reconcile"/>
<field name="user_type" ref="account.data_account_type_receivable"/>
</record>
<record id="a_recv_2" model="account.account">
<field name="code">X11002-b</field>
<field name="name">B2C Debtors - (test)</field>
<field ref="account.cas" name="parent_id"/>
<field name="type">receivable</field>
<field eval="True" name="reconcile"/>
<field name="user_type" ref="account.data_account_type_receivable"/>
</record>
<record id="a_recv_3" model="account.account">
<field name="code">X11002-c</field>
<field name="name">New Debtors - (test)</field>
<field ref="account.cas" name="parent_id"/>
<field name="type">receivable</field>
<field eval="True" name="reconcile"/>
<field name="user_type" ref="account.data_account_type_receivable"/>
</record>
</data>
</openerp>

View File

@@ -1,230 +0,0 @@
<openerp>
<data noupdate="1">
<!--Email template -->
<record id="email_template_credit_control_base" model="email.template">
<field name="name">Credit Control Email</field>
<field name="email_from">noreply@localhost</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="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="report_template" ref="credit_control_summary"/>
<field name="body_html"><![CDATA[
Dear ${object.contact_address.name or ''}
<br/>
<br/>
${object.current_policy_level.custom_mail_text | safe}
]]></field>
</record>
<!-- policy no follow -->
<record model="credit.control.policy"
id="credit_control_no_follow">
<field name="name">No follow</field>
<field name="do_nothing" eval="1"/>
</record>
<!-- no follow policy -->
<record model="credit.control.policy.level"
id="no_follow_1">
<field name="name">No follow</field>
<field name="level" eval="1"/>
<field name="computation_mode">net_days</field>
<field name="delay_days" eval="0"/>
<field name="email_template_id" ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_no_follow"/>
<field name="channel">email</field>
<field name="custom_text">Manual no follow</field>
<field name="custom_mail_text">Manual no follow</field>
</record>
<!-- policy 1 -->
<record model="credit.control.policy"
id="credit_control_3_time">
<field name="name">3 time policy</field>
</record>
<record model="credit.control.policy.level"
id="3_time_1">
<field name="name">10 days net</field>
<field name="level" eval="1"/>
<field name="computation_mode">net_days</field>
<field name="delay_days" eval="10"/>
<field name="email_template_id" ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_3_time"/>
<field name="channel">email</field>
<field name="custom_text">Our records indicate that we have not received the payment of the above mentioned invoice.
If it has already been sent, please disregard this notice. If not, please proceed with payment within 10 days.
Thank you in advance for your anticipated cooperation in this matter.
Best regards
</field>
<field name="custom_mail_text"><![CDATA[
Our records indicate that we have not received the payment of the invoices mentioned in the attached document.<br/>
<br/>
If it has already been sent, please disregard this notice. If not, please proceed with payment within 10 days.<br/>
<br/>
Thank you in advance for your anticipated cooperation in this matter.<br/>
<br/>
Best regards
]]></field>
</record>
<record model="credit.control.policy.level"
id="3_time_2">
<field name="name">30 days end of month</field>
<field name="level" eval="2"/>
<field name="computation_mode">end_of_month</field>
<field name="delay_days" eval="30"/>
<field name="email_template_id" ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_3_time"/>
<field name="channel">email</field>
<field name="custom_text">Our records indicate that we have not yet received the payment of the above mentioned invoice despite our first reminder.
If it has already been sent, please disregard this notice. If not, please proceed with payment within 5 days.
Thank you in advance for your anticipated cooperation in this matter.
Best regards
</field>
<field name="custom_mail_text"><![CDATA[
Our records indicate that we have not yet received the payment of the invoices mentioned in the attached document despite our first reminder.<br/>
If it has already been sent, please disregard this notice. If not, please proceed with payment within 5 days.<br/>
<br/>
Thank you in advance for your anticipated cooperation in this matter.<br/>
<br/>
Best regards
]]></field>
</record>
<record model="credit.control.policy.level"
id="3_time_3">
<field name="name">10 days last reminder</field>
<field name="level" eval="3"/>
<field name="computation_mode">previous_date</field>
<field name="delay_days" eval="10"/>
<field name="email_template_id" ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_3_time"/>
<field name="channel">letter</field>
<field name="custom_text">
Our records indicate that we still have not received the payment of the above mentioned invoice despite our two reminders.
If payment have already been sent, please disregard this notice. If not, please proceed with payment.
If your payment has not been received in the next 5 days, your file will be transfered to our debt collection agency.
Should you need us to arrange a payment plan for you, please advise.
A customer account statement is enclosed for you convenience.
Thank you in advance for your anticipated cooperation in this matter.
Best regards
</field>
<field name="custom_mail_text"><![CDATA[
Our records indicate that we still have not received the payment of the invoices mentioned in the attached document despite our two reminders.<br/>
If payment have already been sent, please disregard this notice. If not, please proceed with payment.<br/>
If your payment has not been received in the next 5 days, your file will be transfered to our debt collection agency.<br/>
<br/>
Should you need us to arrange a payment plan for you, please advise.<br/>
A customer account statement is enclosed for you convenience.<br/>
<br/>
Thank you in advance for your anticipated cooperation in this matter.<br/>
<br/>
Best regards
]]></field>
</record>
<!-- policy 2 -->
<record model="credit.control.policy"
id="credit_control_2_time">
<field name="name">2 time policy</field>
</record>
<record model="credit.control.policy.level"
id="2_time_1">
<field name="name">30 days end of month</field>
<field name="level" eval="1"/>
<field name="computation_mode">end_of_month</field>
<field name="delay_days" eval="30"/>
<field name="email_template_id" ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_2_time"/>
<field name="channel">email</field>
<field name="custom_text">Our records indicate that we have not received the payment of the above mentioned invoice.
If it has already been sent, please disregard this notice. If not, please proceed with payment within 10 days.
Thank you in advance for your anticipated cooperation in this matter.
Best regards
</field>
<field name="custom_mail_text"><![CDATA[
Our records indicate that we have not received the payment of the invoices mentioned in the attached document.<br/>
If it has already been sent, please disregard this notice. If not, please proceed with payment within 10 days.<br/>
<br/>
Thank you in advance for your anticipated cooperation in this matter.<br/>
<br/>
Best regards
]]></field>
</record>
<record model="credit.control.policy.level"
id="2_time_2">
<field name="name">60 days last reminder</field>
<field name="level" eval="2"/>
<field name="computation_mode">previous_date</field>
<field name="delay_days" eval="60"/>
<field name="email_template_id" ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_2_time"/>
<field name="channel">letter</field>
<field name="custom_text">Our records indicate that we still have not received the payment of the above mentioned invoice despite our reminder.
If payment have already been sent, please disregard this notice. If not, please proceed with payment.
If your payment has not been received in the next 5 days, your file will be transfered to our debt
collection agency.
Should you need us to arrange a payment plan for you, please advise.
A customer account statement is enclosed for you convenience.
Thank you in advance for your anticipated cooperation in this matter.
Best regards
</field>
<field name="custom_mail_text"><![CDATA[
Our records indicate that we still have not received the payment of the invoices mentioned in the attached document despite our reminder.
<br/>
<br/>
If payment have already been sent, please disregard this notice. If not, please proceed with payment.<br/>
If your payment has not been received in the next 5 days, your file will be transfered to our debt<br/>
collection agency.<br/>
<br/>
Should you need us to arrange a payment plan for you, please advise.<br/>
A customer account statement is enclosed for you convenience.<br/>
<br/>
Thank you in advance for your anticipated cooperation in this matter.<br/>
<br/>
Best regards
]]></field>
</record>
<record id="group_account_credit_control_manager" model="res.groups">
<field name="name">Credit Control Manager</field>
<field name="category_id" ref="base.module_category_accounting_and_finance"/>
</record>
<record id="group_account_credit_control_user" model="res.groups" context="{'noadmin':True}">
<field name="name">Credit Control User</field>
<field name="category_id" ref="base.module_category_accounting_and_finance"/>
</record>
<record id="group_account_credit_control_info" model="res.groups" context="{'noadmin':True}">
<field name="name">Credit Control Info</field>
<field name="category_id" ref="base.module_category_accounting_and_finance"/>
</record>
<record id="base.main_company" model="res.company">
<field name="credit_policy_id" ref="credit_control_3_time"/>
</record>
</data>
</openerp>

View File

@@ -0,0 +1,249 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<!--Email template -->
<record id="email_template_credit_control_base" model="mail.template">
<field name="name">Credit Control Email</field>
<field name="email_from">${object.partner_id.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="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="report_template" ref="credit_control_summary"/>
<field name="body_html"><![CDATA[
Dear ${object.contact_address.name or ''}
<br/>
<br/>
${object.current_policy_level.custom_mail_text | safe}
]]></field>
</record>
<!-- policy no follow -->
<record model="credit.control.policy"
id="credit_control_no_follow">
<field name="name">No follow</field>
<field name="do_nothing" eval="1"/>
</record>
<!-- no follow policy -->
<record model="credit.control.policy.level"
id="no_follow_1">
<field name="name">No follow</field>
<field name="level" eval="1"/>
<field name="computation_mode">net_days</field>
<field name="delay_days" eval="0"/>
<field name="email_template_id"
ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_no_follow"/>
<field name="channel">email</field>
<field name="custom_text">Manual no follow</field>
<field name="custom_mail_text">Manual no follow</field>
</record>
<!-- policy 1 -->
<record model="credit.control.policy"
id="credit_control_3_time">
<field name="name">3 time policy</field>
</record>
<record model="credit.control.policy.level"
id="3_time_1">
<field name="name">10 days net</field>
<field name="level" eval="1"/>
<field name="computation_mode">net_days</field>
<field name="delay_days" eval="10"/>
<field name="email_template_id"
ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_3_time"/>
<field name="channel">email</field>
<field name="custom_text">Our records indicate that we have not
received the payment of the above mentioned invoice.
If it has already been sent, please disregard this notice. If
not, please proceed with payment within 10 days.
Thank you in advance for your anticipated cooperation in this
matter.
Best regards
</field>
<field name="custom_mail_text"><![CDATA[
Our records indicate that we have not received the payment of the invoices mentioned in the attached document.<br/>
<br/>
If it has already been sent, please disregard this notice. If not, please proceed with payment within 10 days.<br/>
<br/>
Thank you in advance for your anticipated cooperation in this matter.<br/>
<br/>
Best regards
]]></field>
</record>
<record model="credit.control.policy.level"
id="3_time_2">
<field name="name">30 days end of month</field>
<field name="level" eval="2"/>
<field name="computation_mode">end_of_month</field>
<field name="delay_days" eval="30"/>
<field name="email_template_id"
ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_3_time"/>
<field name="channel">email</field>
<field name="custom_text">Our records indicate that we have not yet
received the payment of the above mentioned invoice despite our
first reminder.
If it has already been sent, please disregard this notice. If
not, please proceed with payment within 5 days.
Thank you in advance for your anticipated cooperation in this
matter.
Best regards
</field>
<field name="custom_mail_text"><![CDATA[
Our records indicate that we have not yet received the payment of the invoices mentioned in the attached document despite our first reminder.<br/>
If it has already been sent, please disregard this notice. If not, please proceed with payment within 5 days.<br/>
<br/>
Thank you in advance for your anticipated cooperation in this matter.<br/>
<br/>
Best regards
]]></field>
</record>
<record model="credit.control.policy.level"
id="3_time_3">
<field name="name">10 days last reminder</field>
<field name="level" eval="3"/>
<field name="computation_mode">previous_date</field>
<field name="delay_days" eval="10"/>
<field name="email_template_id"
ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_3_time"/>
<field name="channel">letter</field>
<field name="custom_text">
Our records indicate that we still have not received the
payment of the above mentioned invoice despite our two
reminders.
If payment have already been sent, please disregard this
notice. If not, please proceed with payment.
If your payment has not been received in the next 5 days, your
file will be transfered to our debt collection agency.
Should you need us to arrange a payment plan for you, please
advise.
A customer account statement is enclosed for you convenience.
Thank you in advance for your anticipated cooperation in this
matter.
Best regards
</field>
<field name="custom_mail_text"><![CDATA[
Our records indicate that we still have not received the payment of the invoices mentioned in the attached document despite our two reminders.<br/>
If payment have already been sent, please disregard this notice. If not, please proceed with payment.<br/>
If your payment has not been received in the next 5 days, your file will be transfered to our debt collection agency.<br/>
<br/>
Should you need us to arrange a payment plan for you, please advise.<br/>
A customer account statement is enclosed for you convenience.<br/>
<br/>
Thank you in advance for your anticipated cooperation in this matter.<br/>
<br/>
Best regards
]]></field>
</record>
<!-- policy 2 -->
<record model="credit.control.policy"
id="credit_control_2_time">
<field name="name">2 time policy</field>
</record>
<record model="credit.control.policy.level"
id="2_time_1">
<field name="name">30 days end of month</field>
<field name="level" eval="1"/>
<field name="computation_mode">end_of_month</field>
<field name="delay_days" eval="30"/>
<field name="email_template_id"
ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_2_time"/>
<field name="channel">email</field>
<field name="custom_text">Our records indicate that we have not
received the payment of the above mentioned invoice.
If it has already been sent, please disregard this notice. If
not, please proceed with payment within 10 days.
Thank you in advance for your anticipated cooperation in this
matter.
Best regards
</field>
<field name="custom_mail_text"><![CDATA[
Our records indicate that we have not received the payment of the invoices mentioned in the attached document.<br/>
If it has already been sent, please disregard this notice. If not, please proceed with payment within 10 days.<br/>
<br/>
Thank you in advance for your anticipated cooperation in this matter.<br/>
<br/>
Best regards
]]></field>
</record>
<record model="credit.control.policy.level"
id="2_time_2">
<field name="name">60 days last reminder</field>
<field name="level" eval="2"/>
<field name="computation_mode">previous_date</field>
<field name="delay_days" eval="60"/>
<field name="email_template_id"
ref="email_template_credit_control_base"/>
<field name="policy_id" ref="credit_control_2_time"/>
<field name="channel">letter</field>
<field name="custom_text">Our records indicate that we still have
not received the payment of the above mentioned invoice despite
our reminder.
If payment have already been sent, please disregard this
notice. If not, please proceed with payment.
If your payment has not been received in the next 5 days, your
file will be transfered to our debt
collection agency.
Should you need us to arrange a payment plan for you, please
advise.
A customer account statement is enclosed for you convenience.
Thank you in advance for your anticipated cooperation in this
matter.
Best regards
</field>
<field name="custom_mail_text"><![CDATA[
Our records indicate that we still have not received the payment of the invoices mentioned in the attached document despite our reminder.
<br/>
<br/>
If payment have already been sent, please disregard this notice. If not, please proceed with payment.<br/>
If your payment has not been received in the next 5 days, your file will be transfered to our debt<br/>
collection agency.<br/>
<br/>
Should you need us to arrange a payment plan for you, please advise.<br/>
A customer account statement is enclosed for you convenience.<br/>
<br/>
Thank you in advance for your anticipated cooperation in this matter.<br/>
<br/>
Best regards
]]></field>
</record>
<record id="base.main_company" model="res.company">
<field name="credit_policy_id" ref="credit_control_3_time"/>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="a_recv_1" model="account.account">
<field name="code">X11002-a</field>
<field name="name">B2B Debtors - (test)</field>
<field name="user_type_id" ref="account.data_account_type_receivable"/>
<field name="reconcile" eval="True"/>
</record>
<record id="a_recv_2" model="account.account">
<field name="code">X11002-b</field>
<field name="name">B2C Debtors - (test)</field>
<field name="user_type_id" ref="account.data_account_type_receivable"/>
<field name="reconcile" eval="True"/>
</record>
<record id="a_recv_3" model="account.account">
<field name="code">X11002-c</field>
<field name="name">New Debtors - (test)</field>
<field name="user_type_id" ref="account.data_account_type_receivable"/>
<field name="reconcile" eval="True"/>
</record>
</odoo>

File diff suppressed because it is too large Load Diff

View File

@@ -1,171 +0,0 @@
<openerp>
<data>
<record id="credit_control_line_form" model="ir.ui.view">
<field name="name">credit.control.line.form</field>
<field name="model">credit.control.line</field>
<field name="arch" type="xml">
<form string="Control Credit Lines">
<header>
<field name="state" widget="statusbar"
statusbar_visible="draft,to_be_sent,sent"
statusbar_colors='{"error":"red","email_error":"red"}'/>
</header>
<sheet>
<group>
<group>
<field name="partner_id"/>
<field name="policy_level_id"/>
<field name="policy_id"/>
<field name="level"/>
<field name="manually_overridden"/>
</group>
<group>
<field name="date"/>
<field name="date_due"/>
<field name="channel"/>
<field name="date_sent"/>
<field name="mail_message_id"/>
</group>
</group>
<group>
<group>
<field name="invoice_id"/>
<field name="move_line_id"/>
<field name="account_id"/>
</group>
<group>
<field name="amount_due"/>
<field name="balance_due"/>
<field name="currency_id"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="credit_control_line_search" model="ir.ui.view">
<field name="name">Credit Control Lines</field>
<field name="model">credit.control.line</field>
<field name="arch" type="xml">
<search string="Control Credit Lines">
<group string="Filters">
<filter name="filter_draft" icon="terp-mail-message-new"
string="Draft" domain="[('state', '=', 'draft')]"
help="Draft lines have to be triaged."/>
<filter name="filter_to_be_sent" icon="terp-mail-forward"
string="Ready To Send" domain="[('state', '=', 'to_be_sent')]"
help="These lines are ready to send by email or by letter using the Actions."/>
<filter name="filter_ignored" icon="terp-mail_delete"
string="Ignored" domain="[('state', '=', 'ignored')]"
help="Lines which have been ignored from previous runs."/>
<filter name="filter_sent" icon="terp-mail-replied"
string="Sent" domain="[('state', '=', 'sent')]"
help="Lines already sent."/>
<filter name="filter_error" icon="terp-gtk-stop" string="Error"
domain="[('state', 'in', ('error', 'email_error'))]"
help="An error has occured during the sending of the email."/>
<filter name="filter_manual" icon="terp-gtk-stop" string="Manual change"
domain="[('manually_overridden', '=', True)]"
help="The line was deprecated by a manual change of policy on invoice."/>
<separator orientation="vertical"/>
<field name="date"/>
<field name="channel" />
<field name="policy_id"/>
</group>
<newline/>
<group expand="0" string="More...">
<field name="partner_id"/>
<field name="account_id"/>
<field name="invoice_id"/>
<field name="level"/>
<field name="policy_level_id"/>
</group>
<newline/>
<group expand="0" string="Group By...">
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'date'}"
icon="terp-go-month" string="Run date"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'level'}"
icon="terp-gtk-jump-to-rtl" string="Level"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'partner_id'}"
icon="terp-partner" string="Partner"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'account_id'}"
icon="terp-folder-green" string="Account"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'invoice_id'}"
icon="terp-document-new" string="Invoice"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'policy_id'}"
icon="terp-document-new" string="Credit policy"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'policy_level_id'}"
icon="terp-document-new" string="Credit policy level"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'channel'}"
icon="terp-document-new" string="Channel"/>
<filter domain='[]' context="{'group_by': 'manually_overridden'}"
icon="terp-document-new" string="Manual change"/>
</group>
</search>
</field>
</record>
<record id="credit_control_line_tree" model="ir.ui.view">
<field name="name">credit.control.line.tree</field>
<field name="model">credit.control.line</field>
<field name="arch" type="xml">
<tree editable="bottom" string="Control Credit Lines" colors="green:state == 'sent';red:state in ('error', 'email_error');">
<field name="date"/>
<field name="date_due"/>
<field name="level"/>
<field name="manually_overridden"/>
<field name="state"/>
<field name="channel"/>
<field name="invoice_id"/>
<field name="partner_id"/>
<field name="amount_due"/>
<field name="balance_due"/>
<field name="currency_id"/>
<field name="move_line_id"/>
<field name="account_id"/>
<field name="policy_level_id"/>
<field name="policy_id"/>
<field name="mail_message_id"/>
</tree>
</field>
</record>
<menuitem
name="Credit Control"
parent="account.menu_finance_periodical_processing"
id="base_credit_control_menu"/>
<record model="ir.actions.act_window" id="credit_control_line_action">
<field name="name">Credit Control Lines</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">credit.control.line</field>
<field name="domain"></field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="credit_control_line_tree"/>
<field name="context">{'search_default_filter_draft': 1, 'search_default_filter_to_be_sent': 1}</field>
<field name="search_view_id" ref="credit_control_line_search"/>
</record>
<menuitem
name="Credit Control Lines"
parent="base_credit_control_menu"
action="credit_control_line_action"
sequence="20"
id="credit_control_line_action_menu"/>
</data>
</openerp>

View File

@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
import logging
from openerp import SUPERUSER_ID
from openerp.modules.registry import RegistryManager
from odoo import SUPERUSER_ID
from odoo.modules.registry import RegistryManager
uid = SUPERUSER_ID

View File

@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright 2012-2014 Camptocamp SA
# Copyright 2017 Okia SPRL (https://okia.be)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import account_account
from . import account_invoice
from . import credit_control_line
from . import credit_control_policy
from . import credit_control_run
from . import mail_mail
from . import res_company
from . import res_partner

View File

@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
from odoo import models, fields
class AccountAccount(models.Model):

View File

@@ -18,7 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, _
from odoo import models, fields, api, _
from odoo.exceptions import Warning
class AccountInvoice(models.Model):
@@ -56,7 +57,7 @@ class AccountInvoice(models.Model):
('state', '!=', 'draft')]
cc_nondraft_lines = cc_line_obj.search(nondraft_domain)
if cc_nondraft_lines:
raise api.Warning(
raise Warning(
_('You cannot cancel this invoice.\n'
'A payment reminder has already been '
'sent to the customer.\n'

View File

@@ -20,9 +20,10 @@
##############################################################################
import logging
from openerp import models, fields, api, _
from odoo import models, fields, api, _
from odoo.exceptions import Warning
logger = logging.getLogger('credit.line.control')
logger = logging.getLogger(__name__)
class CreditControlLine(models.Model):
@@ -40,7 +41,7 @@ class CreditControlLine(models.Model):
date = fields.Date(string='Controlling date',
required=True,
select=True)
index=True)
# maturity date of related move line we do not use
# a related field in order to
# allow manual changes
@@ -130,7 +131,7 @@ class CreditControlLine(models.Model):
store=True,
readonly=True)
level = fields.Integer('credit.control.policy.level',
level = fields.Integer('Level',
related='policy_level_id.level',
store=True,
readonly=True)
@@ -149,8 +150,8 @@ class CreditControlLine(models.Model):
data['date_due'] = move_line.date_maturity
data['state'] = 'draft'
data['channel'] = level.channel
data['invoice_id'] = (move_line.invoice.id if
move_line.invoice else False)
data['invoice_id'] = (move_line.invoice_id.id if
move_line.invoice_id else False)
data['partner_id'] = move_line.partner_id.id
data['amount_due'] = (move_line.amount_currency or move_line.debit or
move_line.credit)
@@ -194,7 +195,10 @@ class CreditControlLine(models.Model):
new_lines = self.browse()
for move_line in lines:
open_amount = move_line.amount_residual_currency
if move_line.currency_id:
open_amount = move_line.amount_residual_currency
else:
open_amount = move_line.amount_residual
cur_tolerance = tolerance.get(move_line.currency_id.id,
tolerance_base)
if check_tolerance and open_amount < cur_tolerance:
@@ -204,7 +208,7 @@ class CreditControlLine(models.Model):
controlling_date,
open_amount)
line = self.create(vals)
new_lines += line
new_lines |= line
# when we have lines generated earlier in draft,
# on the same level, it means that we have left
@@ -222,7 +226,7 @@ class CreditControlLine(models.Model):
def unlink(self):
for line in self:
if line.state != 'draft':
raise api.Warning(
raise Warning(
_('You are not allowed to delete a credit control '
'line that is not in draft state.')
)

View File

@@ -18,7 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, _
from odoo import models, fields, api, _
from odoo.exceptions import Warning
class CreditControlPolicy(models.Model):
@@ -39,7 +40,7 @@ class CreditControlPolicy(models.Model):
'account.account',
string='Accounts',
required=True,
domain="[('type', '=', 'receivable')]",
domain="[('internal_type', '=', 'receivable')]",
help="This policy will be active only"
" for the selected accounts",
)
@@ -51,7 +52,7 @@ class CreditControlPolicy(models.Model):
self.ensure_one()
return [('account_id', 'in', self.account_ids.ids),
('date_maturity', '<=', controlling_date),
('reconcile_id', '=', False),
('reconciled', '=', False),
('partner_id', '!=', False)]
@api.multi
@@ -71,7 +72,7 @@ class CreditControlPolicy(models.Model):
move_l_obj = self.env['account.move.line']
user = self.env.user
if user.company_id.credit_policy_id.id != self.id:
return move_l_obj.browse()
return move_l_obj
domain_line = self._move_lines_domain(controlling_date)
return move_l_obj.search(domain_line)
@@ -97,11 +98,10 @@ class CreditControlPolicy(models.Model):
self.ensure_one()
# MARK possible place for a good optimisation
my_obj = self.env[model]
move_l_obj = self.env['account.move.line']
default_domain = self._move_lines_domain(controlling_date)
to_add = move_l_obj.browse()
to_remove = move_l_obj.browse()
to_add = self.env['account.move.line']
to_remove = self.env['account.move.line']
# The lines which are linked to this policy have to be included in the
# run for this policy.
@@ -110,7 +110,7 @@ class CreditControlPolicy(models.Model):
if add_objs:
domain = list(default_domain)
domain.append((move_relation_field, 'in', add_objs.ids))
to_add = move_l_obj.search(domain)
to_add = to_add.search(domain)
# The lines which are linked to another policy do not have to be
# included in the run for this policy.
@@ -119,7 +119,7 @@ class CreditControlPolicy(models.Model):
if neg_objs:
domain = list(default_domain)
domain.append((move_relation_field, 'in', neg_objs.ids))
to_remove = move_l_obj.search(domain)
to_remove = to_remove.search(domain)
return to_add, to_remove
@api.multi
@@ -177,8 +177,7 @@ class CreditControlPolicy(models.Model):
existing credit line but with a different policy.
"""
self.ensure_one()
move_line_obj = self.env['account.move.line']
different_lines = move_line_obj.browse()
different_lines = self.env['account.move.line']
if not lines:
return different_lines
cr = self.env.cr
@@ -188,7 +187,7 @@ class CreditControlPolicy(models.Model):
(self.id, tuple(lines.ids)))
res = cr.fetchall()
if res:
return move_line_obj.browse([row[0] for row in res])
return different_lines.browse([row[0] for row in res])
return different_lines
@api.multi
@@ -199,7 +198,7 @@ class CreditControlPolicy(models.Model):
if account in x.account_ids or x.do_nothing]
if self not in allowed:
allowed_names = u"\n".join(x.name for x in allowed)
raise api.Warning(
raise Warning(
_('You can only use a policy set on '
'account %s.\n'
'Please choose one of the following '
@@ -229,7 +228,7 @@ class CreditControlPolicyLevel(models.Model):
required=True
)
delay_days = fields.Integer(string='Delay (in days)', required=True)
email_template_id = fields.Many2one('email.template',
email_template_id = fields.Many2one('mail.template',
string='Email Template',
required=True)
channel = fields.Selection([('letter', 'Letter'),
@@ -246,17 +245,20 @@ class CreditControlPolicyLevel(models.Model):
'UNIQUE (policy_id, level)',
'Level must be unique per policy')]
@api.one
@api.multi
@api.constrains('level', 'computation_mode')
def _check_level_mode(self):
""" The smallest level of a policy cannot be computed on the
"previous_date".
"""
smallest_level = self.search([('policy_id', '=', self.policy_id.id)],
order='level asc', limit=1)
if smallest_level.computation_mode == 'previous_date':
return api.ValidationError(_('The smallest level can not be of '
'type Previous Reminder'))
for policy_level in self:
smallest_level = \
self.search([('policy_id', '=', policy_level.policy_id.id)],
order='level asc', limit=1)
if smallest_level.computation_mode == 'previous_date':
return api.ValidationError(_('The smallest level can not be '
'of type Previous Reminder'))
@api.multi
def _previous_level(self):
@@ -321,7 +323,7 @@ class CreditControlPolicyLevel(models.Model):
self.ensure_one()
move_line_obj = self.env['account.move.line']
if not lines:
return move_line_obj.browse()
return move_line_obj
cr = self.env.cr
sql = ("SELECT DISTINCT mv_line.id\n"
" FROM account_move_line mv_line\n"
@@ -345,7 +347,7 @@ class CreditControlPolicyLevel(models.Model):
res = cr.fetchall()
if res:
return move_line_obj.browse([row[0] for row in res])
return move_line_obj.browse()
return move_line_obj
@api.multi
@api.returns('account.move.line')
@@ -355,7 +357,7 @@ class CreditControlPolicyLevel(models.Model):
self.ensure_one()
move_line_obj = self.env['account.move.line']
if not lines:
return move_line_obj.browse()
return move_line_obj
cr = self.env.cr
sql = ("SELECT mv_line.id\n"
" FROM account_move_line mv_line\n"
@@ -389,15 +391,14 @@ class CreditControlPolicyLevel(models.Model):
res = cr.fetchall()
if res:
return move_line_obj.browse([row[0] for row in res])
return move_line_obj.browse()
return move_line_obj
@api.multi
@api.returns('account.move.line')
def get_level_lines(self, controlling_date, lines):
""" get all move lines in entry lines that match the current level """
self.ensure_one()
move_line_obj = self.env['account.move.line']
matching_lines = move_line_obj.browse()
matching_lines = self.env['account.move.line']
if self._previous_level() is None:
method = self._get_first_level_move_lines
else:

View File

@@ -20,9 +20,10 @@
##############################################################################
import logging
from openerp import models, fields, api, _
from odoo import models, fields, api, _
from odoo.exceptions import Warning
logger = logging.getLogger('credit.control.run')
logger = logging.getLogger(__name__)
class CreditControlRun(models.Model):
@@ -83,33 +84,31 @@ class CreditControlRun(models.Model):
runs = self.search([('date', '>', controlling_date)],
order='date DESC', limit=1)
if runs:
raise api.Warning(_('A run has already been executed more '
'recently than %s') % (runs.date))
raise Warning(_('A run has already been executed more '
'recently than %s') % (runs.date))
line_obj = self.env['credit.control.line']
lines = line_obj.search([('date', '>', controlling_date)],
order='date DESC', limit=1)
if lines:
raise api.Warning(_('A credit control line more '
'recent than %s exists at %s') %
(controlling_date, lines.date))
raise Warning(_('A credit control line more '
'recent than %s exists at %s') %
(controlling_date, lines.date))
@api.multi
@api.returns('credit.control.line')
def _generate_credit_lines(self):
""" Generate credit control lines. """
self.ensure_one()
cr_line_obj = self.env['credit.control.line']
move_line_obj = self.env['account.move.line']
manually_managed_lines = move_line_obj.browse()
manually_managed_lines = self.env['account.move.line']
self._check_run_date(self.date)
policies = self.policy_ids
if not policies:
raise api.Warning(_('Please select a policy'))
raise Warning(_('Please select a policy'))
report = ''
generated = cr_line_obj.browse()
generated = self.env['credit.control.line']
for policy in policies:
if policy.do_nothing:
continue
@@ -117,11 +116,11 @@ class CreditControlRun(models.Model):
manual_lines = policy._lines_different_policy(lines)
lines -= manual_lines
manually_managed_lines |= manual_lines
policy_lines_generated = cr_line_obj.browse()
policy_lines_generated = self.env['credit.control.line']
if lines:
# policy levels are sorted by level
# so iteration is in the correct order
create = cr_line_obj.create_or_update_from_mv_lines
create = policy_lines_generated.create_or_update_from_mv_lines
for level in reversed(policy.level_ids):
level_lines = level.get_level_lines(self.date, lines)
policy_lines_generated += create(level_lines,
@@ -158,8 +157,8 @@ class CreditControlRun(models.Model):
except Exception:
# In case of exception openerp will do a rollback
# for us and free the lock
raise api.Warning(_('A credit control run is already running'
' in background, please try later.'))
raise Warning(_('A credit control run is already running '
'in background, please try later.'))
self._generate_credit_lines()
return True

View File

@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
from odoo import models, fields
class Mail(models.Model):

View File

@@ -18,7 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
from odoo import models, fields
class ResCompany(models.Model):

View File

@@ -18,8 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api
from openerp.exceptions import Warning, ValidationError
from odoo import models, fields, api
from odoo.exceptions import Warning, ValidationError
class ResPartner(models.Model):
@@ -32,7 +32,7 @@ class ResPartner(models.Model):
credit_policy_id = fields.Many2one(
'credit.control.policy',
string='Credit Control Policy',
domain="[('account_ids', 'in', property_account_receivable)]",
domain="[('account_ids', 'in', property_account_receivable_id)]",
help="The Credit Control Policy used for this "
"partner. This setting can be forced on the "
"invoice. If nothing is defined, it will use "
@@ -43,14 +43,14 @@ class ResPartner(models.Model):
string='Credit Control Lines',
readonly=True)
@api.constrains('credit_policy_id', 'property_account_receivable')
@api.constrains('credit_policy_id', 'property_account_receivable_id')
def _check_credit_policy(self):
""" Ensure that policy on partner are limited to the account policy """
for partner in self:
if (not partner.property_account_receivable or
if (not partner.property_account_receivable_id or
not partner.credit_policy_id):
continue
account = partner.property_account_receivable
account = partner.property_account_receivable_id
policy = partner.credit_policy_id
try:
policy.check_policy_against_account(account)

View File

@@ -1,24 +0,0 @@
<openerp>
<data>
<record id="partner_followup_form_view" model="ir.ui.view">
<field name="name">partner.credit_control.form.view</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form" />
<field name="arch" type="xml">
<field name="credit_limit" position="after">
<field name="credit_policy_id" widget="selection"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_use"/>
</field>
</field>
</record>
<act_window
id="act_partner_credit_relation_relation"
name="Credit Lines"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user"
domain="[('partner_id', '=', active_id)]"
res_model="credit.control.line"
src_model="res.partner"/>
</data>
</openerp>

View File

@@ -1,131 +0,0 @@
<openerp>
<data>
<record id="credit_control_policy_form" model="ir.ui.view">
<field name="name">credit.control.policy.form</field>
<field name="model">credit.control.policy</field>
<field name="arch" type="xml">
<form string="Credit control policy">
<group>
<field name="name"/>
<field name="do_nothing"/>
<field name="company_id"/>
<field name="active"/>
</group>
<notebook colspan="4">
<page string="Policy levels">
<field name="level_ids" nolabel="1" colspan="4" >
<tree string="Credit control policy Level">
<field name="name"/>
<field name="level"/>
<field name="channel"/>
<field name="delay_days"/>
<field name="computation_mode"/>
<field name="email_template_id"/>
</tree>
<form string="Policy level">
<field name="name"/>
<notebook colspan="4">
<page string="Delay Setting">
<group>
<field name="level"/>
<field name="channel"/>
<field name="delay_days"/>
<field name="computation_mode"/>
</group>
</page>
<page string="Mail and reporting">
<group>
<field name="email_template_id"/>
<newline/>
<field name="custom_text" colspan="4"/>
<newline/>
<field name="custom_mail_text" colspan="4"/>
</group>
</page>
</notebook>
</form>
</field>
</page>
<page string="Accounts">
<field name="account_ids" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record id="credit_control_policy_tree" model="ir.ui.view">
<field name="name">credit.control.policy.tree</field>
<field name="model">credit.control.policy</field>
<field name="arch" type="xml">
<tree string="Credit control policy">
<field name="name"/>
<field name="do_nothing"/>
</tree>
</field>
</record>
<menuitem
name="Credit Control"
parent="account.menu_finance_configuration"
id="base_credit_control_configuration_menu"/>
<record model="ir.actions.act_window" id="credit_policy_configuration_action">
<field name="name">Credit Control Policies</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">credit.control.policy</field>
<field name="domain"></field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="credit_control_policy_tree"/>
</record>
<menuitem
name="Credit Control Policies"
parent="base_credit_control_configuration_menu"
action="credit_policy_configuration_action"
id="credit_policy_configuration_action_menu"/>
<record id="credit_mangement_policy_level_form" model="ir.ui.view">
<field name="name">credit.mangement.policy.level.form</field>
<field name="model">credit.control.policy.level</field>
<field name="arch" type="xml">
<form string="Policy level">
<field name="name"/>
<notebook colspan="4">
<page string="Delay Setting">
<group>
<field name="level"/>
<field name="channel"/>
<field name="delay_days"/>
<field name="computation_mode"/>
</group>
</page>
<page string="Mail and reporting">
<group>
<field name="email_template_id"/>
<field name="custom_text"/>
</group>
</page>
</notebook>
</form>
</field>
</record>
<record id="credit_control_policy_level_tree" model="ir.ui.view">
<field name="name">credit.control.policy.level.tree</field>
<field name="model">credit.control.policy.level</field>
<field name="arch" type="xml">
<tree string="Credit control policy level">
<field name="name"/>
<field name="level"/>
<field name="channel"/>
<field name="delay_days"/>
<field name="computation_mode"/>
<field name="email_template_id"/>
</tree>
</field>
</record>
</data>
</openerp>

View File

@@ -1,15 +1,12 @@
<openerp>
<data>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<report
id="credit_control_summary"
model="credit.control.communication"
string="Credit Control Summary"
report_type="qweb-pdf"
name="account_credit_control.report_credit_control_summary"
file="account_credit_control.report_credit_control_summary"
auto="False"
/>
</data>
</openerp>
id="credit_control_summary"
model="credit.control.communication"
string="Credit Control Summary"
report_type="qweb-pdf"
name="account_credit_control.report_credit_control_summary"
file="account_credit_control.report_credit_control_summary"
auto="False"
/>
</odoo>

View File

@@ -1,99 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<template id="report_credit_control_summary_document">
<t t-call="report.external_layout">
<div class="page">
<div class="row" id="address">
<div class="col-xs-5 col-xs-offset-7">
<address t-field="o.contact_address"
t-field-options='{"widget": "contact",
<t t-call="report.external_layout">
<div class="page">
<div class="row" id="address">
<div class="col-xs-5 col-xs-offset-7">
<address t-field="doc.contact_address"
t-field-options='{"widget": "contact",
"fields": ["address", "name"],
"no_marker": true}' />
"no_marker": true}'/>
</div>
<div class="col-xs-5 col-xs-offset-7">
<span t-field="doc.report_date"/>
</div>
</div>
<h2 id="policy_level">
<span t-field="doc.current_policy_level.name"/>
</h2>
<p class="mt32 mb32"
t-field="doc.current_policy_level.custom_text"/>
<h3>Summary</h3>
<table class="table table-condensed" id="summary_table">
<thead>
<tr>
<th>Invoice number</th>
<th>Invoice date</th>
<th>Date due</th>
<th class="text-right">Invoiced amount</th>
<th class="text-right">Open amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="doc.credit_control_line_ids" t-as="l">
<t t-if="l.invoice_id">
<td>
<span t-field="l.invoice_id.number"/>
<t t-if="l.invoice_id.name">
<span t-field="l.invoice_id.name"/>
</t>
</td>
</t>
<t t-if="not l.invoice_id">
<td>
<span t-field="l.move_line_id.name"/>
</td>
</t>
<td>
<span t-field="l.date_entry"/>
</td>
<td>
<span t-field="l.date_due"/>
</td>
<td class="text-right">
<span t-field="l.amount_due"/>
</td>
<td class="text-right">
<span t-field="l.balance_due"/>
</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr>
<td>
<strong>Total Invoiced</strong>
</td>
<td class="text-right">
<span t-field="doc.total_invoiced" />
</td>
</tr>
<tr>
<td>
<strong>Total Due</strong>
</td>
<td class="text-right">
<span t-field="doc.total_due"/>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="col-xs-5 col-xs-offset-7">
<span t-field="o.report_date"/>
</div>
</div>
<h2 id="policy_level">
<span t-field="o.current_policy_level.name"/>
</h2>
<p class="mt32 mb32" t-field="o.current_policy_level.custom_text"/>
<h3>Summary</h3>
<table class="table table-condensed" id="summary_table">
<thead>
<tr>
<th>Invoice number</th>
<th>Invoice date</th>
<th>Date due</th>
<th class="text-right">Invoiced amount</th>
<th class="text-right">Open amount</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.credit_control_line_ids" t-as="l">
<t t-if="l.invoice_id">
<td><span t-field="l.invoice_id.number"/>
<t t-if="l.invoice_id.name">
<span t-field="l.invoice_id.name"/>
</t>
</td>
</t>
<t t-if="not l.invoice_id">
<td><span t-field="l.move_line_id.name"/></td>
</t>
<td>
<span t-field="l.date_entry"/>
</td>
<td>
<span t-field="l.date_due"/>
</td>
<td class="text-right">
<span t-field="l.amount_due"/>
</td>
<td class="text-right">
<span t-field="l.balance_due"
t-field-options='{"widget": "monetary",
"display_currency": "l.currency_id or l.company_id.currency_id"}'/>
</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr>
<td><strong>Total Invoiced</strong></td>
<td class="text-right">
<span t-field="o.total_invoiced" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
<tr>
<td><strong>Total Due</strong></td>
<td class="text-right">
<span t-field="o.total_due" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
</table>
</div>
</div>
</div>
</t>
</t>
</template>
<template id="report_credit_control_summary">
<t t-call="report.html_container">
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'account_credit_control.report_credit_control_summary_document')"/>
<t t-call="report.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="account_credit_control.report_credit_control_summary_document" t-lang="doc.partner_id.lang" />
</t>
</t>
</t>
</template>
</data>
</openerp>
</odoo>

View File

@@ -1,75 +0,0 @@
<openerp>
<data>
<record id="credit_control_run_tree" model="ir.ui.view">
<field name="name">credit.control.run.tree</field>
<field name="model">credit.control.run</field>
<field name="arch" type="xml">
<tree string="Credit control run">
<field name="date"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="credit_control_run_form" model="ir.ui.view">
<field name="name">credit.control.run.form</field>
<field name="model">credit.control.run</field>
<field name="arch" type="xml">
<form string="Credit control run">
<header>
<button name="generate_credit_lines"
string="Compute Credit Control Lines"
class="oe_highlight"
type="object" icon="gtk-execute"
attrs="{'invisible': [('state', '!=', 'draft')]}"/>
<button name="open_credit_lines"
string="Open Credit Control Lines"
type="object"
attrs="{'invisible': [('state', '=', 'draft')]}"/>
<field name="state" widget="statusbar"
statusbar_visible="draft,done"
statusbar_colors='{}'/>
</header>
<sheet>
<group>
<field name="date"/>
</group>
<notebook>
<page string="Policies">
<field name="policy_ids" colspan="4" nolabel="1"/>
<separator string="Report"
attrs="{'invisible': [('report', '=', False)]}"/>
<field name="report" colspan="4" nolabel="1"
attrs="{'invisible': [('report', '=', False)]}"/>
</page>
<page string="Manual Lines" groups="base.group_no_one">
<field name="manual_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="credit_control_run">
<field name="name">Credit Control Run</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">credit.control.run</field>
<field name="domain"></field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="credit_control_run_tree"/>
</record>
<menuitem
name="Credit Control Run"
parent="base_credit_control_menu"
action="credit_control_run"
sequence="10"
id="credit_control_run_menu"/>
</data>
</openerp>

View File

@@ -2,7 +2,7 @@
"account_credit_control.ir_model_access_270",1,1,"group_account_credit_control_manager","credit_control_manager_line","account_credit_control.model_credit_control_line",1,1
"account_credit_control.ir_model_access_271",1,1,"group_account_credit_control_user","credit_control_user_line","account_credit_control.model_credit_control_line",1,1
"account_credit_control.ir_model_access_272",0,0,"group_account_credit_control_info","credit_control_info_line","account_credit_control.model_credit_control_line",1,0
"account_credit_control.ir_model_access_273",1,1,"group_account_credit_control_manager","credit_control_manager_mail_template","email_template.model_email_template",1,1
"account_credit_control.ir_model_access_273",1,1,"group_account_credit_control_manager","credit_control_manager_mail_template","mail.model_mail_template",1,1
"account_credit_control.ir_model_access_275",1,1,"group_account_credit_control_manager","credit_control_manager_mail_message","mail.model_mail_message",1,1
"account_credit_control.ir_model_access_276",1,0,"group_account_credit_control_user","credit_control_user_mail_message","mail.model_mail_message",1,1
"account_credit_control.ir_model_access_277",0,0,"group_account_credit_control_info","credit_control_info_mail_message","mail.model_mail_message",1,0
@@ -17,4 +17,4 @@
"account_credit_control.ir_model_access_289",0,0,"group_account_credit_control_info","credit_control_info_level","account_credit_control.model_credit_control_policy_level",1,0
"account_credit_control.ir_model_access_290",0,0,"account.group_account_user","credit_control_fin_user_line","account_credit_control.model_credit_control_line",1,0
"account_credit_control.ir_model_access_291",0,0,"account.group_account_invoice","credit_control_fin_invoice_line","account_credit_control.model_credit_control_line",1,0
"account_credit_control.ir_model_access_292",1,1,"account.group_account_manager","credit_control_fin_manager_line","account_credit_control.model_credit_control_line",1,1
"account_credit_control.ir_model_access_292",1,1,"account.group_account_manager","credit_control_fin_manager_line","account_credit_control.model_credit_control_line",1,1
1 id perm_create perm_unlink group_id/id name model_id/id perm_read perm_write
2 account_credit_control.ir_model_access_270 1 1 group_account_credit_control_manager credit_control_manager_line account_credit_control.model_credit_control_line 1 1
3 account_credit_control.ir_model_access_271 1 1 group_account_credit_control_user credit_control_user_line account_credit_control.model_credit_control_line 1 1
4 account_credit_control.ir_model_access_272 0 0 group_account_credit_control_info credit_control_info_line account_credit_control.model_credit_control_line 1 0
5 account_credit_control.ir_model_access_273 1 1 group_account_credit_control_manager credit_control_manager_mail_template email_template.model_email_template mail.model_mail_template 1 1
6 account_credit_control.ir_model_access_275 1 1 group_account_credit_control_manager credit_control_manager_mail_message mail.model_mail_message 1 1
7 account_credit_control.ir_model_access_276 1 0 group_account_credit_control_user credit_control_user_mail_message mail.model_mail_message 1 1
8 account_credit_control.ir_model_access_277 0 0 group_account_credit_control_info credit_control_info_mail_message mail.model_mail_message 1 0
17 account_credit_control.ir_model_access_289 0 0 group_account_credit_control_info credit_control_info_level account_credit_control.model_credit_control_policy_level 1 0
18 account_credit_control.ir_model_access_290 0 0 account.group_account_user credit_control_fin_user_line account_credit_control.model_credit_control_line 1 0
19 account_credit_control.ir_model_access_291 0 0 account.group_account_invoice credit_control_fin_invoice_line account_credit_control.model_credit_control_line 1 0
20 account_credit_control.ir_model_access_292 1 1 account.group_account_manager credit_control_fin_manager_line account_credit_control.model_credit_control_line 1 1

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="category_credit_control" model="ir.module.category">
<field name="name">Credit Control</field>
<field name="sequence" eval="99" />
</record>
<record id="group_account_credit_control_info" model="res.groups" context="{'noadmin':True}">
<field name="name">Info</field>
<field name="category_id" ref="category_credit_control"/>
</record>
<record id="group_account_credit_control_user" model="res.groups" context="{'noadmin':True}">
<field name="name">User</field>
<field name="category_id" ref="category_credit_control"/>
<field name="implied_ids" eval="[(4, ref('group_account_credit_control_info'))]"/>
</record>
<record id="group_account_credit_control_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="category_credit_control"/>
<field name="implied_ids" eval="[(4, ref('group_account_credit_control_user'))]"/>
</record>
</odoo>

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<act_window
id="act_account_credit_relation_relation"
name="Credit Lines"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user"
domain="[('account_id', '=', active_id)]"
res_model="credit.control.line"
src_model="account.account"/>
<record id="invoice_followup_form_view" model="ir.ui.view">
<field name="name">invoice.followup.form.view</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Credit Control"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user,account_credit_control.group_account_credit_control_info">
<group>
<field name="credit_policy_id" widget="selection"
string="Manual Credit Control Policy"
attrs="{'invisible': [('credit_policy_id', '=', False)]}"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user,account_credit_control.group_account_credit_control_info"/>
</group>
<separator string="Issued Lines" colspan="4"/>
<field name="credit_control_line_ids" colspan="4"
nolabel="1"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user,account_credit_control.group_account_credit_control_info">
<tree string="Credit Control Lines">
<field name="date"/>
<field name="level"/>
<field name="state"/>
<field name="channel"/>
<field name="balance_due"/>
<field name="policy_level_id"/>
<field name="policy_id"/>
</tree>
</field>
</page>
</notebook>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="credit_control_line_form" model="ir.ui.view">
<field name="name">credit.control.line.form</field>
<field name="model">credit.control.line</field>
<field name="arch" type="xml">
<form string="Control Credit Lines">
<header>
<field name="state" widget="statusbar"
statusbar_visible="draft,to_be_sent,sent"
statusbar_colors='{"error":"red","email_error":"red"}'/>
</header>
<sheet>
<group>
<group>
<field name="partner_id"/>
<field name="policy_level_id"/>
<field name="policy_id"/>
<field name="level"/>
<field name="manually_overridden"/>
</group>
<group>
<field name="date"/>
<field name="date_due"/>
<field name="channel"/>
<field name="date_sent"/>
<field name="mail_message_id"/>
</group>
</group>
<group>
<group>
<field name="invoice_id"/>
<field name="move_line_id"/>
<field name="account_id"/>
</group>
<group>
<field name="amount_due"/>
<field name="balance_due"/>
<field name="currency_id"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record id="credit_control_line_search" model="ir.ui.view">
<field name="name">Credit Control Lines</field>
<field name="model">credit.control.line</field>
<field name="arch" type="xml">
<search string="Control Credit Lines">
<group string="Filters">
<filter name="filter_draft" icon="terp-mail-message-new"
string="Draft" domain="[('state', '=', 'draft')]"
help="Draft lines have to be triaged."/>
<filter name="filter_to_be_sent" icon="terp-mail-forward"
string="Ready To Send"
domain="[('state', '=', 'to_be_sent')]"
help="These lines are ready to send by email or by letter using the Actions."/>
<filter name="filter_ignored" icon="terp-mail_delete"
string="Ignored"
domain="[('state', '=', 'ignored')]"
help="Lines which have been ignored from previous runs."/>
<filter name="filter_sent" icon="terp-mail-replied"
string="Sent" domain="[('state', '=', 'sent')]"
help="Lines already sent."/>
<filter name="filter_error" icon="terp-gtk-stop"
string="Error"
domain="[('state', 'in', ('error', 'email_error'))]"
help="An error has occured during the sending of the email."/>
<filter name="filter_manual" icon="terp-gtk-stop"
string="Manual change"
domain="[('manually_overridden', '=', True)]"
help="The line was deprecated by a manual change of policy on invoice."/>
<separator orientation="vertical"/>
<field name="date"/>
<field name="channel"/>
<field name="policy_id"/>
</group>
<newline/>
<group expand="0" string="More...">
<field name="partner_id"/>
<field name="account_id"/>
<field name="invoice_id"/>
<field name="level"/>
<field name="policy_level_id"/>
</group>
<newline/>
<group expand="0" string="Group By...">
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'date'}"
icon="terp-go-month" string="Run date"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'level'}"
icon="terp-gtk-jump-to-rtl" string="Level"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'partner_id'}"
icon="terp-partner" string="Partner"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'account_id'}"
icon="terp-folder-green" string="Account"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'invoice_id'}"
icon="terp-document-new" string="Invoice"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'policy_id'}"
icon="terp-document-new" string="Credit policy"/>
<separator orientation="vertical"/>
<filter domain='[]'
context="{'group_by': 'policy_level_id'}"
icon="terp-document-new"
string="Credit policy level"/>
<separator orientation="vertical"/>
<filter domain='[]' context="{'group_by': 'channel'}"
icon="terp-document-new" string="Channel"/>
<filter domain='[]'
context="{'group_by': 'manually_overridden'}"
icon="terp-document-new" string="Manual change"/>
</group>
</search>
</field>
</record>
<record id="credit_control_line_tree" model="ir.ui.view">
<field name="name">credit.control.line.tree</field>
<field name="model">credit.control.line</field>
<field name="arch" type="xml">
<tree editable="bottom" string="Control Credit Lines"
colors="green:state == 'sent';red:state in ('error', 'email_error');">
<field name="date"/>
<field name="date_due"/>
<field name="level"/>
<field name="manually_overridden"/>
<field name="state"/>
<field name="channel"/>
<field name="invoice_id"/>
<field name="partner_id"/>
<field name="amount_due"/>
<field name="balance_due"/>
<field name="currency_id"/>
<field name="move_line_id"/>
<field name="account_id"/>
<field name="policy_level_id"/>
<field name="policy_id"/>
<field name="mail_message_id"/>
</tree>
</field>
</record>
<menuitem
name="Credit Control"
parent="account.menu_finance_reports"
id="base_credit_control_menu" sequence="10"/>
<record model="ir.actions.act_window" id="credit_control_line_action">
<field name="name">Credit Control Lines</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">credit.control.line</field>
<field name="domain"></field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="credit_control_line_tree"/>
<field name="context">{'search_default_filter_draft': 1,
'search_default_filter_to_be_sent': 1}
</field>
<field name="search_view_id" ref="credit_control_line_search"/>
</record>
<menuitem
name="Credit Control Lines"
parent="base_credit_control_menu"
action="credit_control_line_action"
sequence="20"
id="credit_control_line_action_menu"/>
</odoo>

View File

@@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="credit_control_policy_form" model="ir.ui.view">
<field name="name">credit.control.policy.form</field>
<field name="model">credit.control.policy</field>
<field name="arch" type="xml">
<form string="Credit control policy">
<group>
<field name="name"/>
<field name="do_nothing"/>
<field name="company_id"/>
<field name="active"/>
</group>
<notebook colspan="4">
<page string="Policy levels">
<field name="level_ids" nolabel="1" colspan="4">
<tree string="Credit control policy Level">
<field name="name"/>
<field name="level"/>
<field name="channel"/>
<field name="delay_days"/>
<field name="computation_mode"/>
<field name="email_template_id"/>
</tree>
<form string="Policy level">
<field name="name"/>
<notebook colspan="4">
<page string="Delay Setting">
<group>
<field name="level"/>
<field name="channel"/>
<field name="delay_days"/>
<field name="computation_mode"/>
</group>
</page>
<page string="Mail and reporting">
<group>
<field name="email_template_id"/>
<newline/>
<field name="custom_text"
colspan="4"/>
<newline/>
<field name="custom_mail_text"
colspan="4"/>
</group>
</page>
</notebook>
</form>
</field>
</page>
<page string="Accounts">
<field name="account_ids" nolabel="1"/>
</page>
</notebook>
</form>
</field>
</record>
<record id="credit_control_policy_tree" model="ir.ui.view">
<field name="name">credit.control.policy.tree</field>
<field name="model">credit.control.policy</field>
<field name="arch" type="xml">
<tree string="Credit control policy">
<field name="name"/>
<field name="do_nothing"/>
</tree>
</field>
</record>
<menuitem
name="Credit Control"
parent="account.menu_finance_configuration"
id="base_credit_control_configuration_menu"/>
<record model="ir.actions.act_window"
id="credit_policy_configuration_action">
<field name="name">Credit Control Policies</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">credit.control.policy</field>
<field name="domain"></field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="credit_control_policy_tree"/>
</record>
<menuitem
name="Credit Control Policies"
parent="base_credit_control_configuration_menu"
action="credit_policy_configuration_action"
id="credit_policy_configuration_action_menu"/>
<record id="credit_mangement_policy_level_form" model="ir.ui.view">
<field name="name">credit.mangement.policy.level.form</field>
<field name="model">credit.control.policy.level</field>
<field name="arch" type="xml">
<form string="Policy level">
<field name="name"/>
<notebook colspan="4">
<page string="Delay Setting">
<group>
<field name="level"/>
<field name="channel"/>
<field name="delay_days"/>
<field name="computation_mode"/>
</group>
</page>
<page string="Mail and reporting">
<group>
<field name="email_template_id"/>
<field name="custom_text"/>
</group>
</page>
</notebook>
</form>
</field>
</record>
<record id="credit_control_policy_level_tree" model="ir.ui.view">
<field name="name">credit.control.policy.level.tree</field>
<field name="model">credit.control.policy.level</field>
<field name="arch" type="xml">
<tree string="Credit control policy level">
<field name="name"/>
<field name="level"/>
<field name="channel"/>
<field name="delay_days"/>
<field name="computation_mode"/>
<field name="email_template_id"/>
</tree>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="credit_control_run_tree" model="ir.ui.view">
<field name="name">credit.control.run.tree</field>
<field name="model">credit.control.run</field>
<field name="arch" type="xml">
<tree string="Credit control run">
<field name="date"/>
<field name="state"/>
</tree>
</field>
</record>
<record id="credit_control_run_form" model="ir.ui.view">
<field name="name">credit.control.run.form</field>
<field name="model">credit.control.run</field>
<field name="arch" type="xml">
<form string="Credit control run">
<header>
<button name="generate_credit_lines"
string="Compute Credit Control Lines"
class="oe_highlight"
type="object" icon="gtk-execute"
attrs="{'invisible': [('state', '!=', 'draft')]}"/>
<button name="open_credit_lines"
string="Open Credit Control Lines"
type="object"
attrs="{'invisible': [('state', '=', 'draft')]}"/>
<field name="state" widget="statusbar"
statusbar_visible="draft,done"
statusbar_colors='{}'/>
</header>
<sheet>
<group>
<field name="date"/>
</group>
<notebook>
<page string="Policies">
<field name="policy_ids" colspan="4" nolabel="1"/>
<separator string="Report"
attrs="{'invisible': [('report', '=', False)]}"/>
<field name="report" colspan="4" nolabel="1"
attrs="{'invisible': [('report', '=', False)]}"/>
</page>
<page string="Manual Lines" groups="base.group_no_one">
<field name="manual_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="credit_control_run">
<field name="name">Credit Control Run</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">credit.control.run</field>
<field name="domain"></field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="credit_control_run_tree"/>
</record>
<menuitem
name="Credit Control Run"
parent="base_credit_control_menu"
action="credit_control_run"
sequence="10"
id="credit_control_run_menu"/>
</odoo>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="credit_control_company_form" model="ir.ui.view">
<field name="name">credit.control.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<field name="currency_id" position="after">
<field name="credit_policy_id" widget="selection"/>
<field name="credit_control_tolerance"/>
</field>
</field>
</record>
</odoo>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="partner_followup_form_view" model="ir.ui.view">
<field name="name">partner.credit_control.form.view</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.view_partner_property_form"/>
<field name="arch" type="xml">
<field name="credit" position="after">
<field name="credit_policy_id" widget="selection"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_use"/>
</field>
</field>
</record>
<act_window
id="act_partner_credit_relation_relation"
name="Credit Lines"
groups="account_credit_control.group_account_credit_control_manager,account_credit_control.group_account_credit_control_user"
domain="[('partner_id', '=', active_id)]"
res_model="credit.control.line"
src_model="res.partner"/>
</odoo>

View File

@@ -19,9 +19,9 @@
#
##############################################################################
import logging
from openerp import models, fields, api
from odoo import models, fields, api
logger = logging.getLogger('credit.control.line.mailing')
logger = logging.getLogger(__name__)
class CreditCommunication(models.TransientModel):
@@ -81,13 +81,14 @@ class CreditCommunication(models.TransientModel):
balance_field = 'credit_control_line_ids.balance_due'
return sum(self.mapped(balance_field))
@api.one
@api.multi
@api.depends('credit_control_line_ids',
'credit_control_line_ids.amount_due',
'credit_control_line_ids.balance_due')
def _compute_total(self):
self.total_invoiced = self._get_total()
self.total_due = self._get_total_due()
for communication in self:
communication.total_invoiced = communication._get_total()
communication.total_due = communication._get_total_due()
@api.model
@api.returns('self', lambda value: value.id)
@@ -176,30 +177,21 @@ class CreditCommunication(models.TransientModel):
@api.returns('mail.mail')
def _generate_emails(self):
""" Generate email message using template related to level """
email_message_obj = self.env['mail.mail']
# Warning: still using the old-api on 'email.template' because
# the method generate_email() does not follow the cr, uid, ids
# convention and the new api wrapper can't translate the call
email_template_obj = self.pool['email.template']
att_obj = self.env['ir.attachment']
emails = email_message_obj.browse()
emails = self.env['mail.mail']
attachments = self.env['ir.attachment']
required_fields = ['subject',
'body_html',
'email_from',
'email_to']
cr, uid, context = self.env.cr, self.env.uid, self.env.context
for comm in self:
template = comm.current_policy_level.email_template_id
email_values = email_template_obj.generate_email(cr, uid,
template.id,
comm.id,
context=context)
email_values = template.generate_email(comm.id)
email_values['type'] = 'email'
# model is Transient record (self) removed periodically so no point
# of storing res_id
email_values.pop('model', None)
email_values.pop('res_id', None)
email = email_message_obj.create(email_values)
email = emails.create(email_values)
state = 'sent'
# The mail will not be send, however it will be in the pool, in an
@@ -213,7 +205,6 @@ class CreditCommunication(models.TransientModel):
comm.credit_control_line_ids.write({'mail_message_id': email.id,
'state': state})
attachments = att_obj.browse()
for att in email_values.get('attachments', []):
attach_fname = att[0]
attach_datas = att[1]
@@ -225,7 +216,7 @@ class CreditCommunication(models.TransientModel):
'res_id': email.id,
'type': 'binary',
}
attachments += att_obj.create(data_attach)
attachments |= attachments.create(data_attach)
email.write({'attachment_ids': [(6, 0, attachments.ids)]})
emails += email
return emails
@@ -242,8 +233,7 @@ class CreditCommunication(models.TransientModel):
@api.multi
@api.returns('credit.control.line')
def _mark_credit_line_as_sent(self):
line_obj = self.env['credit.control.line']
lines = line_obj.browse()
lines = self.env['credit.control.line']
for comm in self:
lines |= comm.credit_control_line_ids

View File

@@ -19,7 +19,8 @@
#
##############################################################################
from openerp import models, fields, api, _
from odoo import models, fields, api, _
from odoo.exceptions import Warning
class CreditControlEmailer(models.TransientModel):
@@ -59,7 +60,7 @@ class CreditControlEmailer(models.TransientModel):
def email_lines(self):
self.ensure_one()
if not self.line_ids:
raise api.Warning(_('No credit control lines selected.'))
raise Warning(_('No credit control lines selected.'))
comm_obj = self.env['credit.control.communication']

View File

@@ -1,54 +1,53 @@
<openerp>
<data>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="credit_line_emailer_form" model="ir.ui.view">
<field name="name">credit.line.emailer.form</field>
<field name="model">credit.control.emailer</field>
<field name="arch" type="xml">
<form string="Mailer" version="7.0">
<separator string="Send emails for the selected lines" colspan="4"/>
<newline/>
<notebook>
<page string="Lines">
<field name="line_ids" colspan="4" nolabel="1" />
</page>
</notebook>
<newline/>
<footer>
<button class="oe_highlight"
name="email_lines"
string="Send the emails"
type="object"/>
or
<button
class="oe_link"
special="cancel"
string="Cancel"/>
</footer>
</form>
</field>
<field name="name">credit.line.emailer.form</field>
<field name="model">credit.control.emailer</field>
<field name="arch" type="xml">
<form string="Mailer" version="7.0">
<separator string="Send emails for the selected lines"
colspan="4"/>
<newline/>
<notebook>
<page string="Lines">
<field name="line_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
<newline/>
<footer>
<button class="oe_highlight"
name="email_lines"
string="Send the emails"
type="object"/>
or
<button
class="oe_link"
special="cancel"
string="Cancel"/>
</footer>
</form>
</field>
</record>
<!-- for menu -->
<act_window name="Send By Email"
res_model="credit.control.emailer"
src_model="credit.control.line"
view_mode="form"
target="new"
key2="client_action_multi"
id="open_credit_line_emailer_wizard_menu_action"/>
res_model="credit.control.emailer"
src_model="credit.control.line"
view_mode="form"
target="new"
key2="client_action_multi"
id="open_credit_line_emailer_wizard_menu_action"/>
<!-- for button -->
<record id="open_credit_line_emailer_wizard" model="ir.actions.act_window">
<field name="name">Send By Email</field>
<field name="res_model">credit.control.emailer</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="credit_line_emailer_form"/>
<field name="target">new</field>
<field name="help">Send an email for the selected lines.</field>
<field name="name">Send By Email</field>
<field name="res_model">credit.control.emailer</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="credit_line_emailer_form"/>
<field name="target">new</field>
<field name="help">Send an email for the selected lines.</field>
</record>
</data>
</openerp>
</odoo>

View File

@@ -18,7 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields, api, _
from odoo import models, fields, api, _
from odoo.exceptions import Warning
class CreditControlMarker(models.TransientModel):
@@ -71,12 +72,12 @@ class CreditControlMarker(models.TransientModel):
self.ensure_one()
if not self.line_ids:
raise api.Warning(_('No credit control lines selected.'))
raise Warning(_('No credit control lines selected.'))
filtered_lines = self._filter_lines(self.line_ids)
if not filtered_lines:
raise api.Warning(_('No lines will be changed. '
'All the selected lines are already done.'))
raise Warning(_('No lines will be changed. '
'All the selected lines are already done.'))
self._mark_lines(filtered_lines, self.name)

View File

@@ -1,39 +1,42 @@
<openerp>
<data>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="credit_line_marker_form" model="ir.ui.view">
<field name="name">credit.line.marker.form</field>
<field name="model">credit.control.marker</field>
<field name="arch" type="xml">
<form string="Lines marker" version="7.0">
<separator string="Change the state of the selected lines" colspan="4"/>
<newline/>
<label string="Warning: you will maybe not be able to revert this operation." colspan="4"></label>
<newline/>
<group>
<group><field name="name"/></group>
<group></group>
</group>
<notebook>
<page string="Lines">
<field name="line_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
<newline/>
<footer>
<button
class="oe_highlight"
name="mark_lines"
string="Change Lines' State"
type="object"/>
or
<button
class="oe_link"
special="cancel"
string="Cancel"/>
</footer>
</form>
</field>
<field name="name">credit.line.marker.form</field>
<field name="model">credit.control.marker</field>
<field name="arch" type="xml">
<form string="Lines marker" version="7.0">
<separator string="Change the state of the selected lines"
colspan="4"/>
<newline/>
<label string="Warning: you will maybe not be able to revert this operation."
colspan="4"></label>
<newline/>
<group>
<group>
<field name="name"/>
</group>
<group></group>
</group>
<notebook>
<page string="Lines">
<field name="line_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
<newline/>
<footer>
<button
class="oe_highlight"
name="mark_lines"
string="Change Lines' State"
type="object"/>
or
<button
class="oe_link"
special="cancel"
string="Cancel"/>
</footer>
</form>
</field>
</record>
<!-- for menu -->
@@ -46,15 +49,14 @@
id="open_credit_line_marker_wizard_menu_action"/>
<record id="open_credit_line_marker_wizard" model="ir.actions.act_window">
<field name="name">Change Lines' State</field>
<field name="res_model">credit.control.marker</field>
<field name="src_model">credit.control.line</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="credit_line_marker_form"/>
<field name="target">new</field>
<field name="help">Change the state of the selected lines.</field>
<field name="name">Change Lines' State</field>
<field name="res_model">credit.control.marker</field>
<field name="src_model">credit.control.line</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="credit_line_marker_form"/>
<field name="target">new</field>
<field name="help">Change the state of the selected lines.</field>
</record>
</data>
</openerp>
</odoo>

View File

@@ -19,11 +19,14 @@
#
##############################################################################
import logging
from openerp import models, fields, api, _
from odoo import models, fields, api, _
from odoo.exceptions import Warning
logger = logging.getLogger(__name__)
class credit_control_policy_changer(models.TransientModel):
class CreditControlPolicyChanger(models.TransientModel):
""" Wizard that is run from invoices and allows to set manually a policy
Policy are actually apply to related move lines availabe
in selection widget
@@ -52,18 +55,17 @@ class credit_control_policy_changer(models.TransientModel):
context = self.env.context
active_ids = context.get('active_ids')
invoice_obj = self.env['account.invoice']
move_line_obj = self.env['account.move.line']
if not active_ids:
return False
selected_lines = move_line_obj.browse()
selected_lines = self.env['account.move.line']
for invoice in invoice_obj.browse(active_ids):
if invoice.type in ('in_invoice', 'in_refund', 'out_refund'):
raise api.Warning(_('Please use wizard on customer invoices'))
raise Warning(_('Please use wizard on customer invoices'))
domain = [('account_id', '=', invoice.account_id.id),
('move_id', '=', invoice.move_id.id),
('reconcile_id', '=', False)]
move_lines = move_line_obj.search(domain)
move_lines = selected_lines.search(domain)
selected_lines |= move_lines
return selected_lines

View File

@@ -1,54 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<odoo>
<record id="credit_control_policy_changer_form" model="ir.ui.view">
<field name="name">credit control policy form</field>
<field name="model">credit.control.policy.changer</field>
<field name="arch" type="xml">
<form version="7.0" string="Set current credit level">
<separator string="Change the overdue level of current invoice" colspan="4"/>
<label string="This wizard will let you set the overdue policy and level for selected invoices"/>
<newline/>
<group>
<group>
<field name="new_policy_id"/>
<field name="do_nothing"
invisible="1"/>
<field name="new_policy_level_id"
domain="[('policy_id', '=', new_policy_id)]"/>
</group>
<group></group>
</group>
<notebook colspan="4">
<page string="Move lines to affect">
<field name="move_line_ids"/>
</page>
</notebook>
<footer>
<button class="oe_highlight"
name="set_new_policy"
string="Set new policy"
type="object"/>
or
<button class="oe_link"
special="cancel"
string="Cancel"/>
</footer>
</form>
<field name="name">credit control policy form</field>
<field name="model">credit.control.policy.changer</field>
<field name="arch" type="xml">
<form version="7.0" string="Set current credit level">
<separator string="Change the overdue level of current invoice"
colspan="4"/>
<label string="This wizard will let you set the overdue policy and level for selected invoices"/>
<newline/>
<group>
<group>
<field name="new_policy_id"/>
<field name="do_nothing"
invisible="1"/>
<field name="new_policy_level_id"
domain="[('policy_id', '=', new_policy_id)]"/>
</group>
<group></group>
</group>
<notebook colspan="4">
<page string="Move lines to affect">
<field name="move_line_ids"/>
</page>
</notebook>
<footer>
<button class="oe_highlight"
name="set_new_policy"
string="Set new policy"
type="object"/>
or
<button class="oe_link"
special="cancel"
string="Cancel"/>
</footer>
</form>
</field>
</field>
</record>
<!-- for button -->
<record id="action_wizard_credit_policy_changer" model="ir.actions.act_window">
<field name="name">Change current credit policy</field>
<field name="res_model">credit.control.policy.changer</field>
<field name="src_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="credit_control_policy_changer_form"/>
<field name="target">new</field>
<field name="help">Allows to manually change credit level</field>
<record id="action_wizard_credit_policy_changer"
model="ir.actions.act_window">
<field name="name">Change current credit policy</field>
<field name="res_model">credit.control.policy.changer</field>
<field name="src_model">account.invoice</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="credit_control_policy_changer_form"/>
<field name="target">new</field>
<field name="help">Allows to manually change credit level</field>
</record>
<!-- for menu -->
@@ -60,5 +61,4 @@
key2="client_action_multi"
id="action_wizard_credit_policy_changer_menu_action"/>
</data>
</openerp>
</odoo>

View File

@@ -19,7 +19,8 @@
#
##############################################################################
from openerp import models, fields, api, _
from odoo import models, fields, api, _
from odoo.exceptions import Warning
class CreditControlPrinter(models.TransientModel):
@@ -57,7 +58,7 @@ class CreditControlPrinter(models.TransientModel):
self.ensure_one()
comm_obj = self.env['credit.control.communication']
if not self.line_ids:
raise api.Warning(_('No credit control lines selected.'))
raise Warning(_('No credit control lines selected.'))
lines = self._get_lines(self.line_ids, self._credit_line_predicate)

View File

@@ -1,30 +1,30 @@
<openerp>
<data>
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="credit_line_printer_form" model="ir.ui.view">
<field name="name">credit.line.printer.form</field>
<field name="model">credit.control.printer</field>
<field name="arch" type="xml">
<form string="Lines report" version="7.0">
<separator string="Print the selected lines" colspan="4"/>
<newline/>
<group>
<field name="mark_as_sent"
colspan="4"/>
</group>
<newline/>
<notebook>
<page string="Lines">
<field name="line_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
<footer>
<button class="oe_highlight" name="print_lines" string="Print" type="object"/>
or
<button class="oe_link" special="cancel" string="Cancel"/>
</footer>
</form>
</field>
<field name="name">credit.line.printer.form</field>
<field name="model">credit.control.printer</field>
<field name="arch" type="xml">
<form string="Lines report" version="7.0">
<separator string="Print the selected lines" colspan="4"/>
<newline/>
<group>
<field name="mark_as_sent"
colspan="4"/>
</group>
<newline/>
<notebook>
<page string="Lines">
<field name="line_ids" colspan="4" nolabel="1"/>
</page>
</notebook>
<footer>
<button class="oe_highlight" name="print_lines"
string="Print" type="object"/>
or
<button class="oe_link" special="cancel" string="Cancel"/>
</footer>
</form>
</field>
</record>
<!-- for menu -->
@@ -37,15 +37,14 @@
id="open_credit_line_printer_wizard_menu_action"/>
<record id="open_credit_line_printer_wizard" model="ir.actions.act_window">
<field name="name">Print Lines</field>
<field name="res_model">credit.control.printer</field>
<field name="src_model">credit.control.line</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="credit_line_printer_form"/>
<field name="target">new</field>
<field name="help">Print selected lines</field>
<field name="name">Print Lines</field>
<field name="res_model">credit.control.printer</field>
<field name="src_model">credit.control.line</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="credit_line_printer_form"/>
<field name="target">new</field>
<field name="help">Print selected lines</field>
</record>
</data>
</openerp>
</odoo>