Merge lp:~r-dawn/openobject-addons/trunk_negative_brackets into lp:openobject-addons

Proposed by Dawn Richardson
Status: Needs review
Proposed branch: lp:~r-dawn/openobject-addons/trunk_negative_brackets
Merge into: lp:openobject-addons
Diff against target: 51 lines (+33/-0)
2 files modified
account/res_config.py (+21/-0)
account/res_config_view.xml (+12/-0)
To merge this branch: bzr merge lp:~r-dawn/openobject-addons/trunk_negative_brackets
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+169326@code.launchpad.net

Description of the change

Adds an extra option in languages to format negative numbers into brackets on accounting reports. This is farily standard accounting functionality. See http://help.openerp.com/question/20849/how-to-display-negative-numbers-in-brackets-on-reports/. The additions leave the option unchecked by default, to avoid changing any existing functionality.

To post a comment you must log in.

Unmerged revisions

8765. By Dawn Richardson

[IMP] Adds in option in languages to display all negative amounts on accounting reports in brackets. Unticked by default to avoid changing existing functionality.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/res_config.py'
2--- account/res_config.py 2013-05-30 10:18:33 +0000
3+++ account/res_config.py 2013-06-14 02:29:31 +0000
4@@ -344,4 +344,25 @@
5 'module_account_accountant': True,
6 }}
7 return {}
8+
9+class lang(osv.osv):
10+ """
11+ Adding an option for displaying negative numbers in brackets
12+ """
13+ _name = "res.lang"
14+ _inherit = "res.lang"
15+ _columns = {
16+ 'negative_brackets': fields.boolean('Display Negatives in Brackets'),
17+ }
18+
19+ def format(self, cr, uid, ids, percent, value, grouping=False, monetary=False, context=None):
20+ """ Format() will return the language-specific output for float values"""
21+ formatted = super(lang,self).format(cr, uid, ids, percent, value, grouping, monetary, context)
22+ this = self.browse(cr, uid, ids)[0]
23+ if this.negative_brackets and (len(formatted) > 0 and formatted[0]=="-"):
24+ # replace negative sign with brackets
25+ formatted = '(' + formatted[1:] + ")"
26+ return formatted
27+
28+lang()
29 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
30
31=== modified file 'account/res_config_view.xml'
32--- account/res_config_view.xml 2013-04-11 10:46:43 +0000
33+++ account/res_config_view.xml 2013-06-14 02:29:31 +0000
34@@ -271,5 +271,17 @@
35 <menuitem id="menu_account_config" name="Invoicing" parent="base.menu_config"
36 sequence="14" action="action_account_config"/>
37
38+ <!-- Extra language settings -->
39+ <record id="res_lang_form" model="ir.ui.view">
40+ <field name="name">res.lang.form</field>
41+ <field name="model">res.lang</field>
42+ <field name="inherit_id" ref="base.res_lang_form"/>
43+ <field name="arch" type="xml">
44+ <field name="translatable" position="after">
45+ <field name="negative_brackets" />
46+ </field>
47+ </field>
48+ </record>
49+
50 </data>
51 </openerp>

Subscribers

People subscribed via source and target branches

to all changes: