Browse Source

[MIG] customer_activity_statement: Migration to 11.0

pull/389/head
hveficent 7 years ago
committed by mreficent
parent
commit
af11a55d80
  1. 11
      customer_activity_statement/README.rst
  2. 4
      customer_activity_statement/__init__.py
  3. 7
      customer_activity_statement/__manifest__.py
  4. 3
      customer_activity_statement/report/__init__.py
  5. 12
      customer_activity_statement/report/customer_activity_statement.py
  6. 5
      customer_activity_statement/static/description/index.html
  7. 3
      customer_activity_statement/tests/__init__.py
  8. 11
      customer_activity_statement/tests/test_customer_activity_statement.py
  9. 14
      customer_activity_statement/views/statement.xml
  10. 3
      customer_activity_statement/wizard/__init__.py
  11. 9
      customer_activity_statement/wizard/customer_activity_statement_wizard.py
  12. 2
      customer_activity_statement/wizard/customer_activity_statement_wizard.xml

11
customer_activity_statement/README.rst

@ -1,4 +1,4 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
@ -21,21 +21,22 @@ Configuration
Users willing to access to this report should have proper Accounting & Finance rights: Users willing to access to this report should have proper Accounting & Finance rights:
#. Go to *Settings / Users* and edit your user to add the corresponding access rights as follows. #. Go to *Settings / Users* and edit your user to add the corresponding access rights as follows.
#. In *Application / Accounting & Finance*, select *Accountant* or *Adviser* options.
#. In *Application / Accounting & Finance*, select *Billing* or *Billing Manager*
#. In *Technical Setting* mark *Show Full Accounting Features* options.
Usage Usage
===== =====
To use this module, you need to: To use this module, you need to:
#. Go to Customers and select one or more
#. Go to Invoicing > Sales > Master Data > Customers and select one or more
#. Press 'Action > Customer Activity Statement' #. Press 'Action > Customer Activity Statement'
#. Indicate if you want to display aging buckets #. Indicate if you want to display aging buckets
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/91/10.0
:target: https://runbot.odoo-community.org/runbot/91/11.0
Bug Tracker Bug Tracker
=========== ===========
@ -51,7 +52,7 @@ Credits
Images Images
------ ------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.png>`_.
Contributors Contributors
------------ ------------

4
customer_activity_statement/__init__.py

@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import report from . import report
from . import wizard from . import wizard
from . import tests

7
customer_activity_statement/__manifest__.py

@ -1,18 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com) # (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{ {
'name': 'Customer Activity Statement', 'name': 'Customer Activity Statement',
'version': '10.0.1.0.0',
'version': '11.0.1.0.0',
'category': 'Accounting & Finance', 'category': 'Accounting & Finance',
'summary': 'OCA Financial Reports', 'summary': 'OCA Financial Reports',
'author': "Eficent, Odoo Community Association (OCA)", 'author': "Eficent, Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/account-financial-reporting', 'website': 'https://github.com/OCA/account-financial-reporting',
'license': 'AGPL-3', 'license': 'AGPL-3',
'depends': [ 'depends': [
'account',
'account_invoicing',
], ],
'data': [ 'data': [
'views/statement.xml', 'views/statement.xml',

3
customer_activity_statement/report/__init__.py

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import customer_activity_statement from . import customer_activity_statement

12
customer_activity_statement/report/customer_activity_statement.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com) # (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
@ -54,6 +53,7 @@ class CustomerActivityStatement(models.AbstractModel):
partners = ', '.join([str(i) for i in partner_ids]) partners = ', '.join([str(i) for i in partner_ids])
date_start = datetime.strptime( date_start = datetime.strptime(
date_start, DEFAULT_SERVER_DATE_FORMAT).date() date_start, DEFAULT_SERVER_DATE_FORMAT).date()
# pylint: disable=E8103
self.env.cr.execute("""WITH Q1 AS (%s), Q2 AS (%s) self.env.cr.execute("""WITH Q1 AS (%s), Q2 AS (%s)
SELECT partner_id, currency_id, balance SELECT partner_id, currency_id, balance
FROM Q2""" % (self._initial_balance_sql_q1(partners, date_start), FROM Q2""" % (self._initial_balance_sql_q1(partners, date_start),
@ -106,6 +106,7 @@ class CustomerActivityStatement(models.AbstractModel):
date_start, DEFAULT_SERVER_DATE_FORMAT).date() date_start, DEFAULT_SERVER_DATE_FORMAT).date()
date_end = datetime.strptime( date_end = datetime.strptime(
date_end, DEFAULT_SERVER_DATE_FORMAT).date() date_end, DEFAULT_SERVER_DATE_FORMAT).date()
# pylint: disable=E8103
self.env.cr.execute("""WITH Q1 AS (%s), Q2 AS (%s) self.env.cr.execute("""WITH Q1 AS (%s), Q2 AS (%s)
SELECT partner_id, move_id, date, date_maturity, name, ref, debit, SELECT partner_id, move_id, date, date_maturity, name, ref, debit,
credit, amount, blocked, currency_id credit, amount, blocked, currency_id
@ -248,6 +249,7 @@ class CustomerActivityStatement(models.AbstractModel):
partners = ', '.join([str(i) for i in partner_ids]) partners = ', '.join([str(i) for i in partner_ids])
date_end = datetime.strptime( date_end = datetime.strptime(
date_end, DEFAULT_SERVER_DATE_FORMAT).date() date_end, DEFAULT_SERVER_DATE_FORMAT).date()
# pylint: disable=E8103
self.env.cr.execute("""WITH Q1 AS (%s), Q2 AS (%s), self.env.cr.execute("""WITH Q1 AS (%s), Q2 AS (%s),
Q3 AS (%s), Q4 AS (%s) Q3 AS (%s), Q4 AS (%s)
SELECT partner_id, currency_id, current, b_1_30, b_30_60, b_60_90, SELECT partner_id, currency_id, current, b_1_30, b_30_60, b_60_90,
@ -271,7 +273,7 @@ class CustomerActivityStatement(models.AbstractModel):
return res return res
@api.multi @api.multi
def render_html(self, docids, data):
def get_report_values(self, docids, data):
company_id = data['company_id'] company_id = data['company_id']
partner_ids = data['partner_ids'] partner_ids = data['partner_ids']
date_start = data['date_start'] date_start = data['date_start']
@ -338,7 +340,7 @@ class CustomerActivityStatement(models.AbstractModel):
buckets_to_display[partner_id][currency] = [] buckets_to_display[partner_id][currency] = []
buckets_to_display[partner_id][currency] = line buckets_to_display[partner_id][currency] = line
docargs = {
return {
'doc_ids': partner_ids, 'doc_ids': partner_ids,
'doc_model': 'res.partner', 'doc_model': 'res.partner',
'docs': self.env['res.partner'].browse(partner_ids), 'docs': self.env['res.partner'].browse(partner_ids),
@ -353,5 +355,3 @@ class CustomerActivityStatement(models.AbstractModel):
'Date_end': date_end_display, 'Date_end': date_end_display,
'Date': today_display, 'Date': today_display,
} }
return self.env['report'].render(
'customer_activity_statement.statement', values=docargs)

5
customer_activity_statement/static/description/index.html

@ -29,7 +29,8 @@ so the customer can review how much is open, due or overdue.</div></p>
<p class="oe_mt32">To configure this module, you need to: <p class="oe_mt32">To configure this module, you need to:
<ul> <ul>
<li>Go to <code>Settings / Users</code> and edit your user to add the corresponding access rights as follows.</li> <li>Go to <code>Settings / Users</code> and edit your user to add the corresponding access rights as follows.</li>
<li>In <code>Application / Accounting & Finance</code>, select <code>Accountant</code> or <code>Adviser</code> options.</li>
<li>In <code>Application / Accounting & Finance</code>, select <code>Billing</code> or <code>Billing Manager</code> options.</li>
<li>In <code>Technical Setting</code> mark <code>Show Full Accounting Features</code> options.</li>
</ul> </ul>
</p> </p>
</div> </div>
@ -44,7 +45,7 @@ so the customer can review how much is open, due or overdue.</div></p>
<div class="oe_span12"> <div class="oe_span12">
<p class="oe_mt32">To use this module, you need to: <p class="oe_mt32">To use this module, you need to:
<ul> <ul>
<li>Go to <code>Customers</code> and select one or more</li>
<li>Go to <code>Invoicing > Sales > Master Data > Customers</code> and select one or more</li>
<li>Press '<code>Action > Customer Activity Statement</code>'</li> <li>Press '<code>Action > Customer Activity Statement</code>'</li>
<li>Indicate if you want to display aging buckets</li> <li>Indicate if you want to display aging buckets</li>
</ul> </ul>

3
customer_activity_statement/tests/__init__.py

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import test_customer_activity_statement from . import test_customer_activity_statement

11
customer_activity_statement/tests/test_customer_activity_statement.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com) # (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
@ -51,7 +50,7 @@ class TestCustomerActivityStatement(TransactionCase):
self.assertDictContainsSubset( self.assertDictContainsSubset(
{ {
'type': 'ir.actions.report.xml',
'type': 'ir.actions.report',
'report_name': self.report_name, 'report_name': self.report_name,
'report_type': 'qweb-pdf', 'report_type': 'qweb-pdf',
}, },
@ -61,8 +60,8 @@ class TestCustomerActivityStatement(TransactionCase):
data = wiz_id._prepare_activity_statement() data = wiz_id._prepare_activity_statement()
docids = data['partner_ids'] docids = data['partner_ids']
report = self.statement_model.render_html(docids, data)
self.assertIsInstance(report, str,
report = self.statement_model.get_report_values(docids, data)
self.assertIsInstance(report, dict,
"There was an error while compiling the report.") "There was an error while compiling the report.")
self.assertIn("<!DOCTYPE html>", report,
self.assertIn("Show_Buckets", report,
"There was an error while compiling the report.") "There was an error while compiling the report.")

14
customer_activity_statement/views/statement.xml

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo> <odoo>
<template id="customer_activity_statement.statement_document"> <template id="customer_activity_statement.statement_document">
<t t-call="report.external_layout">
<t t-call="web.external_layout">
<div class="page"> <div class="page">
<div class="row"> <div class="row">
<div class="col-xs-5 col-xs-offset-7"> <div class="col-xs-5 col-xs-offset-7">
@ -35,14 +37,14 @@
</tr> </tr>
</thead> </thead>
<tr> <tr>
<td style="border-right: 1px solid black;"></td>
<td style="border-right: 1px solid black;"/>
<td style="border-right: 1px solid black;"> <td style="border-right: 1px solid black;">
<span t-esc="Date_start[o.id]"/> <span t-esc="Date_start[o.id]"/>
</td> </td>
<td style="border-right: 1px solid black;"> <td style="border-right: 1px solid black;">
Balance Forward Balance Forward
</td> </td>
<td style="border-right: 1px solid black;"></td>
<td style="border-right: 1px solid black;"/>
<td class="text-right" t-if="currency in Balance_forward[o.id]" style="border-right: 1px solid black;"> <td class="text-right" t-if="currency in Balance_forward[o.id]" style="border-right: 1px solid black;">
<span t-esc="Balance_forward[o.id][currency]" t-esc-options='{"widget": "monetary", "display_currency": "currency"}'/> <span t-esc="Balance_forward[o.id][currency]" t-esc-options='{"widget": "monetary", "display_currency": "currency"}'/>
</td> </td>
@ -101,14 +103,14 @@
</t> </t>
</tr> </tr>
<tr> <tr>
<td style="border-right: 1px solid black;"></td>
<td style="border-right: 1px solid black;"/>
<td style="border-right: 1px solid black;"> <td style="border-right: 1px solid black;">
<span t-esc="Date_end[o.id]"/> <span t-esc="Date_end[o.id]"/>
</td> </td>
<td style="border-right: 1px solid black;"> <td style="border-right: 1px solid black;">
Ending Balance Ending Balance
</td> </td>
<td style="border-right: 1px solid black;"></td>
<td style="border-right: 1px solid black;"/>
<td class="text-right" style="border-right: 1px solid black;"> <td class="text-right" style="border-right: 1px solid black;">
<span t-esc="Amount_Due[o.id][currency]" t-esc-options='{"widget": "monetary", "display_currency": "currency"}'/> <span t-esc="Amount_Due[o.id][currency]" t-esc-options='{"widget": "monetary", "display_currency": "currency"}'/>
</td> </td>
@ -184,7 +186,7 @@
</template> </template>
<template id="statement"> <template id="statement">
<t t-call="report.html_container">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="o"> <t t-foreach="docs" t-as="o">
<t t-if="not (Filter_non_due_partners and (not Lines[o.id]) and (len(doc_ids) > 1))"> <t t-if="not (Filter_non_due_partners and (not Lines[o.id]) and (len(doc_ids) > 1))">
<t t-call="customer_activity_statement.statement_document" t-lang="o.lang"/> <t t-call="customer_activity_statement.statement_document" t-lang="o.lang"/>

3
customer_activity_statement/wizard/__init__.py

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import customer_activity_statement_wizard from . import customer_activity_statement_wizard

9
customer_activity_statement/wizard/customer_activity_statement_wizard.py

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services S.L.
# Copyright 2018 Eficent Business and IT Consulting Services S.L.
# (http://www.eficent.com) # (http://www.eficent.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
@ -51,5 +50,7 @@ class CustomerActivityStatementWizard(models.TransientModel):
def _export(self): def _export(self):
"""Export to PDF.""" """Export to PDF."""
data = self._prepare_activity_statement() data = self._prepare_activity_statement()
return self.env['report'].with_context(landscape=True).get_action(
self, 'customer_activity_statement.statement', data=data)
return self.env.ref(
'customer_activity_statement'
'.action_print_customer_activity_statement').report_action(
self, data=data)

2
customer_activity_statement/wizard/customer_activity_statement_wizard.xml

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2018 Eficent Business and IT Consulting Services S.L.
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo> <odoo>
<!-- wizard action on res.partner --> <!-- wizard action on res.partner -->
<act_window id="customer_activity_statement_wizard_action" <act_window id="customer_activity_statement_wizard_action"

Loading…
Cancel
Save