Browse Source

Review of OCA Open Items Report PDF

pull/367/head
jcoux 8 years ago
committed by Jordi Ballester
parent
commit
ca438bddb6
  1. 5
      account_financial_report_qweb/__openerp__.py
  2. 4
      account_financial_report_qweb/menuitems.xml
  3. 2
      account_financial_report_qweb/report/__init__.py
  4. 34
      account_financial_report_qweb/report/aged_partner_balance.py
  5. 174
      account_financial_report_qweb/report/open_items.py
  6. 76
      account_financial_report_qweb/report/templates/open_items_report.xml
  7. 12
      account_financial_report_qweb/reports.xml
  8. 3
      account_financial_report_qweb/wizard/__init__.py
  9. 15
      account_financial_report_qweb/wizard/open_items_wizard.py
  10. 16
      account_financial_report_qweb/wizard/open_items_wizard_view.xml

5
account_financial_report_qweb/__openerp__.py

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Author: Damien Crier # Author: Damien Crier
# Author: Julien Coux
# Copyright 2016 Camptocamp SA # Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{ {
@ -22,7 +23,7 @@
'data': [ 'data': [
'wizard/aged_partner_balance_wizard_view.xml', 'wizard/aged_partner_balance_wizard_view.xml',
'wizard/general_ledger_wizard_view.xml', 'wizard/general_ledger_wizard_view.xml',
'wizard/open_invoice_wizard_view.xml',
'wizard/open_items_wizard_view.xml',
'wizard/balance_common_wizard_view.xml', 'wizard/balance_common_wizard_view.xml',
'wizard/partner_balance_wizard_view.xml', 'wizard/partner_balance_wizard_view.xml',
'wizard/trial_balance_wizard_view.xml', 'wizard/trial_balance_wizard_view.xml',
@ -32,7 +33,7 @@
'report/templates/aged_partner_balance.xml', 'report/templates/aged_partner_balance.xml',
'report/templates/general_ledger.xml', 'report/templates/general_ledger.xml',
'report/templates/layouts.xml', 'report/templates/layouts.xml',
'report/templates/open_invoice_report.xml',
'report/templates/open_items_report.xml',
'view/account_view.xml' 'view/account_view.xml'
], ],
'test': [ 'test': [

4
account_financial_report_qweb/menuitems.xml

@ -36,8 +36,8 @@
<menuitem <menuitem
parent="menu_oca_reports" parent="menu_oca_reports"
action='action_open_invoice_wizard'
id='menu_open_invoice_wizard'
action='action_open_items_wizard'
id='menu_open_items_wizard'
/> />
</data> </data>

2
account_financial_report_qweb/report/__init__.py

@ -7,4 +7,4 @@
from . import aged_partner_balance from . import aged_partner_balance
from . import general_ledger from . import general_ledger
from . import general_ledger_xlsx from . import general_ledger_xlsx
from . import open_invoice
from . import open_items

34
account_financial_report_qweb/report/aged_partner_balance.py

@ -19,7 +19,7 @@ class AgedPartnerBalanceReport(models.TransientModel):
filter_partner_ids = fields.Many2many(comodel_name='res.partner') filter_partner_ids = fields.Many2many(comodel_name='res.partner')
show_move_line_details = fields.Boolean() show_move_line_details = fields.Boolean()
open_invoice_id = fields.Many2one(comodel_name='report_open_invoice_qweb')
open_items_id = fields.Many2one(comodel_name='report_open_items_qweb')
account_ids = fields.One2many( account_ids = fields.One2many(
comodel_name='report_aged_partner_balance_qweb_account', comodel_name='report_aged_partner_balance_qweb_account',
@ -168,15 +168,15 @@ class AgedPartnerBalanceReportCompute(models.TransientModel):
@api.model @api.model
def compute_data_for_report(self): def compute_data_for_report(self):
self.ensure_one() self.ensure_one()
model = self.env['report_open_invoice_qweb']
self.open_invoice_id = model.create({
model = self.env['report_open_items_qweb']
self.open_items_id = model.create({
'date_at': self.date_at, 'date_at': self.date_at,
'only_posted_moves': self.only_posted_moves, 'only_posted_moves': self.only_posted_moves,
'company_id': self.company_id.id, 'company_id': self.company_id.id,
'filter_account_ids': [(6, 0, self.filter_account_ids.ids)], 'filter_account_ids': [(6, 0, self.filter_account_ids.ids)],
'filter_partner_ids': [(6, 0, self.filter_partner_ids.ids)], 'filter_partner_ids': [(6, 0, self.filter_partner_ids.ids)],
}) })
self.open_invoice_id.compute_data_for_report()
self.open_items_id.compute_data_for_report()
self.inject_account_values() self.inject_account_values()
self.inject_partner_values() self.inject_partner_values()
@ -207,14 +207,14 @@ SELECT
rao.code, rao.code,
rao.name rao.name
FROM FROM
report_open_invoice_qweb_account rao
report_open_items_qweb_account rao
WHERE WHERE
rao.report_id = %s rao.report_id = %s
""" """
query_inject_account_params = ( query_inject_account_params = (
self.id, self.id,
self.env.uid, self.env.uid,
self.open_invoice_id.id,
self.open_items_id.id,
) )
self.env.cr.execute(query_inject_account, query_inject_account_params) self.env.cr.execute(query_inject_account, query_inject_account_params)
@ -236,9 +236,9 @@ SELECT
rpo.partner_id, rpo.partner_id,
rpo.name rpo.name
FROM FROM
report_open_invoice_qweb_partner rpo
report_open_items_qweb_partner rpo
INNER JOIN INNER JOIN
report_open_invoice_qweb_account rao ON rpo.report_account_id = rao.id
report_open_items_qweb_account rao ON rpo.report_account_id = rao.id
INNER JOIN INNER JOIN
report_aged_partner_balance_qweb_account ra ON rao.code = ra.code report_aged_partner_balance_qweb_account ra ON rao.code = ra.code
WHERE WHERE
@ -247,7 +247,7 @@ AND ra.report_id = %s
""" """
query_inject_partner_params = ( query_inject_partner_params = (
self.env.uid, self.env.uid,
self.open_invoice_id.id,
self.open_items_id.id,
self.id, self.id,
) )
self.env.cr.execute(query_inject_partner, query_inject_partner_params) self.env.cr.execute(query_inject_partner, query_inject_partner_params)
@ -328,11 +328,11 @@ SELECT
) AS older ) AS older
FROM FROM
date_range, date_range,
report_open_invoice_qweb_move_line rlo
report_open_items_qweb_move_line rlo
INNER JOIN INNER JOIN
report_open_invoice_qweb_partner rpo ON rlo.report_partner_id = rpo.id
report_open_items_qweb_partner rpo ON rlo.report_partner_id = rpo.id
INNER JOIN INNER JOIN
report_open_invoice_qweb_account rao ON rpo.report_account_id = rao.id
report_open_items_qweb_account rao ON rpo.report_account_id = rao.id
INNER JOIN INNER JOIN
report_aged_partner_balance_qweb_account ra ON rao.code = ra.code report_aged_partner_balance_qweb_account ra ON rao.code = ra.code
INNER JOIN INNER JOIN
@ -358,7 +358,7 @@ GROUP BY
""" """
query_inject_line_params = (self.date_at,) * 6 query_inject_line_params = (self.date_at,) * 6
query_inject_line_params += ( query_inject_line_params += (
self.open_invoice_id.id,
self.open_items_id.id,
self.id, self.id,
) )
self.env.cr.execute(query_inject_line, query_inject_line_params) self.env.cr.execute(query_inject_line, query_inject_line_params)
@ -439,11 +439,11 @@ SELECT
END AS older END AS older
FROM FROM
date_range, date_range,
report_open_invoice_qweb_move_line rlo
report_open_items_qweb_move_line rlo
INNER JOIN INNER JOIN
report_open_invoice_qweb_partner rpo ON rlo.report_partner_id = rpo.id
report_open_items_qweb_partner rpo ON rlo.report_partner_id = rpo.id
INNER JOIN INNER JOIN
report_open_invoice_qweb_account rao ON rpo.report_account_id = rao.id
report_open_items_qweb_account rao ON rpo.report_account_id = rao.id
INNER JOIN INNER JOIN
report_aged_partner_balance_qweb_account ra ON rao.code = ra.code report_aged_partner_balance_qweb_account ra ON rao.code = ra.code
INNER JOIN INNER JOIN
@ -467,7 +467,7 @@ AND ra.report_id = %s
""" """
query_inject_move_line_params = (self.date_at,) * 6 query_inject_move_line_params = (self.date_at,) * 6
query_inject_move_line_params += ( query_inject_move_line_params += (
self.open_invoice_id.id,
self.open_items_id.id,
self.id, self.id,
) )
self.env.cr.execute(query_inject_move_line, self.env.cr.execute(query_inject_move_line,

174
account_financial_report_qweb/report/open_invoice.py → account_financial_report_qweb/report/open_items.py

@ -5,95 +5,120 @@
from openerp import models, fields, api from openerp import models, fields, api
class OpenInvoiceReport(models.TransientModel):
class OpenItemsReport(models.TransientModel):
""" Here, we just define class fields. """ Here, we just define class fields.
For methods, go more bottom at this file. For methods, go more bottom at this file.
The class hierarchy is :
* OpenItemsReport
** OpenItemsReportAccount
*** OpenItemsReportPartner
**** OpenItemsReportMoveLine
""" """
_name = 'report_open_invoice_qweb'
_name = 'report_open_items_qweb'
# Filters fields, used for data computation
date_at = fields.Date() date_at = fields.Date()
only_posted_moves = fields.Boolean() only_posted_moves = fields.Boolean()
hide_account_balance_at_0 = fields.Boolean() hide_account_balance_at_0 = fields.Boolean()
company_id = fields.Many2one(comodel_name='res.company') company_id = fields.Many2one(comodel_name='res.company')
filter_account_ids = fields.Many2many(comodel_name='account.account') filter_account_ids = fields.Many2many(comodel_name='account.account')
filter_partner_ids = fields.Many2many(comodel_name='res.partner') filter_partner_ids = fields.Many2many(comodel_name='res.partner')
# Flag fields, used for report display
has_second_currency = fields.Boolean() has_second_currency = fields.Boolean()
# Data fields, used to browse report data
account_ids = fields.One2many( account_ids = fields.One2many(
comodel_name='report_open_invoice_qweb_account',
comodel_name='report_open_items_qweb_account',
inverse_name='report_id' inverse_name='report_id'
) )
class OpenInvoiceReportAccount(models.TransientModel):
class OpenItemsReportAccount(models.TransientModel):
_name = 'report_open_invoice_qweb_account'
_name = 'report_open_items_qweb_account'
_order = 'code ASC' _order = 'code ASC'
report_id = fields.Many2one( report_id = fields.Many2one(
comodel_name='report_open_invoice_qweb',
comodel_name='report_open_items_qweb',
ondelete='cascade', ondelete='cascade',
index=True index=True
) )
# Data fields, used to keep link with real object
account_id = fields.Many2one( account_id = fields.Many2one(
'account.account', 'account.account',
index=True index=True
) )
# Data fields, used for report display
code = fields.Char() code = fields.Char()
name = fields.Char() name = fields.Char()
final_amount_residual = fields.Float(digits=(16, 2)) final_amount_residual = fields.Float(digits=(16, 2))
# Data fields, used to browse report data
partner_ids = fields.One2many( partner_ids = fields.One2many(
comodel_name='report_open_invoice_qweb_partner',
comodel_name='report_open_items_qweb_partner',
inverse_name='report_account_id' inverse_name='report_account_id'
) )
class OpenInvoiceReportPartner(models.TransientModel):
class OpenItemsReportPartner(models.TransientModel):
_name = 'report_open_invoice_qweb_partner'
_name = 'report_open_items_qweb_partner'
report_account_id = fields.Many2one( report_account_id = fields.Many2one(
comodel_name='report_open_invoice_qweb_account',
comodel_name='report_open_items_qweb_account',
ondelete='cascade', ondelete='cascade',
index=True index=True
) )
# Data fields, used to keep link with real object
partner_id = fields.Many2one( partner_id = fields.Many2one(
'res.partner', 'res.partner',
index=True index=True
) )
# Data fields, used for report display
name = fields.Char() name = fields.Char()
final_amount_residual = fields.Float(digits=(16, 2)) final_amount_residual = fields.Float(digits=(16, 2))
# Data fields, used to browse report data
move_line_ids = fields.One2many( move_line_ids = fields.One2many(
comodel_name='report_open_invoice_qweb_move_line',
comodel_name='report_open_items_qweb_move_line',
inverse_name='report_partner_id' inverse_name='report_partner_id'
) )
@api.model @api.model
def _generate_order_by(self, order_spec, query): def _generate_order_by(self, order_spec, query):
"""Custom order to display "No partner allocated" at last position."""
return """ return """
ORDER BY ORDER BY
CASE CASE
WHEN "report_open_invoice_qweb_partner"."partner_id" IS NOT NULL
WHEN "report_open_items_qweb_partner"."partner_id" IS NOT NULL
THEN 0 THEN 0
ELSE 1 ELSE 1
END, END,
"report_open_invoice_qweb_partner"."name"
"report_open_items_qweb_partner"."name"
""" """
class OpenInvoiceReportMoveLine(models.TransientModel):
class OpenItemsReportMoveLine(models.TransientModel):
_name = 'report_open_invoice_qweb_move_line'
_name = 'report_open_items_qweb_move_line'
report_partner_id = fields.Many2one( report_partner_id = fields.Many2one(
comodel_name='report_open_invoice_qweb_partner',
comodel_name='report_open_items_qweb_partner',
ondelete='cascade', ondelete='cascade',
index=True index=True
) )
# Data fields, used to keep link with real object
move_line_id = fields.Many2one('account.move.line') move_line_id = fields.Many2one('account.move.line')
# Data fields, used for report display
date = fields.Date() date = fields.Date()
date_due = fields.Date() date_due = fields.Date()
entry = fields.Char() entry = fields.Char()
@ -108,38 +133,43 @@ class OpenInvoiceReportMoveLine(models.TransientModel):
amount_residual_currency = fields.Float(digits=(16, 2)) amount_residual_currency = fields.Float(digits=(16, 2))
class OpenInvoiceReportCompute(models.TransientModel):
class OpenItemsReportCompute(models.TransientModel):
""" Here, we just define methods.
For class fields, go more top at this file.
"""
_inherit = 'report_open_invoice_qweb'
_inherit = 'report_open_items_qweb'
@api.model
@api.multi
def print_report(self): def print_report(self):
self.ensure_one() self.ensure_one()
self.compute_data_for_report() self.compute_data_for_report()
report_name = 'account_financial_report_qweb.report_open_items_qweb'
return { return {
'type': 'ir.actions.report.xml', 'type': 'ir.actions.report.xml',
'report_name':
'account_financial_report_qweb.report_open_invoice_qweb',
'report_name': report_name,
'datas': {'ids': [self.id]}, 'datas': {'ids': [self.id]},
} }
@api.model
@api.multi
def compute_data_for_report(self): def compute_data_for_report(self):
self.ensure_one() self.ensure_one()
self.inject_account_values()
self.inject_partner_values()
self.inject_line_values()
self.inject_line_values(only_empty_partner_line=True)
self.clean_partners_and_accounts()
self.compute_partners_and_accounts_cumul()
# Compute report data
self._inject_account_values()
self._inject_partner_values()
self._inject_line_values()
self._inject_line_values(only_empty_partner_line=True)
self._clean_partners_and_accounts()
self._compute_partners_and_accounts_cumul()
if self.hide_account_balance_at_0: if self.hide_account_balance_at_0:
self.clean_partners_and_accounts(
self._clean_partners_and_accounts(
only_delete_account_balance_at_0=True only_delete_account_balance_at_0=True
) )
self.compute_has_second_currency()
# Compute display flag
self._compute_has_second_currency()
def inject_account_values(self):
def _inject_account_values(self):
"""Inject report values for report_open_items_qweb_account."""
query_inject_account = """ query_inject_account = """
WITH WITH
accounts AS accounts AS
@ -184,7 +214,7 @@ WITH
a.id a.id
) )
INSERT INTO INSERT INTO
report_open_invoice_qweb_account
report_open_items_qweb_account
( (
report_id, report_id,
create_uid, create_uid,
@ -221,7 +251,8 @@ FROM
) )
self.env.cr.execute(query_inject_account, query_inject_account_params) self.env.cr.execute(query_inject_account, query_inject_account_params)
def inject_partner_values(self):
def _inject_partner_values(self):
""" Inject report values for report_open_items_qweb_partner. """
query_inject_partner = """ query_inject_partner = """
WITH WITH
accounts_partners AS accounts_partners AS
@ -242,7 +273,7 @@ WITH
'No partner allocated' 'No partner allocated'
) AS partner_name ) AS partner_name
FROM FROM
report_open_invoice_qweb_account ra
report_open_items_qweb_account ra
INNER JOIN INNER JOIN
account_account a ON ra.account_id = a.id account_account a ON ra.account_id = a.id
INNER JOIN INNER JOIN
@ -274,7 +305,7 @@ WITH
at.include_initial_balance at.include_initial_balance
) )
INSERT INTO INSERT INTO
report_open_invoice_qweb_partner
report_open_items_qweb_partner
( (
report_account_id, report_account_id,
create_uid, create_uid,
@ -304,7 +335,12 @@ FROM
) )
self.env.cr.execute(query_inject_partner, query_inject_partner_params) self.env.cr.execute(query_inject_partner, query_inject_partner_params)
def inject_line_values(self, only_empty_partner_line=False):
def _inject_line_values(self, only_empty_partner_line=False):
""" Inject report values for report_open_items_qweb_move_line.
The "only_empty_partner_line" value is used
to compute data without partner.
"""
query_inject_move_line = """ query_inject_move_line = """
WITH WITH
move_lines_amount AS move_lines_amount AS
@ -328,9 +364,9 @@ WITH
END END
) AS partial_amount_currency ) AS partial_amount_currency
FROM FROM
report_open_invoice_qweb_partner rp
report_open_items_qweb_partner rp
INNER JOIN INNER JOIN
report_open_invoice_qweb_account ra
report_open_items_qweb_account ra
ON rp.report_account_id = ra.id ON rp.report_account_id = ra.id
INNER JOIN INNER JOIN
account_move_line ml account_move_line ml
@ -408,7 +444,7 @@ WITH
amount_currency amount_currency
) )
INSERT INTO INSERT INTO
report_open_invoice_qweb_move_line
report_open_items_qweb_move_line
( (
report_partner_id, report_partner_id,
create_uid, create_uid,
@ -460,9 +496,9 @@ SELECT
ml.amount_currency, ml.amount_currency,
ml2.amount_residual_currency ml2.amount_residual_currency
FROM FROM
report_open_invoice_qweb_partner rp
report_open_items_qweb_partner rp
INNER JOIN INNER JOIN
report_open_invoice_qweb_account ra ON rp.report_account_id = ra.id
report_open_items_qweb_account ra ON rp.report_account_id = ra.id
INNER JOIN INNER JOIN
account_move_line ml ON ra.account_id = ml.account_id account_move_line ml ON ra.account_id = ml.account_id
INNER JOIN INNER JOIN
@ -525,19 +561,22 @@ ORDER BY
self.date_at,) self.date_at,)
) )
def compute_partners_and_accounts_cumul(self):
def _compute_partners_and_accounts_cumul(self):
""" Compute cumulative amount for
report_open_items_qweb_partner and report_open_items_qweb_account.
"""
query_compute_partners_cumul = """ query_compute_partners_cumul = """
UPDATE UPDATE
report_open_invoice_qweb_partner
report_open_items_qweb_partner
SET SET
final_amount_residual = final_amount_residual =
( (
SELECT SELECT
SUM(rml.amount_residual) AS final_amount_residual SUM(rml.amount_residual) AS final_amount_residual
FROM FROM
report_open_invoice_qweb_move_line rml
report_open_items_qweb_move_line rml
WHERE WHERE
rml.report_partner_id = report_open_invoice_qweb_partner.id
rml.report_partner_id = report_open_items_qweb_partner.id
) )
WHERE WHERE
id IN id IN
@ -545,9 +584,9 @@ WHERE
SELECT SELECT
rp.id rp.id
FROM FROM
report_open_invoice_qweb_account ra
report_open_items_qweb_account ra
INNER JOIN INNER JOIN
report_open_invoice_qweb_partner rp
report_open_items_qweb_partner rp
ON ra.id = rp.report_account_id ON ra.id = rp.report_account_id
WHERE WHERE
ra.report_id = %s ra.report_id = %s
@ -558,16 +597,16 @@ WHERE
params_compute_partners_cumul) params_compute_partners_cumul)
query_compute_accounts_cumul = """ query_compute_accounts_cumul = """
UPDATE UPDATE
report_open_invoice_qweb_account
report_open_items_qweb_account
SET SET
final_amount_residual = final_amount_residual =
( (
SELECT SELECT
SUM(rp.final_amount_residual) AS final_amount_residual SUM(rp.final_amount_residual) AS final_amount_residual
FROM FROM
report_open_invoice_qweb_partner rp
report_open_items_qweb_partner rp
WHERE WHERE
rp.report_account_id = report_open_invoice_qweb_account.id
rp.report_account_id = report_open_items_qweb_account.id
) )
WHERE WHERE
report_id = %s report_id = %s
@ -576,23 +615,29 @@ WHERE
self.env.cr.execute(query_compute_accounts_cumul, self.env.cr.execute(query_compute_accounts_cumul,
params_compute_accounts_cumul) params_compute_accounts_cumul)
def clean_partners_and_accounts(self,
def _clean_partners_and_accounts(self,
only_delete_account_balance_at_0=False): only_delete_account_balance_at_0=False):
""" Delete empty data for
report_open_items_qweb_partner and report_open_items_qweb_account.
The "only_delete_account_balance_at_0" value is used
to delete also the data with cumulative amounts at 0.
"""
query_clean_partners = """ query_clean_partners = """
DELETE FROM DELETE FROM
report_open_invoice_qweb_partner
report_open_items_qweb_partner
WHERE WHERE
id IN id IN
( (
SELECT SELECT
DISTINCT rp.id DISTINCT rp.id
FROM FROM
report_open_invoice_qweb_account ra
report_open_items_qweb_account ra
INNER JOIN INNER JOIN
report_open_invoice_qweb_partner rp
report_open_items_qweb_partner rp
ON ra.id = rp.report_account_id ON ra.id = rp.report_account_id
LEFT JOIN LEFT JOIN
report_open_invoice_qweb_move_line rml
report_open_items_qweb_move_line rml
ON rp.id = rml.report_partner_id ON rp.id = rml.report_partner_id
WHERE WHERE
ra.report_id = %s ra.report_id = %s
@ -615,16 +660,16 @@ WHERE
self.env.cr.execute(query_clean_partners, params_clean_partners) self.env.cr.execute(query_clean_partners, params_clean_partners)
query_clean_accounts = """ query_clean_accounts = """
DELETE FROM DELETE FROM
report_open_invoice_qweb_account
report_open_items_qweb_account
WHERE WHERE
id IN id IN
( (
SELECT SELECT
DISTINCT ra.id DISTINCT ra.id
FROM FROM
report_open_invoice_qweb_account ra
report_open_items_qweb_account ra
LEFT JOIN LEFT JOIN
report_open_invoice_qweb_partner rp
report_open_items_qweb_partner rp
ON ra.id = rp.report_account_id ON ra.id = rp.report_account_id
WHERE WHERE
ra.report_id = %s ra.report_id = %s
@ -646,22 +691,23 @@ WHERE
params_clean_accounts = (self.id,) params_clean_accounts = (self.id,)
self.env.cr.execute(query_clean_accounts, params_clean_accounts) self.env.cr.execute(query_clean_accounts, params_clean_accounts)
def compute_has_second_currency(self):
def _compute_has_second_currency(self):
""" Compute "has_second_currency" flag which will used for display."""
query_update_has_second_currency = """ query_update_has_second_currency = """
UPDATE UPDATE
report_open_invoice_qweb
report_open_items_qweb
SET SET
has_second_currency = has_second_currency =
( (
SELECT SELECT
TRUE TRUE
FROM FROM
report_open_invoice_qweb_move_line l
report_open_items_qweb_move_line l
INNER JOIN INNER JOIN
report_open_invoice_qweb_partner p
report_open_items_qweb_partner p
ON l.report_partner_id = p.id ON l.report_partner_id = p.id
INNER JOIN INNER JOIN
report_open_invoice_qweb_account a
report_open_items_qweb_account a
ON p.report_account_id = a.id ON p.report_account_id = a.id
WHERE WHERE
a.report_id = %s a.report_id = %s

76
account_financial_report_qweb/report/templates/open_invoice_report.xml → account_financial_report_qweb/report/templates/open_items_report.xml

@ -1,54 +1,50 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <odoo>
<template id="account_financial_report_qweb.report_open_invoice_qweb">
<template id="account_financial_report_qweb.report_open_items_qweb">
<t t-call="report.html_container"> <t t-call="report.html_container">
<t t-foreach="docs" t-as="o"> <t t-foreach="docs" t-as="o">
<!-- Saved flag fields into variables, used to define columns display -->
<t t-set="has_second_currency" t-value="o.has_second_currency"/> <t t-set="has_second_currency" t-value="o.has_second_currency"/>
<t t-call="account_financial_report_qweb.internal_layout"> <t t-call="account_financial_report_qweb.internal_layout">
<!-- Defines global variables used by internal layout -->
<t t-set="title" t-value='"Open Items Report"'/> <t t-set="title" t-value='"Open Items Report"'/>
<t t-set="company_name" t-value="o.company_id.name"/> <t t-set="company_name" t-value="o.company_id.name"/>
<div class="page"> <div class="page">
<div class="act_as_table data_table" style="width: 1140px !important;">
<div class="act_as_row labels">
<div class="act_as_cell">Date at filter</div>
<div class="act_as_cell">Target moves filter</div>
<div class="act_as_cell">Account balance at 0 filter</div>
</div>
<div class="act_as_row">
<div class="act_as_cell">
<span t-field="o.date_at"/>
</div>
<div class="act_as_cell">
<t t-if="o.only_posted_moves">All posted entries</t>
<t t-if="not o.only_posted_moves">All entries</t>
</div>
<div class="act_as_cell">
<t t-if="o.hide_account_balance_at_0">Hide</t>
<t t-if="not o.hide_account_balance_at_0">Show</t>
</div>
</div>
</div>
<!-- Display filters -->
<t t-call="account_financial_report_qweb.report_open_items_qweb_filters"/>
<t t-foreach="o.account_ids" t-as="account"> <t t-foreach="o.account_ids" t-as="account">
<div class="page_break"> <div class="page_break">
<!-- Display account header -->
<div class="act_as_table list_table" style="margin-top: 10px;"/> <div class="act_as_table list_table" style="margin-top: 10px;"/>
<div class="act_as_caption account_title" style="width: 1141px !important;"> <div class="act_as_caption account_title" style="width: 1141px !important;">
<span t-field="account.code"/> - <span t-field="account.name"/> <span t-field="account.code"/> - <span t-field="account.name"/>
</div> </div>
<!-- Display account partners -->
<t t-foreach="account.partner_ids" t-as="partner"> <t t-foreach="account.partner_ids" t-as="partner">
<div class="page_break"> <div class="page_break">
<!-- Display partner header -->
<div class="act_as_caption account_title"> <div class="act_as_caption account_title">
<span t-field="partner.name"/> <span t-field="partner.name"/>
</div> </div>
<t t-call="account_financial_report_qweb.report_open_invoice_qweb_lines"/>
<t t-call="account_financial_report_qweb.report_open_invoice_qweb_ending_cumul">
<!-- Display partner move lines -->
<t t-call="account_financial_report_qweb.report_open_items_qweb_lines"/>
<!-- Display partner footer -->
<t t-call="account_financial_report_qweb.report_open_items_qweb_ending_cumul">
<t t-set="account_or_partner_object" t-value="partner"/> <t t-set="account_or_partner_object" t-value="partner"/>
<t t-set="type" t-value='"partner_type"'/> <t t-set="type" t-value='"partner_type"'/>
</t> </t>
</div> </div>
</t> </t>
<t t-call="account_financial_report_qweb.report_open_invoice_qweb_ending_cumul">
<!-- Display account footer -->
<t t-call="account_financial_report_qweb.report_open_items_qweb_ending_cumul">
<t t-set="account_or_partner_object" t-value="account"/> <t t-set="account_or_partner_object" t-value="account"/>
<t t-set="type" t-value='"account_type"'/> <t t-set="type" t-value='"account_type"'/>
</t> </t>
@ -60,8 +56,33 @@
</t> </t>
</template> </template>
<template id="account_financial_report_qweb.report_open_invoice_qweb_lines">
<template id="account_financial_report_qweb.report_open_items_qweb_filters">
<div class="act_as_table data_table" style="width: 1140px !important;"> <div class="act_as_table data_table" style="width: 1140px !important;">
<div class="act_as_row labels">
<div class="act_as_cell">Date at filter</div>
<div class="act_as_cell">Target moves filter</div>
<div class="act_as_cell">Account balance at 0 filter</div>
</div>
<div class="act_as_row">
<div class="act_as_cell">
<span t-field="o.date_at"/>
</div>
<div class="act_as_cell">
<t t-if="o.only_posted_moves">All posted entries</t>
<t t-if="not o.only_posted_moves">All entries</t>
</div>
<div class="act_as_cell">
<t t-if="o.hide_account_balance_at_0">Hide</t>
<t t-if="not o.hide_account_balance_at_0">Show</t>
</div>
</div>
</div>
</template>
<template id="account_financial_report_qweb.report_open_items_qweb_lines">
<div class="act_as_table data_table" style="width: 1140px !important;">
<!-- Display table headers for lines -->
<div class="act_as_thead"> <div class="act_as_thead">
<div class="act_as_row labels"> <div class="act_as_row labels">
<!--## date--> <!--## date-->
@ -92,6 +113,8 @@
</t> </t>
</div> </div>
</div> </div>
<!-- Display each lines -->
<t t-foreach="partner.move_line_ids" t-as="line"> <t t-foreach="partner.move_line_ids" t-as="line">
<!-- # lines or centralized lines --> <!-- # lines or centralized lines -->
<div class="act_as_row lines"> <div class="act_as_row lines">
@ -134,7 +157,8 @@
</div> </div>
</template> </template>
<template id="account_financial_report_qweb.report_open_invoice_qweb_ending_cumul">
<template id="account_financial_report_qweb.report_open_items_qweb_ending_cumul">
<!-- Display ending balance line for account or partner -->
<div class="act_as_table list_table" style="width: 1141px !important;"> <div class="act_as_table list_table" style="width: 1141px !important;">
<div class="act_as_row labels" style="font-weight: bold;"> <div class="act_as_row labels" style="font-weight: bold;">
<!--## date--> <!--## date-->

12
account_financial_report_qweb/reports.xml

@ -21,12 +21,12 @@
/> />
<report <report
id="action_report_open_invoice_qweb"
model="report_open_invoice_qweb"
string="Open Invoice"
id="action_report_open_items_qweb"
model="report_open_items_qweb"
string="Open Items"
report_type="qweb-pdf" report_type="qweb-pdf"
name="account_financial_report_qweb.report_open_invoice_qweb"
file="account_financial_report_qweb.report_open_invoice_qweb"
name="account_financial_report_qweb.report_open_items_qweb"
file="account_financial_report_qweb.report_open_items_qweb"
/> />
<report <report
@ -67,7 +67,7 @@
<field name="paperformat_id" ref="report_qweb_paperformat"/> <field name="paperformat_id" ref="report_qweb_paperformat"/>
</record> </record>
<record id="action_report_open_invoice_qweb" model="ir.actions.report.xml">
<record id="action_report_open_items_qweb" model="ir.actions.report.xml">
<field name="paperformat_id" ref="report_qweb_paperformat"/> <field name="paperformat_id" ref="report_qweb_paperformat"/>
</record> </record>

3
account_financial_report_qweb/wizard/__init__.py

@ -1,8 +1,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Author: Damien Crier # Author: Damien Crier
# Author: Julien Coux
# Copyright 2016 Camptocamp SA # Copyright 2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import aged_partner_balance_wizard from . import aged_partner_balance_wizard
from . import balance_common_wizard from . import balance_common_wizard
from . import general_ledger_wizard from . import general_ledger_wizard
from . import open_invoice_wizard
from . import open_items_wizard

15
account_financial_report_qweb/wizard/open_invoice_wizard.py → account_financial_report_qweb/wizard/open_items_wizard.py

@ -8,11 +8,11 @@ from datetime import datetime
from openerp import models, fields, api from openerp import models, fields, api
class OpenInvoiceReportWizard(models.TransientModel):
"""Open invoice report wizard."""
class OpenItemsReportWizard(models.TransientModel):
"""Open items report wizard."""
_name = "open.invoice.report.wizard"
_description = "Open Invoice Report Wizard"
_name = "open.items.report.wizard"
_description = "Open Items Report Wizard"
company_id = fields.Many2one( company_id = fields.Many2one(
comodel_name='res.company', comodel_name='res.company',
@ -69,7 +69,12 @@ class OpenInvoiceReportWizard(models.TransientModel):
@api.multi @api.multi
def button_export_pdf(self): def button_export_pdf(self):
model = self.env['report_open_invoice_qweb']
self.ensure_one()
return self._export()
def _export(self):
"""Default export is PDF."""
model = self.env['report_open_items_qweb']
report = model.create({ report = model.create({
'date_at': self.date_at, 'date_at': self.date_at,
'only_posted_moves': self.target_move == 'posted', 'only_posted_moves': self.target_move == 'posted',

16
account_financial_report_qweb/wizard/open_invoice_wizard_view.xml → account_financial_report_qweb/wizard/open_items_wizard_view.xml

@ -2,10 +2,10 @@
<openerp> <openerp>
<data> <data>
<!-- OPEN INVOICE -->
<record id="open_invoice_wizard" model="ir.ui.view">
<field name="name">Open Invoice</field>
<field name="model">open.invoice.report.wizard</field>
<!-- OPEN ITEMS -->
<record id="open_items_wizard" model="ir.ui.view">
<field name="name">Open Items</field>
<field name="model">open.items.report.wizard</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form> <form>
<group name="main_info"> <group name="main_info">
@ -38,13 +38,13 @@
</field> </field>
</record> </record>
<record id="action_open_invoice_wizard" model="ir.actions.act_window">
<field name="name">Open Invoice</field>
<record id="action_open_items_wizard" model="ir.actions.act_window">
<field name="name">Open Items</field>
<field name="type">ir.actions.act_window</field> <field name="type">ir.actions.act_window</field>
<field name="res_model">open.invoice.report.wizard</field>
<field name="res_model">open.items.report.wizard</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">form</field> <field name="view_mode">form</field>
<field name="view_id" ref="open_invoice_wizard"/>
<field name="view_id" ref="open_items_wizard"/>
<field name="target">new</field> <field name="target">new</field>
</record> </record>
Loading…
Cancel
Save