Merge lp:~s-momin-serpentcs/account-fstr/account-fstr into lp:account-fstr/6.0

Proposed by Serpent Consulting Services
Status: Needs review
Proposed branch: lp:~s-momin-serpentcs/account-fstr/account-fstr
Merge into: lp:account-fstr/6.0
Diff against target: 1151 lines (+1064/-0) (has conflicts)
16 files modified
account_fstr/__init__.py (+26/-0)
account_fstr/__openerp__.py (+49/-0)
account_fstr/account_account.py (+63/-0)
account_fstr/account_account_view.xml (+23/-0)
account_fstr/account_fstr_category.py (+178/-0)
account_fstr/account_fstr_menu.xml (+31/-0)
account_fstr/account_fstr_report.xml (+15/-0)
account_fstr/account_fstr_view.xml (+154/-0)
account_fstr/account_fstr_wizard_view.xml (+42/-0)
account_fstr/reports/__init__.py (+20/-0)
account_fstr/reports/account_fstr_report.py (+171/-0)
account_fstr/reports/account_fstr_report.rml (+134/-0)
account_fstr/reports/sm_kit.py (+10/-0)
account_fstr/security/ir.model.access.csv (+2/-0)
account_fstr/wizard/__init__.py (+20/-0)
account_fstr/wizard/account_fstr_wizard.py (+126/-0)
Conflict adding file account_fstr.  Moved existing file to account_fstr.moved.
To merge this branch: bzr merge lp:~s-momin-serpentcs/account-fstr/account-fstr
Reviewer Review Type Date Requested Status
Enapps Committers Pending
Review via email: mp+153174@code.launchpad.net
To post a comment you must log in.
2. By sirajahmad

[IMP] account_fstr: Added a state field in form view, added a constraints on parent_node field

Unmerged revisions

2. By sirajahmad

[IMP] account_fstr: Added a state field in form view, added a constraints on parent_node field

1. By sirajahmad

[mod]modify module account_fstr from 6.1 to 7.0

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'account_fstr'
=== renamed directory 'account_fstr' => 'account_fstr.moved'
=== added file 'account_fstr/__init__.py'
--- account_fstr/__init__.py 1970-01-01 00:00:00 +0000
+++ account_fstr/__init__.py 2013-04-02 11:54:22 +0000
@@ -0,0 +1,26 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C)
6# 2010 Colin MacMillan - Publicus Solutions Ltd.
7# All Rights Reserved
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as
11# published by the Free Software Foundation, either version 3 of the
12# License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Affero General Public License for more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23import account_fstr_category
24import wizard
25import reports
26import account_account
027
=== added file 'account_fstr/__openerp__.py'
--- account_fstr/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_fstr/__openerp__.py 2013-04-02 11:54:22 +0000
@@ -0,0 +1,49 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C)
6# 2011 Colin MacMillan - Enapps Ltd.
7# All Rights Reserved
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as
11# published by the Free Software Foundation, either version 3 of the
12# License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Affero General Public License for more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23
24{
25 'name' : 'Financial Statement Template reporting module',
26 'version' : '1.1',
27 'depends' : ['base', 'account'],
28 'author' : 'Enapps Ltd.',
29 'description': '''This module provides functionality to create customised financial statements. Examples of a financial statement would be a trial balance, balance sheet, profit and loss, etc. Any report that is produced by organising sets of accounts can be created using this module.
30
31User documentation can be found here - www.publicus-solutions.com/blog/post1
32
33Compatible with OpenERP v. 6.0,6.1 and 7.0
34
35''',
36 'website' : 'http://www.enapps.co.uk/',
37 "category": 'Accounting & Finance',
38 'demo' : [],
39 'data' : [
40 'security/ir.model.access.csv',
41 'account_fstr_wizard_view.xml',
42 'account_fstr_view.xml',
43 'account_fstr_menu.xml',
44 'account_account_view.xml',
45 ],
46 'active': False,
47 'installable': True,
48 'images': ['images/fstr_form.png',],
49}
050
=== added file 'account_fstr/account_account.py'
--- account_fstr/account_account.py 1970-01-01 00:00:00 +0000
+++ account_fstr/account_account.py 2013-04-02 11:54:22 +0000
@@ -0,0 +1,63 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2011 Enapps LTD (<http://www.enapps.co.uk>).
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20from openerp.osv import fields, osv
21from openerp.tools.translate import _
22from openerp import netsvc
23import time
24from openerp.addons.decimal_precision import decimal_precision as dp
25
26class account_account(osv.osv):
27 _name = "account.account"
28 _inherit = "account.account"
29
30 _columns = {
31 'category_ids': fields.many2many('account_fstr.category', 'account_fstr_category_account', 'category_id', 'account_id', 'Categories'),
32 }
33
34 def test_category_list(self, cr, uid, ids, category_ids, context={}):
35 category_ids = category_ids[0][2]
36 warning = {}
37 warning_category_names = []
38 category_pool = self.pool.get('account_fstr.category')
39 for account in self.browse(cr, uid, ids, context=context):
40 progenitors = [ctgry.progenitor_id.id for ctgry in account.category_ids]
41 current_category_ids = [ctgry.id for ctgry in account.category_ids]
42 new_categories = list(set(category_ids) - set(current_category_ids))
43 new_categories_objs = category_pool.browse(cr, uid, new_categories, context=context)
44 if len(new_categories_objs) > len(set([ctgry.progenitor_id.id for ctgry in new_categories_objs])):
45 warning.update({
46 'title': 'Alert',
47 'message': "You cant add one account to more than one category within the same repoting template",
48 })
49 return {'value': {'category_ids': current_category_ids}, 'warning': warning}
50 for category in new_categories_objs:
51 if category.progenitor_id.id in progenitors:
52 warning_category_names.append("%s / %s " % (category.progenitor_id.name, category.name))
53 category_ids.remove(category.id)
54 if warning_category_names:
55 warning.update({
56 'title': 'Alert',
57 'message': "Categories %s already exist for current account" % (", ".join(warning_category_names)),
58 })
59 return {'value': {'category_ids': category_ids}, 'warning': warning}
60
61account_account()
62
63# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
064
=== added file 'account_fstr/account_account_view.xml'
--- account_fstr/account_account_view.xml 1970-01-01 00:00:00 +0000
+++ account_fstr/account_account_view.xml 2013-04-02 11:54:22 +0000
@@ -0,0 +1,23 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="view_account_form" model="ir.ui.view">
6 <field name="name">account.account.form</field>
7 <field name="model">account.account</field>
8 <field name="inherit_id" ref="account.view_account_form" />
9 <field name="arch" type="xml">
10 <xpath expr='//group[@groups="base.group_multi_currency"]'
11 position="after">
12 <group>
13 <field name="category_ids" colspan="6" nolabel="1"
14 domain="[('state', '=', 'normal')]" attrs="{'invisible': [('type', '=', 'view')]}"
15 on_change="test_category_list(category_ids)" />
16 </group>
17
18 </xpath>
19 </field>
20 </record>
21
22 </data>
23</openerp>
024
=== added file 'account_fstr/account_fstr_category.py'
--- account_fstr/account_fstr_category.py 1970-01-01 00:00:00 +0000
+++ account_fstr/account_fstr_category.py 2013-04-02 11:54:22 +0000
@@ -0,0 +1,178 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Copyright (C)
6# 2010 Colin MacMillan - Enapps Ltd.
7# All Rights Reserved
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU Affero General Public License as
11# published by the Free Software Foundation, either version 3 of the
12# License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU Affero General Public License for more details.
18#
19# You should have received a copy of the GNU Affero General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
21#
22##############################################################################
23
24from openerp.osv import fields, osv
25from openerp.addons.decimal_precision import decimal_precision as dp
26from wizard import account_fstr_wizard
27from openerp.tools.translate import _
28
29class account_fstr_category(osv.osv):
30 _name = "account_fstr.category"
31 _description = "Financial Statement template category"
32 _order = "sequence, id"
33
34
35 def __compute(self, cr, uid, ids, field_names, arg=None, context=None,
36 query='', query_params=()):
37 res = {}
38 for category_obj in self.browse(cr, uid, ids, context=context):
39 res.update({category_obj.id: self.__compute_balance_for_caregory(cr, uid, category_obj, context=context)})
40 return res
41
42 def __compute_balance_for_caregory(self, cr, uid, category_obj, context={}):
43 result = 0
44 if category_obj.state == 'normal':
45 for account_obj in category_obj.account_ids:
46 result += account_obj.balance
47 else:
48 for child_category_obj in category_obj.child_id:
49 result += self.__compute_balance_for_caregory(cr, uid, child_category_obj, context=context)
50 return result
51
52 def _get_progenitor_id(self, cr, uid, ids, field_names, arg=None, context={}):
53 res = {}
54 for category_obj in self.browse(cr, uid, ids, context=context):
55 res.update({category_obj.id: self._get_progenitor_id_in_recurse(cr, uid, category_obj, context=context) })
56 return res
57
58 def _get_progenitor_id_in_recurse(self, cr, uid, category_obj, context={}):
59 result = None
60 if not (category_obj.parent_id and category_obj.parent_id.id):
61 result = category_obj.id
62 else:
63 result = self._get_progenitor_id_in_recurse(cr, uid, category_obj.parent_id, context=context)
64 return result
65
66 def _get_childs(self, cr, uid, ids, context={}):
67 return self.search(cr, uid, [('id', 'child_of', ids)], context=context)
68
69 _columns = {
70 'name': fields.char('Category Title name', size=32, required=True, select=True),
71 'digits_round': fields.integer('Digits round', required=True),
72 'company_id': fields.many2one('res.company', 'Company', ondelete='set null'),
73 'name_end': fields.char('Category End/Total name', size=128,),
74 'display_total': fields.boolean('Display End/Total'),
75 'parent_id': fields.many2one('account_fstr.category', 'Parent node', ondelete='cascade', select=True),
76 'sequence': fields.integer('Sequence'),
77 'consolidate_total': fields.boolean('Consolidate total', help="Selecting Consolidate total will print this category total as a single summed figure and will not list out each individual account"),
78 'display_heading': fields.boolean('Display title'),
79 'bold_title': fields.boolean('Bold'),
80 'italic_title': fields.boolean('Italic'),
81 'underline_title': fields.boolean('Unnderline'),
82 'bold_end': fields.boolean('Bold'),
83 'italic_end': fields.boolean('Italic'),
84 'underline_end': fields.boolean('Unnderline'),
85 'inversed_sign': fields.boolean('Inversed sign'),
86 'child_id': fields.one2many('account_fstr.category', 'parent_id', 'Consolidated Children', select=True),
87 'account_ids': fields.many2many('account.account', 'account_fstr_category_account', 'account_id', 'category_id', 'Accounts', select=True),
88 'indent_title': fields.integer('Indent Title, (pt)'),
89 'indent_end': fields.integer('Indent End, (pt)'),
90 'top_spacing_title': fields.integer('Top spacing Title, (pt)'),
91 'top_spacing_end': fields.integer('Top spacing End, (pt)'),
92 'bottom_spacing_title': fields.integer('Bottom spacing Title, (pt)'),
93 'bottom_spacing_end': fields.integer('Bottom spacing End, (pt)'),
94 'state': fields.selection([('view','View'),('root','Root'),('normal','Normal')], 'Type', select=True,),
95 'balance': fields.function(__compute, digits_compute=dp.get_precision('Account'), method=True, string='Balance', store=False, type='float'),
96 'printable': fields.boolean('Printable', help="Select to allow category to display in print list"),
97 'progenitor_id': fields.function(_get_progenitor_id, method=True,
98 string='Root', type='many2one',
99 obj='account_fstr.category',
100 store={ 'account_fstr.category': (_get_childs, ['parent_id'], 1)}, select=True),
101
102
103 }
104
105 _defaults = {
106 'state': 'normal',
107 'indent_title': 10,
108 'indent_end': 10,
109 'top_spacing_title': 0,
110 'digits_round': 0,
111 }
112
113 def _check_recursion(self, cr, uid, ids, context=None):
114 level = 100
115 while len(ids):
116 cr.execute('select distinct parent_id from account_fstr_category where id IN %s',(tuple(ids),))
117 ids = filter(None, map(lambda x:x[0], cr.fetchall()))
118 if not level:
119 return False
120 level -= 1
121 return True
122
123 _constraints = [
124 (_check_recursion, 'Error ! You cannot create recursive.', ['parent_id']),
125 ]
126
127 def print_template(self, cr, uid, ids, context={}):
128 return account_fstr_wizard.account_fstr_wizard.print_template(cr, uid, ids, context={})
129
130
131 def _get_selected_accounts(self, cr, uid, progenitor_id, current_category_id, context={}):
132 result = []
133 category_ids = self.search(cr, uid, [('progenitor_id', '=', progenitor_id)], context=context)
134 for category_obj in self.browse(cr, uid, category_ids, context=context):
135 if category_obj.id != current_category_id:
136 result.extend([category.id for category in category_obj.account_ids])
137 return result
138
139 def test_account_list(self, cr, uid, ids, progenitor_id, account_ids):
140 warning = {}
141 warning_account_names = []
142 current_account_ids = []
143 all_account_ids_for_template = self._get_selected_accounts(cr, uid,
144 progenitor_id,
145 ids)
146 updated_account_ids = account_ids[0][2]
147 for account_obj in self.pool.get('account.account').browse(cr, uid, updated_account_ids):
148 if not (account_obj.id in all_account_ids_for_template):
149 current_account_ids.append(account_obj.id)
150 else:
151 warning_account_names.append(account_obj.name)
152 if warning_account_names:
153 warning.update({
154 'title': 'Alert',
155 'message': "Accounts %s already exist in current template" % (", ".join(warning_account_names)),
156 })
157 return {'value': {'account_ids': current_account_ids,}, 'warning': warning}
158
159 def view_exception_accounts(self, cr, uid, ids, context={}):
160 account_list = self._get_selected_accounts(cr, uid, ids[0], ids, context=context)
161 model_data_pool = self.pool.get('ir.model.data')
162 model_data_ids = model_data_pool.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_account_list')], context=context)
163 resource_id = model_data_pool.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
164 return {
165 'name': "Exception Accounts",
166 'view_mode': 'form',
167 'view_type': 'form',
168 'views': [(resource_id, 'tree'),],
169 'res_model': 'account.account',
170 'type': 'ir.actions.act_window',
171 'nodestroy': True,
172 'domain': [('type', '!=', 'view'), ('id', 'not in', account_list)]
173 }
174
175
176account_fstr_category()
177
178# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0179
=== added file 'account_fstr/account_fstr_menu.xml'
--- account_fstr/account_fstr_menu.xml 1970-01-01 00:00:00 +0000
+++ account_fstr/account_fstr_menu.xml 2013-04-02 11:54:22 +0000
@@ -0,0 +1,31 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <menuitem icon="terp-stock_format-default"
6 id="parent_menu_account_fstr"
7 name="Financial Statement template reporting"
8 parent="account.menu_finance"
9 sequence="10"/>
10
11 <menuitem action="action_account_fstr_category_form"
12 id="menu_account_fstr_category_form"
13 icon="STOCK_PREFERENCES"
14 name="Financial Statement categories form"
15 parent="parent_menu_account_fstr" />
16
17 <menuitem action="action_account_fstr_category_tree"
18 id="menu_account_fstr_category_tree"
19 icon="STOCK_PREFERENCES"
20 name="Financial Statement categories tree"
21 parent="parent_menu_account_fstr" />
22
23 <menuitem action="action_account_fstr_wizard"
24 id="menu_account_fstr_wizard_form"
25 icon="STOCK_PRINT"
26 name="Print/Preview financial statements"
27 parent="parent_menu_account_fstr" />
28
29 </data>
30</openerp>
31
032
=== added file 'account_fstr/account_fstr_report.xml'
--- account_fstr/account_fstr_report.xml 1970-01-01 00:00:00 +0000
+++ account_fstr/account_fstr_report.xml 2013-04-02 11:54:22 +0000
@@ -0,0 +1,15 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <report
5 id="report_account_fstr"
6 string="Aged reval report"
7 model="account_fstr.category"
8 name="account_fstr.report"
9 rml="account_fstr/reports/account_fstr_report.rml"
10 header="True"
11 multi="True"
12 />
13
14 </data>
15</openerp>
016
=== added file 'account_fstr/account_fstr_view.xml'
--- account_fstr/account_fstr_view.xml 1970-01-01 00:00:00 +0000
+++ account_fstr/account_fstr_view.xml 2013-04-02 11:54:22 +0000
@@ -0,0 +1,154 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <!--Category -->
6
7 <record id="view_account_fstr_category_search" model="ir.ui.view">
8 <field name="name">view.account_fstr.category.search</field>
9 <field name="model">account_fstr.category</field>
10 <field name="arch" type="xml">
11 <search string="Search Categories">
12 <group col="10" colspan="4">
13 <field name="name" />
14 <field name="parent_id" />
15 <field name="progenitor_id" select="1" />
16 </group>
17 <group expand="1" string="Group By...">
18 <filter string="Parent" name="fparent" icon="terp-personal"
19 domain="[]" context="{'group_by':'parent_id'}" />
20 <filter string="Temlate" name="ftemplate" icon="terp-personal"
21 domain="[]" context="{'group_by':'progenitor_id'}" />
22 </group>
23 </search>
24 </field>
25 </record>
26
27 <record id="view_account_fstr_category_form" model="ir.ui.view">
28 <field name="name">account_fstr.category.form</field>
29 <field name="model">account_fstr.category</field>
30 <field name="arch" type="xml">
31 <form string="Financial Statement category" version="7.0">
32 <header>
33 <!--<field name="state" widget="statusbar" nolabel="1"
34 statusbar_visible="view,root,normal"
35 statusbar_colors="{&quot;proforma&quot;:&quot;blue&quot;,&quot;proforma2&quot;:&quot;blue&quot;}" /> -->
36 <button icon="gtk-print" string="Print/Preview"
37 name="%(action_account_fstr_wizard)d" type="action" states="normal" />
38 <button icon="gtk-find" string="Exception accounts" name="view_exception_accounts"
39 type="object" states="normal" />
40 </header>
41 <sheet>
42 <notebook>
43 <page string="Configurations">
44 <label string="Category Title name" />
45 <field name="name" colspan="2" style="width: 30em" />
46 <group colspan="2" col="4">
47 <group string="Category Title" colspan="1" col="2">
48 <field name="display_heading" />
49 <field name="bold_title" />
50 <field name="italic_title" />
51 <field name="underline_title" />
52 </group>
53 <group string="Spacing" colspan="1" col="2">
54 <field name="indent_title" />
55 <field name="top_spacing_title" />
56 <field name="bottom_spacing_title" />
57 </group>
58 </group>
59 <label string="Category End/Total name" />
60 <field name="name_end" colspan="2" style="width: 30em" />
61 <group colspan="2" col="4">
62 <group string="Category End/Total" colspan="1" col="2">
63 <field name="display_total" />
64 <field name="bold_end" />
65 <field name="italic_end" />
66 <field name="underline_end" />
67 <field name="consolidate_total" />
68 </group>
69 <group string="Spacing" colspan="1" col="2">
70 <field name="indent_end" />
71 <field name="top_spacing_end" />
72 <field name="bottom_spacing_end" />
73 </group>
74 </group>
75 <separator string="Settings" colspan="4" />
76 <group>
77 <field name="company_id" style="width: 30em" />
78 <field name="parent_id" style="width: 30em" />
79 <field name="state" style="width: 30em" />
80 </group>
81 <group>
82 <field name="progenitor_id" colspan="2" invisible="True" />
83 <field name="digits_round" colspan="2" style="width: 30em" />
84 <field name="sequence" style="width: 10em" />
85 <field name="inversed_sign" colspan="1" />
86 </group>
87 <group colspan="2" string="Print Options">
88 <field name="printable" />
89 </group>
90 </page>
91 <page string="Accounts">
92 <separator colspan="4" />
93 <field name="account_ids" colspan="4"
94 attrs="{'invisible':[('state','!=','normal')]}" domain="[('type', '!=', 'view')]"
95 on_change="test_account_list(progenitor_id, account_ids)"
96 nolabel="1" />
97 </page>
98 </notebook>
99 </sheet>
100 </form>
101 </field>
102 </record>
103
104 <record id="view_account_fstr_category_tree" model="ir.ui.view">
105 <field name="name">account_fstr.category.tree</field>
106 <field name="model">account_fstr.category</field>
107 <field name="field_parent">child_id</field>
108 <field name="arch" type="xml">
109 <tree colors="ForestGreen:state=='root';blue:state=='view'"
110 string="Financial Statement category">
111 <field name="name" select="1" />
112 <field name="company_id" />
113 <field name="name_end" />
114 <field name="balance" />
115 <field name="display_total" />
116 <field name="progenitor_id" select="1" />
117 <field name="parent_id" select="1" />
118 <field name="digits_round" select="1" />
119 <field name="sequence" />
120 <field name="indent_title" />
121 <field name="top_spacing_title" />
122 <field name="consolidate_total" />
123 <field name="display_heading" />
124 <field name="bold_title" />
125 <field name="italic_title" colspan="1" />
126 <field name="underline_title" colspan="1" />
127 <field name="inversed_sign" />
128 <field name="state" />
129 <field name="account_ids" />
130 </tree>
131 </field>
132 </record>
133
134 <record id="action_account_fstr_category_tree" model="ir.actions.act_window">
135 <field name="name">Financial Statement category</field>
136 <field name="type">ir.actions.act_window</field>
137 <field name="res_model">account_fstr.category</field>
138 <field name="view_mode">tree</field>
139 <field name="view_type">tree</field>
140 <field name="view_id" ref="view_account_fstr_category_tree" />
141 <field name="domain">[('parent_id','=',False)]</field>
142 </record>
143
144 <record id="action_account_fstr_category_form" model="ir.actions.act_window">
145 <field name="name">Financial Statement category</field>
146 <field name="type">ir.actions.act_window</field>
147 <field name="res_model">account_fstr.category</field>
148 <field name="view_mode">tree,form</field>
149 <field name="view_type">form</field>
150 <field name="view_id" ref="view_account_fstr_category_tree" />
151 <field name="search_view_id" ref="view_account_fstr_category_search" />
152 </record>
153 </data>
154</openerp>
0155
=== added file 'account_fstr/account_fstr_wizard_view.xml'
--- account_fstr/account_fstr_wizard_view.xml 1970-01-01 00:00:00 +0000
+++ account_fstr/account_fstr_wizard_view.xml 2013-04-02 11:54:22 +0000
@@ -0,0 +1,42 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record id="view_account_fstr_wizard_form" model="ir.ui.view">
5 <field name="name">account_fstr.wizard.form</field>
6 <field name="model">account_fstr.wizard</field>
7 <field name="arch" type="xml">
8 <form string="Account charts">
9 <group colspan="4">
10 <field name="fiscalyear" on_change="onchange_fiscalyear(fiscalyear)" widget="selection"/>
11 <field name="target_move"/>
12 <label align="0.7" colspan="4" string="(If you do not select Fiscal year it will take all open fiscal years)"/>
13 <separator string="Periods" colspan="4"/>
14 <field name="period_from" widget="selection"/>
15 <field name="period_to" widget="selection"/>
16 <separator colspan="4"/>
17 <field name="root_node" domain="[('printable','=','1')]"/>
18 <field name="hide_zero"/>
19 </group>
20 <separator string="" colspan="4"/>
21 <group colspan="4" col="6">
22 <button icon="gtk-cancel" special="cancel" string="Cancel"/>
23 <button icon="terp-gtk-go-back-rtl" string="Preview" name="open_window" type="object"/>
24 <button icon="gtk-print" string="Print" name="print_template" type="object"/>
25 </group>
26 </form>
27 </field>
28 </record>
29
30 <record id="action_account_fstr_wizard" model="ir.actions.act_window">
31 <field name="name">Temlate Print/Preview</field>
32 <field name="view_id" ref="view_account_fstr_wizard_form"/>
33 <field name="view_type">form</field>
34 <field name="view_mode">form</field>
35 <field name="res_model">account_fstr.wizard</field>
36 <field name="target">new</field>
37 </record>
38
39 <report id="account_fstr_report" string="Print Template" model="account_fstr.category" name="account_fstr.report" rml="account_fstr/reports/account_fstr_report.rml"/>
40
41 </data>
42</openerp>
043
=== added directory 'account_fstr/images'
=== added file 'account_fstr/images/fstr_form.png'
1Binary files account_fstr/images/fstr_form.png 1970-01-01 00:00:00 +0000 and account_fstr/images/fstr_form.png 2013-04-02 11:54:22 +0000 differ44Binary files account_fstr/images/fstr_form.png 1970-01-01 00:00:00 +0000 and account_fstr/images/fstr_form.png 2013-04-02 11:54:22 +0000 differ
=== added directory 'account_fstr/reports'
=== added file 'account_fstr/reports/__init__.py'
--- account_fstr/reports/__init__.py 1970-01-01 00:00:00 +0000
+++ account_fstr/reports/__init__.py 2013-04-02 11:54:22 +0000
@@ -0,0 +1,20 @@
1##############################################################################
2#
3# Copyright (C) 2011 Enapps LTD (<http://www.enapps.co.uk>).
4# All Rights Reserved
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20import account_fstr_report
021
=== added file 'account_fstr/reports/account_fstr_report.py'
--- account_fstr/reports/account_fstr_report.py 1970-01-01 00:00:00 +0000
+++ account_fstr/reports/account_fstr_report.py 2013-04-02 11:54:22 +0000
@@ -0,0 +1,171 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2011 Enapps LTD (<http://www.enapps.co.uk>).
5# All Rights Reserved
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22import time
23from openerp.report import report_sxw
24from openerp import pooler
25from account.report.common_report_header import common_report_header
26from sm_kit import groupe_digits
27
28
29class account_fstr_report(report_sxw.rml_parse, common_report_header):
30
31 _name = 'account_fstr.category.report'
32
33 date_end = None
34 root_node_obj = None
35
36 def __init__(self, cr, uid, name, context):
37 super(account_fstr_report, self).__init__(cr, uid, name, context)
38 category_id = context.get('active_id')
39 if context.get('active_model') == 'account_fstr.wizard':
40 category_id = context.get('account_fstr_root_node')[0]
41 self.root_node_obj = pooler.get_pool(cr.dbname).get('account_fstr.category').browse(cr, uid, category_id, context=context)
42 self.category_pool = pooler.get_pool(cr.dbname).get('account_fstr.category')
43 ids = context['active_ids']
44 self.localcontext.update({
45 'time': time,
46 'template_data': self._get_template_data(cr, uid, ids, [], self.root_node_obj, context=context),
47 'date_end': '',
48 'digits_round': '0' * (self.root_node_obj.digits_round - 2)
49 })
50
51 def _get_root_id(self):
52 if self.root_node_obj:
53 return self.root_node_obj
54 else:
55 return None
56
57 def _get_template_data(self, cr, uid, ids, statements, category_id, context={}):
58 category_obj = self.category_pool.browse(cr, uid, category_id, context=context)
59 name = category_obj.name
60 result = [self._get_statement(cr, uid, ids, [], self._get_root_id(), -1, context=context), self._get_root_id().balance]
61 result = self._digits_rounding(cr, uid, ids, result, context=context)
62 return {
63 'name': name,
64 'statements': result,
65 'lang': context['lang'],
66 }
67 def _digits_rounding(self, cr, uid, ids, statements, context={}):
68 digits_round = self.root_node_obj.digits_round
69 statements[1] = self._account_round(statements[1], digits_round)
70 for statement_id in range(len(statements[0])):
71 statements[0][statement_id]['total_amount'] = self._account_round(statements[0][statement_id]['total_amount'], digits_round)
72 return statements
73
74 def _account_round(self, number, digits_round):
75 if number == ' ':
76 return number
77 if number == None:
78 return ' '
79 number = (round(float(number), 2 - digits_round))
80 if digits_round <= 2:
81 format_string = "%%.%if" % (2 - digits_round,)
82 elif digits_round > 2:
83 number = int(number / (10 ** (digits_round - 2)))
84 format_string = "%i"
85 result = groupe_digits(format_string % number)
86 if result == "-0":
87 result = "0"
88 return result
89
90 def _get_statement(self, cr, uid, ids, statements_list, category_obj, parent_indent, context={}):
91 indent = category_obj.indent_title + parent_indent
92 font_name_title = 'Helvetica'
93 font_name_end = 'Helvetica'
94
95 # Category Name - bold/italic
96 if category_obj.bold_title or category_obj.italic_title:
97 font_name_title += '-'
98 if category_obj.bold_title:
99 font_name_title += 'Bold'
100 if category_obj.italic_title:
101 font_name_title += 'Oblique'
102
103 # Category End Name - bold/italic
104 if category_obj.bold_end or category_obj.italic_end:
105 font_name_end += '-'
106 if category_obj.bold_end:
107 font_name_end += 'Bold'
108 if category_obj.italic_end:
109 font_name_end += 'Oblique'
110
111 total_amount = 0
112 internal_statements = []
113
114 if category_obj.state == 'normal':
115 for account_statement_obj in category_obj.account_ids:
116 account_total_amount = account_statement_obj.balance
117
118 # skip iterations where amount = 0 and hide_zero box ticked
119 if 'hide_zero' in context:
120 hide_zero = int(context['hide_zero'])
121 if hide_zero == 1 and account_total_amount == 0.0:
122 continue
123
124 if category_obj.inversed_sign:
125 account_total_amount = -account_total_amount
126 internal_statements.append({
127 'name': "%s\t%s" % (account_statement_obj.code, account_statement_obj.name,),
128 'indent': indent + 10,
129 'top_spacing': None,
130 'bottom_spacing': None,
131 'font_name': 'Helvetica',
132 'underline': False,
133 'total_amount': account_total_amount,
134 })
135 total_amount += account_total_amount
136 internal_statements = sorted(internal_statements, key=lambda statement: statement['name'])
137
138 elif category_obj.state != 'normal':
139 for child_category in sorted(category_obj.child_id, key=lambda child_obj: child_obj.sequence):
140 internal_statements = self._get_statement(cr, uid, ids, internal_statements, child_category, indent, context=context)
141 total_amount = category_obj.balance
142 if category_obj.inversed_sign:
143 total_amount = -total_amount
144 # Categroy Title
145 if category_obj.display_heading:
146 statements_list.append({
147 'name': category_obj.name,
148 'indent': category_obj.indent_title + category_obj.top_spacing_title,
149 'top_spacing': category_obj.top_spacing_title,
150 'bottom_spacing': category_obj.bottom_spacing_title,
151 'font_name': font_name_title,
152 'underline': category_obj.underline_title,
153 'total_amount': total_amount if category_obj.consolidate_total else ' ',
154 })
155 if not category_obj.consolidate_total:
156 statements_list.extend(internal_statements)
157 # Category End Name
158 if category_obj.display_total:
159 statements_list.append({
160 'name': category_obj.name_end,
161 'indent': category_obj.indent_end,
162 'top_spacing': category_obj.top_spacing_end,
163 'bottom_spacing': category_obj.bottom_spacing_end,
164 'font_name': font_name_end,
165 'underline': category_obj.underline_end,
166 'total_amount': total_amount,
167 })
168 return statements_list
169
170report_sxw.report_sxw('report.account_fstr.report', 'account_fstr.category',
171 'addons/account_fstr/reports/account_fstr_report.rml', parser=account_fstr_report, header="True")
0172
=== added file 'account_fstr/reports/account_fstr_report.rml'
--- account_fstr/reports/account_fstr_report.rml 1970-01-01 00:00:00 +0000
+++ account_fstr/reports/account_fstr_report.rml 2013-04-02 11:54:22 +0000
@@ -0,0 +1,134 @@
1<?xml version="1.0"?>
2<document filename="test.pdf">
3 <template pageSize="(595.0,842.0)" title="Account Statements report" author="Publicus Solutions Ltd." allowSplitting="20">
4 <pageTemplate id="first">
5 <frame id="first" x1="42.0" y1="42.0" width="511" height="758"/>
6 </pageTemplate>
7 </template>
8 <stylesheet>
9 <blockTableStyle id="Standard_Outline">
10 <blockAlignment value="LEFT"/>
11 <blockValign value="TOP"/>
12 </blockTableStyle>
13 <blockTableStyle id="Table7">
14 <blockAlignment value="LEFT"/>
15 <blockValign value="TOP"/>
16 <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,0" stop="0,-1"/>
17 <lineStyle kind="LINEAFTER" colorName="#000000" start="0,0" stop="0,-1"/>
18 <lineStyle kind="LINEAFTER" colorName="#000000" start="-1,0" stop="-1,-1"/>
19 <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="-1,0"/>
20 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
21 <lineStyle kind="LINEBEFORE" colorName="#000000" start="0,1" stop="0,-1"/>
22 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/>
23 <lineStyle kind="LINEBEFORE" colorName="#000000" start="1,1" stop="1,-1"/>
24 <lineStyle kind="LINEAFTER" colorName="#000000" start="1,1" stop="1,-1"/>
25 <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/>
26 </blockTableStyle>
27 <blockTableStyle id="Table_title">
28 <blockAlignment value="LEFT"/>
29 <blockValign value="TOP"/>
30 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
31 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="-1,-1"/>
32 </blockTableStyle>
33 <blockTableStyle id="Table_futter">
34 <blockAlignment value="LEFT"/>
35 <blockValign value="TOP"/>
36 <lineStyle kind="LINEABOVE" colorName="#000000" start="0,0" stop="-1,0"/>
37 <lineStyle kind="LINEBELOW" colorName="#000000" start="0,0" stop="-1,0"/>
38 </blockTableStyle>
39 <initialize>
40 <paraStyle name="all" alignment="justify"/>
41 </initialize>
42 <paraStyle name="P1" fontName="Helvetica"/>
43 <paraStyle name="P2" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
44 <paraStyle name="P3" fontName="Helvetica-Bold" fontSize="10.0" leading="13" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
45 <paraStyle name="P4" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
46 <paraStyle name="P4c" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
47 <paraStyle name="P4l" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
48 <paraStyle name="P5" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
49 <paraStyle name="P5l" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
50 <paraStyle name="P5lb" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
51 <paraStyle name="P5rb" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
52 <paraStyle name="P5c" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
53 <paraStyle name="P7" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
54 <paraStyle name="Standard" fontName="Helvetica"/>
55 <paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
56 <paraStyle name="Heading" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="12.0" spaceAfter="6.0"/>
57 <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
58 <paraStyle name="Table Contents" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/>
59 <paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER" spaceBefore="0.0" spaceAfter="6.0"/>
60 <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/>
61 <paraStyle name="Index" fontName="Helvetica"/>
62 <paraStyle name="Footer" fontName="Helvetica"/>
63 <paraStyle name="Horizontal Line" fontName="Helvetica" fontSize="6.0" leading="8" spaceBefore="0.0" spaceAfter="14.0"/>
64 <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
65 <paraStyle name="Heading 9" fontName="Helvetica-Bold" fontSize="75%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/>
66 <paraStyle name="terp_tblheader_General" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="6.0" spaceAfter="6.0"/>
67 <paraStyle name="terp_tblheader_Details" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
68 <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
69 <paraStyle name="terp_default_Bold_8" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
70 <paraStyle name="terp_tblheader_General_Centre" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="6.0" spaceAfter="6.0"/>
71 <paraStyle name="terp_tblheader_General_Right" fontName="Helvetica-Bold" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="6.0" spaceAfter="6.0"/>
72 <paraStyle name="terp_tblheader_Details_Centre" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
73 <paraStyle name="terp_tblheader_Details_Right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
74 <paraStyle name="terp_default_Right_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
75 <paraStyle name="terp_default_Centre_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
76 <paraStyle name="terp_header_Right" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/>
77 <paraStyle name="terp_header_Centre" fontName="Helvetica-Bold" fontSize="12.0" leading="15" alignment="CENTER" spaceBefore="12.0" spaceAfter="6.0"/>
78 <paraStyle name="terp_default_address" fontName="Helvetica" fontSize="10.0" leading="13" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
79 <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
80 <paraStyle name="terp_default_Bold_9" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
81 <paraStyle name="terp_default_Centre_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/>
82 <paraStyle name="terp_default_Right_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/>
83 <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
84 <images/>
85 </stylesheet>
86 <story>
87 <para style="P7"> [[ setLang([[ template_data['lang']) ]] [[ template_data['name'] ]]</para>
88 <blockTable colWidths="255.0,255.0" repeatRows="1">
89 <tr>
90 <td>
91 <para style="P4l">[[ not data['fiscalyear'] and removeParentNode('para')]][[ data['fiscalyear'] ]]</para>
92 </td>
93 <td>
94 <para style="P4">[[ not (data['period_from'] and data['period_to']) and removeParentNode('para')]]Periods: from [[ data['period_from'] ]] to [[ data['period_to'] ]]</para>
95 </td>
96 </tr>
97 </blockTable>
98 <blockTable colWidths="413.0,97.0" repeatRows="1">
99 <tr>
100 <td>
101 <para style="P4l"></para>
102 </td>
103 <td>
104 <para style="P4">[[ user.company_id.currency_id.name ]] [[ digits_round ]]</para>
105 </td>
106 </tr>
107 <tr>
108 <td>
109 <para style="P4">
110 <font face="Helvetica">[[ repeatIn(template_data['statements'][0], 'o') ]]</font>
111 </para>
112 <para style="P5l">
113 [[ setTag('para', 'para', {'spaceBefore': "%s" % (o['top_spacing'],), 'leftIndent': "%s" % (o['indent'],), 'fontName': o['font_name'],}) ]]
114 <u>[[ not (o['underline']) and (setTag('u', 'font', {})) ]] [[ o['name'] ]]</u>
115 </para>
116 <para style="P5l">
117 [[ setTag('para', 'para', {'spaceAfter': "%s" % (o['bottom_spacing'],),}) ]]
118 </para>
119 </td>
120 <td>
121 <para style="P5">
122 [[ setTag('para', 'para', {'leftIndent': "%s" % (o['indent'],), 'fontName': o['font_name'],}) ]]
123 [[ o['total_amount'] ]]
124 </para>
125 <para style="P5l">
126 [[ setTag('para', 'para', {'spaceAfter': "%s" % (o['bottom_spacing'],),}) ]]
127 </para>
128 </td>
129 </tr>
130 </blockTable>
131
132 </story>
133</document>
134
0135
=== added file 'account_fstr/reports/sm_kit.py'
--- account_fstr/reports/sm_kit.py 1970-01-01 00:00:00 +0000
+++ account_fstr/reports/sm_kit.py 2013-04-02 11:54:22 +0000
@@ -0,0 +1,10 @@
1import re
2
3def groupe_digits(digite, separator=','):
4 digite = str(digite)
5 if '.' in digite:
6 re_obj = re.compile(r'(?<=\d)(?=(?:\d\d\d)+\.)')
7 else:
8 re_obj = re.compile(r'(?<=\d)(?=(?:\d\d\d)+$)')
9 result = re_obj.sub(separator, digite)
10 return result
011
=== added directory 'account_fstr/security'
=== added file 'account_fstr/security/ir.model.access.csv'
--- account_fstr/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ account_fstr/security/ir.model.access.csv 2013-04-02 11:54:22 +0000
@@ -0,0 +1,2 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2"access_account_fstr_category","account_fstr.category","model_account_fstr_category","account.group_account_manager",1,1,1,1
03
=== added directory 'account_fstr/wizard'
=== added file 'account_fstr/wizard/__init__.py'
--- account_fstr/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ account_fstr/wizard/__init__.py 2013-04-02 11:54:22 +0000
@@ -0,0 +1,20 @@
1##############################################################################
2#
3# Copyright (C) 2011 Enapps LTD (<http://www.enapps.co.uk>).
4# All Rights Reserved
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20import account_fstr_wizard
021
=== added file 'account_fstr/wizard/account_fstr_wizard.py'
--- account_fstr/wizard/account_fstr_wizard.py 1970-01-01 00:00:00 +0000
+++ account_fstr/wizard/account_fstr_wizard.py 2013-04-02 11:54:22 +0000
@@ -0,0 +1,126 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2011 Enapps LTD (<http://www.enapps.co.uk>).
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU Affero General Public License as
8# published by the Free Software Foundation, either version 3 of the
9# License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU Affero General Public License for more details.
15#
16# You should have received a copy of the GNU Affero General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.
18#
19##############################################################################
20
21from openerp.osv import fields, osv
22
23class account_fstr_wizard(osv.osv_memory):
24
25 _name = 'account_fstr.wizard'
26 _description = "Template Print/Preview"
27 _columns = {
28 'fiscalyear': fields.many2one('account.fiscalyear', \
29 'Fiscal year', \
30 help = 'Keep empty for all open fiscal years'),
31 'period_from': fields.many2one('account.period', 'Start period'),
32 'period_to': fields.many2one('account.period', 'End period'),
33 'target_move': fields.selection([('posted', 'All Posted Entries'),
34 ('all', 'All Entries'),
35 ], 'Target Moves', required = True),
36 'root_node': fields.many2one('account_fstr.category', 'Root node', required=True,),
37 'hide_zero': fields.boolean('Hide accounts with a zero balance'),
38 }
39
40 def default_get(self, cr, uid, fields, context={}):
41 result = super(osv.osv_memory, self).default_get(cr, uid, fields, context=context)
42 result['root_node']= context.get('active_id', None)
43 return result
44
45 def onchange_fiscalyear(self, cr, uid, ids, fiscalyear_id=False, context=None):
46 res = {}
47 res['value'] = {}
48 if fiscalyear_id:
49 start_period = end_period = False
50 cr.execute('''
51 SELECT * FROM (SELECT p.id
52 FROM account_period p
53 LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
54 WHERE f.id = %s
55 ORDER BY p.date_start ASC
56 LIMIT 1) AS period_start
57 UNION
58 SELECT * FROM (SELECT p.id
59 FROM account_period p
60 LEFT JOIN account_fiscalyear f ON (p.fiscalyear_id = f.id)
61 WHERE f.id = %s
62 AND p.date_start < NOW()
63 ORDER BY p.date_stop DESC
64 LIMIT 1) AS period_stop''', (fiscalyear_id, fiscalyear_id))
65 periods = [i[0] for i in cr.fetchall()]
66 if periods and len(periods) > 1:
67 start_period = periods[0]
68 end_period = periods[1]
69 res['value'] = {'period_from': start_period, 'period_to': end_period}
70 return res
71
72 def open_window(self, cr, uid, ids, context=None):
73 """
74 Opens chart of Accounts
75 @param cr: the current row, from the database cursor,
76 @param uid: the current user’s ID for security checks,
77 @param ids: List of account chart’s IDs
78 @return: dictionary of Open account chart window on given fiscalyear and all Entries or posted entries
79 """
80 mod_obj = self.pool.get('ir.model.data')
81 act_obj = self.pool.get('ir.actions.act_window')
82 period_obj = self.pool.get('account.period')
83 fy_obj = self.pool.get('account.fiscalyear')
84 if context is None:
85 context = {}
86 data = self.read(cr, uid, ids, [], context=context)[0]
87 result = mod_obj.get_object_reference(cr, uid, 'account_fstr', 'action_account_fstr_category_tree')
88 id = result and result[1] or False
89 result = act_obj.read(cr, uid, [id], context=context)[0]
90 result['periods'] = []
91 if data['period_from'] and data['period_to']:
92 result['periods'] = period_obj.build_ctx_periods(cr, uid, data['period_from'][0], data['period_to'][0])
93 result['context'] = str({'fiscalyear': data['fiscalyear'][0], 'periods': result['periods'], 'state': data['target_move']})
94 if data['fiscalyear']:
95 result['name'] += ':' + fy_obj.read(cr, uid, [data['fiscalyear'][0]], context=context)[0]['code']
96 result['domain'] = [('id', '=', data['root_node'][0])]
97 return result
98
99 def print_template(self, cr, uid, ids, context={}):
100 period_obj = self.pool.get('account.period')
101 data = self.read(cr, uid, ids, [], context=context)[0]
102 data_obj = self.browse(cr, uid, ids, context=context)[0]
103 datas = {'periods': [], 'ids': ids}
104 if data['period_from'] and data['period_to']:
105 context['periods'] = period_obj.build_ctx_periods(cr, uid, data['period_from'][0], data['period_to'][0])
106 datas['context'] = str({'fiscalyear': data['fiscalyear'], 'periods': datas['periods'], \
107 'state': data['target_move']})
108 datas['period_from'] = data_obj.period_from.name
109 datas['period_to'] = data_obj.period_to.name
110 datas['fiscalyear'] = data_obj.fiscalyear.name
111 context['account_fstr_root_node'] = data['root_node']
112 context['hide_zero'] = data['hide_zero']
113 return {
114 'type': 'ir.actions.report.xml',
115 'report_name': 'account_fstr.report',
116 'datas': datas,
117 'context': context,
118 }
119
120 _defaults = {
121 'target_move': 'posted'
122 }
123
124account_fstr_wizard()
125
126# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Subscribers

People subscribed via source and target branches