[ADD] account/project/wizard : convert account_analytic_cost_ledger_for_journal_report wizard to osv_memory
bzr revid: psi@tinyerp.co.in-20100428071259-gng95v2l2piqc2zb
This commit is contained in:
parent
87a2597fa3
commit
3c26bdadc5
|
@ -96,6 +96,7 @@ module named account_voucherss
|
|||
'project/wizard/account_analytic_cost_ledger_view.xml',
|
||||
'project/wizard/account_analytic_inverted_balance_report.xml',
|
||||
'project/wizard/account_analytic_journal_report_view.xml',
|
||||
'project/wizard/account_analytic_cost_ledger_for_journal_report_view.xml',
|
||||
'product_view.xml',
|
||||
'account_assert_test.xml',
|
||||
'process/statement_process.xml',
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
<report auto="False" id="account_analytic_account_quantity_cost_ledger" menu="False" model="account.analytic.account" name="account.analytic.account.quantity_cost_ledger" rml="account/project/report/quantity_cost_ledger.rml" string="Cost Ledger (Only quantities)"/>
|
||||
|
||||
<wizard id="account_analytic_account_quantity_cost_ledger_report" keyword="client_print_multi" model="account.analytic.account" name="account.analytic.account.quantity_cost_ledger.report" string="Cost Ledger (Only quantities)"/>
|
||||
<!-- <wizard id="account_analytic_account_quantity_cost_ledger_report" keyword="client_print_multi" model="account.analytic.account" name="account.analytic.account.quantity_cost_ledger.report" string="Cost Ledger (Only quantities)"/>-->
|
||||
|
||||
|
||||
<report auto="False" id="account_analytic_account_analytic_check" menu="False" model="account.account" name="account.analytic.account.analytic.check" rml="account/project/report/analytic_check.rml" string="Analytic Check"/>
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import time
|
||||
|
||||
import pooler
|
||||
import time
|
||||
from report import report_sxw
|
||||
|
||||
class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
||||
|
@ -35,7 +35,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
|||
})
|
||||
|
||||
def _lines_g(self, account_id, date1, date2, journals):
|
||||
if not journals or not journals[0][2]:
|
||||
if not journals:
|
||||
self.cr.execute("SELECT sum(aal.unit_amount) AS quantity, \
|
||||
aa.code AS code, aa.name AS name, aa.id AS id \
|
||||
FROM account_account AS aa, account_analytic_line AS aal \
|
||||
|
@ -45,7 +45,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
|||
GROUP BY aa.code, aa.name, aa.id ORDER BY aa.code",
|
||||
(account_id, date1, date2))
|
||||
else:
|
||||
journal_ids = journals[0][2]
|
||||
journal_ids = journals
|
||||
self.cr.execute("SELECT sum(aal.unit_amount) AS quantity, \
|
||||
aa.code AS code, aa.name AS name, aa.id AS id \
|
||||
FROM account_account AS aa, account_analytic_line AS aal \
|
||||
|
@ -59,7 +59,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
|||
return res
|
||||
|
||||
def _lines_a(self, general_account_id, account_id, date1, date2, journals):
|
||||
if not journals or not journals[0][2]:
|
||||
if not journals:
|
||||
self.cr.execute("SELECT aal.name AS name, aal.code AS code, \
|
||||
aal.unit_amount AS quantity, aal.date AS date, \
|
||||
aaj.code AS cj \
|
||||
|
@ -71,7 +71,7 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
|||
ORDER BY aal.date, aaj.code, aal.code",
|
||||
(general_account_id, account_id, date1, date2))
|
||||
else:
|
||||
journal_ids = journals[0][2]
|
||||
journal_ids = journals
|
||||
self.cr.execute("SELECT aal.name AS name, aal.code AS code, \
|
||||
aal.unit_amount AS quantity, aal.date AS date, \
|
||||
aaj.code AS cj \
|
||||
|
@ -86,13 +86,13 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
|||
return res
|
||||
|
||||
def _account_sum_quantity(self, account_id, date1, date2, journals):
|
||||
if not journals or not journals[0][2]:
|
||||
if not journals:
|
||||
self.cr.execute("SELECT sum(unit_amount) \
|
||||
FROM account_analytic_line \
|
||||
WHERE account_id=%s AND date>=%s AND date<=%s",
|
||||
(account_id, date1, date2))
|
||||
else:
|
||||
journal_ids = journals[0][2]
|
||||
journal_ids = journals
|
||||
self.cr.execute("SELECT sum(unit_amount) \
|
||||
FROM account_analytic_line \
|
||||
WHERE account_id = %s AND date >= %s AND date <= %s \
|
||||
|
@ -104,17 +104,17 @@ class account_analytic_quantity_cost_ledger(report_sxw.rml_parse):
|
|||
ids = map(lambda x: x.id, accounts)
|
||||
if not len(ids):
|
||||
return 0.0
|
||||
if not journals or not journals[0][2]:
|
||||
if not journals:
|
||||
self.cr.execute("SELECT sum(unit_amount) \
|
||||
FROM account_analytic_line \
|
||||
WHERE account_id =ANY(%s) AND date>=%s AND date<=%s",
|
||||
(date1, date2,ids,))
|
||||
(ids, date1, date2,))
|
||||
else:
|
||||
journal_ids = journals[0][2]
|
||||
journal_ids = journals
|
||||
self.cr.execute("SELECT sum(unit_amount) \
|
||||
FROM account_analytic_line \
|
||||
WHERE account_id =ANY(%s) AND date >= %s AND date <= %s \
|
||||
AND journal_id =ANY(%s)",(ids,date1, date2,journal_ids))
|
||||
AND journal_id =ANY(%s)",(ids, date1, date2, journal_ids))
|
||||
return self.cr.fetchone()[0] or 0.0
|
||||
|
||||
report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger',
|
||||
|
@ -122,6 +122,4 @@ report_sxw.report_sxw('report.account.analytic.account.quantity_cost_ledger',
|
|||
'addons/account/project/report/quantity_cost_ledger.rml',
|
||||
parser=account_analytic_quantity_cost_ledger, header=False)
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -23,7 +23,7 @@ import account_analytic_journal_report
|
|||
import account_analytic_balance_report
|
||||
import account_analytic_inverted_balance_report
|
||||
import account_analytic_cost_ledger_report
|
||||
import wizard_account_analytic_cost_ledger_for_journal_report
|
||||
import account_analytic_cost_ledger_for_journal_report
|
||||
import account_analytic_check
|
||||
import project_account_analytic_line
|
||||
import wizard_analytic_account_chart
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import time
|
||||
|
||||
from osv import osv, fields
|
||||
|
||||
class account_analytic_cost_ledger_journal_report(osv.osv_memory):
|
||||
_name = 'account.analytic.cost.ledger.journal.report'
|
||||
_description = 'Account Analytic Cost Ledger For Journal Report'
|
||||
|
||||
_columns = {
|
||||
'date1': fields.date('Start of period', required=True),
|
||||
'date2': fields.date('End of period', required=True),
|
||||
'journal': fields.many2many('account.analytic.journal', 'ledger_journal_rel','ledger_id', 'Journal_id','Journals'),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'date1':time.strftime('%Y-01-01'),
|
||||
'date2':time.strftime('%Y-%m-%d')
|
||||
}
|
||||
|
||||
def check_report(self, cr, uid, ids, context=None):
|
||||
datas = {}
|
||||
if context is None:
|
||||
context = {}
|
||||
data = self.read(cr, uid, ids)[0]
|
||||
datas = {
|
||||
'ids': context.get('active_ids',[]),
|
||||
'model': 'account.analytic.account',
|
||||
'form': data
|
||||
}
|
||||
return {
|
||||
'type': 'ir.actions.report.xml',
|
||||
'report_name': 'account.analytic.account.quantity_cost_ledger',
|
||||
'datas': datas,
|
||||
}
|
||||
|
||||
account_analytic_cost_ledger_journal_report()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
#import time
|
||||
#import wizard
|
||||
#
|
||||
#_form = '''<?xml version="1.0"?>
|
||||
#<form string="Select period">
|
||||
# <separator string="Cost Legder for period" colspan="4"/>
|
||||
# <field name="date1"/>
|
||||
# <field name="date2"/>
|
||||
# <separator string="and Journals" colspan="4"/>
|
||||
# <field name="journal" colspan="4"/>
|
||||
#</form>'''
|
||||
#
|
||||
#_fields = {
|
||||
# 'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||
# 'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||
# 'journal': {'string':'Journals','type':'many2many', 'relation':'account.analytic.journal'},
|
||||
#}
|
||||
#
|
||||
#
|
||||
#class wizard_report(wizard.interface):
|
||||
# states = {
|
||||
# 'init': {
|
||||
# 'actions': [],
|
||||
# 'result': {
|
||||
# 'type': 'form',
|
||||
# 'arch': _form,
|
||||
# 'fields': _fields,
|
||||
# 'state': [
|
||||
# ('end','Cancel'),
|
||||
# ('report','Print')
|
||||
# ]
|
||||
# }
|
||||
# },
|
||||
# 'report': {
|
||||
# 'actions': [],
|
||||
# 'result': {
|
||||
# 'type': 'print',
|
||||
# 'report': 'account.analytic.account.quantity_cost_ledger',
|
||||
# 'state': 'end'
|
||||
# }
|
||||
# },
|
||||
# }
|
||||
#
|
||||
#wizard_report('account.analytic.account.quantity_cost_ledger.report')
|
||||
#
|
||||
## vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="account_analytic_cost_ledger_journal_view" model="ir.ui.view">
|
||||
<field name="name">Account Analytic Cost Ledger Journal</field>
|
||||
<field name="model">account.analytic.cost.ledger.journal.report</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Select period">
|
||||
<separator string="Cost Legder for period" colspan="4"/>
|
||||
<field name="date1"/>
|
||||
<field name="date2"/>
|
||||
<separator string="and Journals" colspan="4"/>
|
||||
<field name="journal" colspan="4"/>
|
||||
<separator colspan="4"/>
|
||||
<group colspan="4" col="6">
|
||||
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
|
||||
<button name="check_report" string="Print" type="object" icon="gtk-print"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_account_analytic_cost_ledger_journal" model="ir.actions.act_window">
|
||||
<field name="name">Cost Ledger (Only quantities)</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.analytic.cost.ledger.journal.report</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account_analytic_cost_ledger_journal_view"/>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="account_analytic_cost_ledger_journal_values">
|
||||
<field name="model_id" ref="analytic.model_account_analytic_account" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Account Analytic Cost Ledger Journal</field>
|
||||
<field name="key2">client_print_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_account_analytic_cost_ledger_journal'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">account.analytic.account</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,68 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import time
|
||||
import wizard
|
||||
|
||||
_form = '''<?xml version="1.0"?>
|
||||
<form string="Select period">
|
||||
<separator string="Cost Legder for period" colspan="4"/>
|
||||
<field name="date1"/>
|
||||
<field name="date2"/>
|
||||
<separator string="and Journals" colspan="4"/>
|
||||
<field name="journal" colspan="4"/>
|
||||
</form>'''
|
||||
|
||||
_fields = {
|
||||
'date1': {'string':'Start of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-01-01')},
|
||||
'date2': {'string':'End of period', 'type':'date', 'required':True, 'default': lambda *a: time.strftime('%Y-%m-%d')},
|
||||
'journal': {'string':'Journals','type':'many2many', 'relation':'account.analytic.journal'},
|
||||
}
|
||||
|
||||
|
||||
class wizard_report(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': _form,
|
||||
'fields': _fields,
|
||||
'state': [
|
||||
('end','Cancel'),
|
||||
('report','Print')
|
||||
]
|
||||
}
|
||||
},
|
||||
'report': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type': 'print',
|
||||
'report': 'account.analytic.account.quantity_cost_ledger',
|
||||
'state': 'end'
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
wizard_report('account.analytic.account.quantity_cost_ledger.report')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue