Merge lp:~gkliska/storno-accounting/storno-accounting into lp:storno-accounting

Proposed by Goran Kliska
Status: Needs review
Proposed branch: lp:~gkliska/storno-accounting/storno-accounting
Merge into: lp:storno-accounting
Diff against target: 886 lines (+842/-0)
8 files modified
account_storno/__init__.py (+30/-0)
account_storno/__openerp__.py (+62/-0)
account_storno/account.py (+96/-0)
account_storno/account_invoice_refund.py (+125/-0)
account_storno/account_view.xml (+17/-0)
account_storno/i18n/account_storno.pot (+212/-0)
account_storno/i18n/hr.po (+212/-0)
account_storno/invoice.py (+88/-0)
To merge this branch: bzr merge lp:~gkliska/storno-accounting/storno-accounting
Reviewer Review Type Date Requested Status
Account Core Editors Pending
Review via email: mp+158022@code.launchpad.net

Description of the change

Initial commit to start with.
Known issues/dilemmas:
  - how to control visible/readonly/mandatory/selection_choices for account_journal.posting_policy from (future) res_company.posting_policy. Dummy field.function() or field.related(), but then we will need lot of them?
  - constraint regarding Tax/Base amount maybe belongs to account-constraints project
  - account_invoice_refund really needs refactoring in core IMO, here attempt to be compatible with Akretion account_journal_sale_refund_link module using same account_journal.refund_journal_id fieldname

To post a comment you must log in.
Revision history for this message
Eric Caudal - www.elico-corp.com (elicoidal) wrote :

Hi Goran,
I am not sure about this and take out the database constraints.
Here is what we could do: create a storno check box at account_move_line
level, invisible that would be check any time a "storno" company uses a
journal in "storno mode". we just need to change the SQL constraint to
something similar to "CHECK (((credit+debit>=0) AND NOT storno) OR
(abs(credit+debit)>=0 AND storno))" (Syntax to be confirmed)

In this case no need to implement complex methods and it could be
compatible with both method at the same time.
your thoughts?
Eric CAUDAL

Eric Caudal
/CEO/
--
*Elico Corporation, Shanghai branch
/OpenERP Premium Certified Training Partner/ *
Cell: + 86 186 2136 1670
Office: + 86 21 6211 8017/27/37
Skype: elico.corp
<email address hidden> <mailto:<email address hidden>>
http://www.elico-corp.com

Elico Corp
On 04/10/2013 05:34 PM, Goran Kliska wrote:
> Goran Kliska has proposed merging lp:~gkliska/storno-accounting/storno-accounting into lp:storno-accounting.
>
> Requested reviews:
> Account Core Editors (account-core-editors)
>
> For more details, see:
> https://code.launchpad.net/~gkliska/storno-accounting/storno-accounting/+merge/158022
>
> Initial commit to start with.
> Known issues/dilemmas:
> - how to control visible/readonly/mandatory/selection_choices for account_journal.posting_policy from (future) res_company.posting_policy. Dummy field.function() or field.related(), but then we will need lot of them?
> - constraint regarding Tax/Base amount maybe belongs to account-constraints project
> - account_invoice_refund really needs refactoring in core IMO, here attempt to be compatible with Akretion account_journal_sale_refund_link module using same account_journal.refund_journal_id fieldname
>

Revision history for this message
Goran Kliska (gkliska) wrote :

Hi Eric,
I think OpenERP application constraints are reliable - under transaction control if orm is used.
_check_contra_minus() is not complex - only 5 lines.
Storno check box at account_move_line would be duplication of data - something we tend to avoid.
SQL constraints across tables are not standard SQL.
IMO Application constraint is best option.
Thanks.

Revision history for this message
Eric Caudal - www.elico-corp.com (elicoidal) wrote :

Hi Goran,
Having a constraint at SQL centralizes and secures the control (for
additional modules etc) and maintenance is easier.
Duplication of data in aml would allow to avoid cross table SQL
constraint actually. Besides it would log the storno moves inside the
aml (In case at some point a journal is switched on/off storno)
I am not sure as well about performance impacts: I would say the SQL
constraint tends to be much quicker than Python code.
Eric CAUDAL

Eric Caudal
/CEO/
--
*Elico Corporation, Shanghai branch
/OpenERP Premium Certified Training Partner/ *
Cell: + 86 186 2136 1670
Office: + 86 21 6211 8017/27/37
Skype: elico.corp
<email address hidden> <mailto:<email address hidden>>
http://www.elico-corp.com

Elico Corp
On 04/11/2013 12:14 AM, Goran Kliska wrote:
> Hi Eric,
> I think OpenERP application constraints are reliable - under transaction control if orm is used.
> _check_contra_minus() is not complex - only 5 lines.
> Storno check box at account_move_line would be duplication of data - something we tend to avoid.
> SQL constraints across tables are not standard SQL.
> IMO Application constraint is best option.
> Thanks.

Unmerged revisions

1. By Slobodni programi

Initial commit

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_storno'
2=== added file 'account_storno/__init__.py'
3--- account_storno/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_storno/__init__.py 2013-04-10 09:33:20 +0000
5@@ -0,0 +1,30 @@
6+# -*- encoding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Module: account_storno
11+# Author: Goran Kliska
12+# mail: gkliskaATgmail.com
13+# Copyright (C) 2011- Slobodni programi d.o.o., Zagreb
14+# Contributions:
15+#
16+# This program is free software: you can redistribute it and/or modify
17+# it under the terms of the GNU Affero General Public License as
18+# published by the Free Software Foundation, either version 3 of the
19+# License, or (at your option) any later version.
20+#
21+# This program is distributed in the hope that it will be useful,
22+# but WITHOUT ANY WARRANTY; without even the implied warranty of
23+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24+# GNU Affero General Public License for more details.
25+#
26+# You should have received a copy of the GNU Affero General Public License
27+# along with this program. If not, see <http://www.gnu.org/licenses/>.
28+#
29+##############################################################################
30+
31+import account
32+import invoice
33+import account_invoice_refund
34+
35+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
36\ No newline at end of file
37
38=== added file 'account_storno/__openerp__.py'
39--- account_storno/__openerp__.py 1970-01-01 00:00:00 +0000
40+++ account_storno/__openerp__.py 2013-04-10 09:33:20 +0000
41@@ -0,0 +1,62 @@
42+# -*- encoding: utf-8 -*-
43+##############################################################################
44+#
45+# OpenERP, Open Source Management Solution
46+# Module: account_storno
47+# Author: Goran Kliska
48+# mail: gkliskaATgmail.com
49+# Copyright (C) 2011- Slobodni programi d.o.o., Zagreb
50+# http://www.slobodni-programi.hr
51+# Contributions:
52+#
53+# This program is free software: you can redistribute it and/or modify
54+# it under the terms of the GNU Affero General Public License as
55+# published by the Free Software Foundation, either version 3 of the
56+# License, or (at your option) any later version.
57+#
58+# This program is distributed in the hope that it will be useful,
59+# but WITHOUT ANY WARRANTY; without even the implied warranty of
60+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61+# GNU Affero General Public License for more details.
62+#
63+# You should have received a copy of the GNU Affero General Public License
64+# along with this program. If not, see <http://www.gnu.org/licenses/>.
65+#
66+##############################################################################
67+
68+{
69+ "name" : "Account storno",
70+ "description" : """
71+
72+Author: Goran Kliska @ Slobodni programi d.o.o.
73+ http://www.slobodni-programi.hr
74+Contributions:
75+ Ivan Vađić @ Slobodni programi d.o.o.
76+ Tomislav Bošnjaković @ Storm Computers d.o.o.: Bugs report
77+
78+Description:
79+ Enables Storno Accounting, a business practice commonly used in Eastern European countries.
80+ Adds new field "Posting policy" with values Storno/Contra on the Journal.
81+ For Storno Journals refund invoices are (usually) done in the same journal with negative *(-1) quantities.
82+
83+ Countries where Storno accounting is mandatory or considered as best practice:
84+ Czech Republic, Poland, Romania, Russia, China, Slovakia, Slovenia, Ukraine, Croatia, Bosnia and Herzegovina, Serbia, Romania, ...
85+
86+WARNING:
87+ This module is managing accounting, invoices, and refund wizard.
88+ Other modules are required for stock, voucher, etc. storno posting.
89+
90+""",
91+ "version" : "13.1",
92+ "author" : "Slobodni programi d.o.o.",
93+ "category" : "Localisation/Croatia",
94+ "website": "http://www.slobodni-programi.hr",
95+ 'depends': ['account',],
96+ 'init_xml': [],
97+ 'update_xml': [ 'account_view.xml',],
98+ "demo_xml" : [],
99+ 'test' : [],
100+ "active": False,
101+ "installable": True,
102+}
103+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
104\ No newline at end of file
105
106=== added file 'account_storno/account.py'
107--- account_storno/account.py 1970-01-01 00:00:00 +0000
108+++ account_storno/account.py 2013-04-10 09:33:20 +0000
109@@ -0,0 +1,96 @@
110+# -*- encoding: utf-8 -*-
111+##############################################################################
112+#
113+# OpenERP, Open Source Management Solution
114+# Module: account_storno
115+# Author: Goran Kliska
116+# mail: gkliskaATgmail.com,
117+# Copyright (C) 2011- Slobodni programi d.o.o., Zagreb www.slobodni-programi.hr
118+# Contributions:
119+#
120+# This program is free software: you can redistribute it and/or modify
121+# it under the terms of the GNU Affero General Public License as
122+# published by the Free Software Foundation, either version 3 of the
123+# License, or (at your option) any later version.
124+#
125+# This program is distributed in the hope that it will be useful,
126+# but WITHOUT ANY WARRANTY; without even the implied warranty of
127+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128+# GNU Affero General Public License for more details.
129+#
130+# You should have received a copy of the GNU Affero General Public License
131+# along with this program. If not, see <http://www.gnu.org/licenses/>.
132+#
133+##############################################################################
134+
135+from osv import fields, osv, orm
136+from openerp.tools import float_compare
137+from openerp.tools.translate import _
138+import decimal_precision as dp
139+
140+class account_journal(osv.osv):
141+ _inherit = "account.journal"
142+ _columns = {
143+ 'posting_policy':fields.selection([
144+ ('contra', 'Contra (debit<->credit)'),
145+ ('storno', 'Storno (-)'),
146+ ],
147+ 'Storno or Contra', size=16, required=True,
148+ help="Storno allows minus postings, Refunds are posted on the same joural/account * (-1).\n"
149+ "Contra doesn't allow negative posting. Refunds are posted by swaping credit and debit side."
150+ ),
151+ 'refund_journal_id':fields.many2one('account.journal', 'Refund journal',
152+ help="Journal for refunds/returns from this journal. Leave empty to use same journal for normal and refund/return postings.",
153+ ),
154+ }
155+ _defaults = {'posting_policy': 'storno',
156+ }
157+
158+
159+class account_move_line(osv.osv):
160+ _inherit = "account.move.line"
161+ #Original constraints
162+ #_sql_constraints = [
163+ #('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in accounting entry !'),
164+ #('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in accounting entry !'),
165+ #]
166+ # credit_debit1 is valid constraint. Clear message
167+ # credit_debit2 is replaced with dummy constraint that is always true.
168+
169+ _sql_constraints = [
170+ ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in accounting entry! Either credit or debit must be 0.00.'),
171+ ('credit_debit2', 'CHECK (abs(credit+debit)>=0)', 'Wrong credit or debit value in accounting entry !'),
172+ ]
173+
174+ def _check_contra_minus(self, cr, uid, ids, context=None):
175+ """ This is to restore credit_debit2 check functionality, for contra journals
176+ """
177+ for l in self.browse(cr, uid, ids, context=context):
178+ if l.journal_id.posting_policy == 'contra':
179+ if l.debit + l.credit < 0.0:
180+ return False
181+ return True
182+
183+ def _check_storno_tax(self, cr, uid, ids, context=None):
184+ """For Storno accounting Tax/Base amount is always == (debit + credit)
185+ Still trying to find the case where it is not.
186+ Maybe for contra check is abs(tax_amount) = abs(debit + credit) ???
187+ """
188+ for l in self.browse(cr, uid, ids, context=context):
189+ if l.journal_id.posting_policy == 'storno' and l.tax_code_id:
190+ if float_compare((l.debit + l.credit), l.tax_amount, precision_digits = 2) != 0: #precision_digits=dp.get_precision('Account')[1])
191+ return False
192+ return True
193+
194+ _constraints = [
195+ (_check_contra_minus, _('Negative credit or debit amount is not allowed for "contra" journal policy.'), ['journal_id']),
196+ (_check_storno_tax, _('Invalid tax amount. Tax amount can be 0.00 or equal to (Credit + Debit).'), ['journal_id']),
197+ ]
198+
199+
200+class account_model_line(osv.osv):
201+ _inherit = "account.model.line"
202+ _sql_constraints = [
203+ ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in model! Either credit or debit must be 0.00.'),
204+ ('credit_debit2', 'CHECK (abs(credit+debit)>=0)', 'Wrong credit or debit value in accounting entry !'),
205+ ]
206
207=== added file 'account_storno/account_invoice_refund.py'
208--- account_storno/account_invoice_refund.py 1970-01-01 00:00:00 +0000
209+++ account_storno/account_invoice_refund.py 2013-04-10 09:33:20 +0000
210@@ -0,0 +1,125 @@
211+# -*- encoding: utf-8 -*-
212+##############################################################################
213+#
214+# OpenERP, Open Source Management Solution
215+# Module: account_storno
216+# Author: Goran Kliska
217+# mail: gkliskaATgmail.com
218+# Copyright (C) 2011- Slobodni programi d.o.o., Zagreb
219+# Contributions:
220+#
221+# This program is free software: you can redistribute it and/or modify
222+# it under the terms of the GNU Affero General Public License as
223+# published by the Free Software Foundation, either version 3 of the
224+# License, or (at your option) any later version.
225+#
226+# This program is distributed in the hope that it will be useful,
227+# but WITHOUT ANY WARRANTY; without even the implied warranty of
228+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
229+# GNU Affero General Public License for more details.
230+#
231+# You should have received a copy of the GNU Affero General Public License
232+# along with this program. If not, see <http://www.gnu.org/licenses/>.
233+#
234+##############################################################################
235+import time
236+from osv import fields, osv
237+from tools.translate import _
238+import netsvc
239+
240+class account_invoice(osv.osv):
241+ """Not knowing legal requirements of all storno countries about journals
242+ This version is for Croatia, Bih, Serbia...
243+ Candidate for new module?
244+ """
245+ _inherit = "account.invoice"
246+
247+ def _journal_invoice_type_dict(self):
248+ return {'sale': 'out_invoice', # Customer Invoice
249+ 'purchase': 'in_invoice', # Customer Refund
250+ 'sale_refund': 'out_refund', # Supplier Invoice
251+ 'purchase_refund': 'in_refund', # Supplier Refund
252+ }
253+
254+ def refund(self, cr, uid, ids, date=None, period_id=None, description=None, journal_id=None):
255+ #Where is the context, per invoice method?
256+ #This approach is slow, updating after creating, but maybe better than copy-paste whole method
257+ res = super(account_invoice, self).refund(cr, uid, ids, date=date, period_id=period_id, description=description, journal_id=journal_id)
258+ for invoice in self.pool.get('account.invoice').browse(cr, uid, res):
259+ self.pool.get('account.invoice').write(cr, uid, [invoice.id],
260+ {'type': self._journal_invoice_type_dict()[invoice.journal_id.type] })
261+ if invoice.journal_id.posting_policy == 'storno':
262+ for inv_line in invoice.invoice_line:
263+ self.pool.get('account.invoice.line').write(cr, uid,
264+ [inv_line.id],
265+ {'quantity': inv_line.quantity * (-1) })
266+ for tax_line in invoice.tax_line:
267+ if tax_line.manual or True:
268+ self.pool.get('account.invoice.tax').write(cr, uid,
269+ [tax_line.id],
270+ {'base': tax_line.base * (-1),
271+ 'amount': tax_line.amount * (-1),
272+ 'base_amount': tax_line.base_amount * (-1),
273+ 'tax_amount': tax_line.tax_amount * (-1),
274+ })
275+ return res
276+
277+
278+class account_invoice_refund(osv.osv_memory):
279+ _inherit = "account.invoice.refund"
280+
281+ def _get_journal(self, cr, uid, context=None):
282+ """"in Croatia, for out invoice refunds must go to same journal #TODO for localization
283+ """
284+ #borrowed from Akretion account_journal_sale_refund_link
285+ #compatibility with crm_claim_rma module
286+ invoice_id = context.get('invoice_ids', [context['active_id']])[0]
287+ invoice = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context)
288+ refund_journal_id = invoice.journal_id.refund_journal_id
289+ if refund_journal_id:
290+ return refund_journal_id.id
291+ elif invoice.journal_id.posting_policy == 'storno':
292+ return False #meaning: same journal as original
293+ else:
294+ return super(account_invoice_refund, self)._get_journal(cr, uid, context)
295+
296+ _defaults = {
297+ 'journal_id': _get_journal,
298+ 'filter_refund': 'modify',
299+ }
300+
301+ def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
302+ journal_obj = self.pool.get('account.journal')
303+ user_obj = self.pool.get('res.users')
304+ res = super(account_invoice_refund,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
305+ company_id = user_obj.browse(cr, uid, uid, context=context).company_id.id
306+ #I would love to have invoice.journal_id.posting_policy here
307+ invoice_type = context.get('type', 'all')
308+ if invoice_type in ('out_invoice', 'out_refund'):
309+ journal_types = ('sale','sale_refund')
310+ elif invoice_type in ('in_invoice', 'in_refund'):
311+ journal_types = ('purchase','purchase_refund')
312+ else:
313+ journal_types = ('sale','sale_refund','purchase','purchase_refund')
314+ journal_select = journal_obj._name_search(cr, uid, '', [('type', 'in', journal_types), ('company_id','child_of',[company_id])], context=context)
315+ #original for loop needed???
316+ res['fields']['journal_id']['selection'] = journal_select
317+ return res
318+
319+ def compute_refund(self, cr, uid, ids, mode='refund', context=None):
320+ mod_obj = self.pool.get('ir.model.data')
321+ act_obj = self.pool.get('ir.actions.act_window')
322+ res = super(account_invoice_refund,self).compute_refund(cr, uid, ids, mode=mode, context=context)
323+ last_inv_id = res['domain'][1][2][-1] #yupiii here is last created invoice id, great hook
324+ inv = self.pool.get('account.invoice').browse(cr, uid, [last_inv_id])[0]
325+ xml_id = (inv.type == 'out_refund') and 'action_invoice_tree3' or \
326+ (inv.type == 'in_refund') and 'action_invoice_tree4' or \
327+ (inv.type == 'out_invoice') and 'action_invoice_tree1' or \
328+ (inv.type == 'in_invoice') and 'action_invoice_tree2'
329+ result = mod_obj.get_object_reference(cr, uid, 'account', xml_id)
330+ id = result and result[1] or False
331+ result = act_obj.read(cr, uid, id, context=context)
332+ invoice_domain = eval(result['domain'])
333+ invoice_domain.append(('id', 'in', res['domain'][1][2] ))
334+ result['domain'] = invoice_domain
335+ return result
336
337=== added file 'account_storno/account_view.xml'
338--- account_storno/account_view.xml 1970-01-01 00:00:00 +0000
339+++ account_storno/account_view.xml 2013-04-10 09:33:20 +0000
340@@ -0,0 +1,17 @@
341+<?xml version="1.0" encoding="utf-8"?>
342+<openerp>
343+ <data>
344+ <record id="view_account_journal_form_posting_policy" model="ir.ui.view">
345+ <field name="name">account.journal.form.storno</field>
346+ <field name="model">account.journal</field>
347+ <field name="type">form</field>
348+ <field name="inherit_id" ref="account.view_account_journal_form" />
349+ <field name="arch" type="xml">
350+ <field name="centralisation" position="after">
351+ <field name="posting_policy" groups="account.group_account_manager"/>
352+ <field name="refund_journal_id" groups="account.group_account_manager"/>
353+ </field>
354+ </field>
355+ </record>
356+ </data>
357+</openerp>
358\ No newline at end of file
359
360=== added directory 'account_storno/i18n'
361=== added file 'account_storno/i18n/account_storno.pot'
362--- account_storno/i18n/account_storno.pot 1970-01-01 00:00:00 +0000
363+++ account_storno/i18n/account_storno.pot 2013-04-10 09:33:20 +0000
364@@ -0,0 +1,212 @@
365+# Translation of OpenERP Server.
366+# This file contains the translation of the following modules:
367+# * account_storno
368+#
369+msgid ""
370+msgstr ""
371+"Project-Id-Version: OpenERP Server 6.1beta\n"
372+"Report-Msgid-Bugs-To: \n"
373+"POT-Creation-Date: 2012-01-04 12:30+0000\n"
374+"PO-Revision-Date: 2012-01-04 12:30+0000\n"
375+"Last-Translator: <>\n"
376+"Language-Team: \n"
377+"MIME-Version: 1.0\n"
378+"Content-Type: text/plain; charset=UTF-8\n"
379+"Content-Transfer-Encoding: \n"
380+"Plural-Forms: \n"
381+
382+#. module: account_storno
383+#: code:addons/account_storno/account_invoice_refund.py:212
384+#, python-format
385+msgid "Can not %s draft/proforma/cancel invoice."
386+msgstr "Can not %s draft/proforma/cancel invoice."
387+
388+#. module: account_storno
389+#: constraint:account.move.line:0
390+msgid "Company must be the same for its related account and period."
391+msgstr "Company must be the same for its related account and period."
392+
393+#. module: account_storno
394+#: code:addons/account_storno/invoice.py:45
395+#, python-format
396+msgid "No Invoice Lines !"
397+msgstr "No Invoice Lines !"
398+
399+#. module: account_storno
400+#: sql_constraint:account.journal:0
401+msgid "The name of the journal must be unique per company !"
402+msgstr "The name of the journal must be unique per company !"
403+
404+#. module: account_storno
405+#: code:addons/account_storno/invoice.py:62
406+#, python-format
407+msgid "Bad total !"
408+msgstr "Bad total !"
409+
410+#. module: account_storno
411+#: code:addons/account_storno/invoice.py:73
412+#, python-format
413+msgid "Can not create the invoice !\n"
414+"The related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount."
415+msgstr "Can not create the invoice !\n"
416+"The related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount."
417+
418+#. module: account_storno
419+#: code:addons/account_storno/invoice.py:45
420+#, python-format
421+msgid "Please create some invoice lines."
422+msgstr "Please create some invoice lines."
423+
424+#. module: account_storno
425+#: sql_constraint:account.model.line:0
426+msgid "Wrong credit or debit value in model, they must be positive!"
427+msgstr "Wrong credit or debit value in model, they must be positive!"
428+
429+#. module: account_storno
430+#: code:addons/account_storno/account_invoice_refund.py:212
431+#: code:addons/account_storno/account_invoice_refund.py:214
432+#: code:addons/account_storno/invoice.py:43
433+#: code:addons/account_storno/invoice.py:73
434+#, python-format
435+msgid "Error !"
436+msgstr "Error !"
437+
438+#. module: account_storno
439+#: model:ir.model,name:account_storno.model_account_journal
440+msgid "Journal"
441+msgstr "Journal"
442+
443+#. module: account_storno
444+#: selection:account.journal,posting_policy:0
445+msgid "Contra (debit<->credit)"
446+msgstr "Contra (debit<->credit)"
447+
448+#. module: account_storno
449+#: code:addons/account_storno/invoice.py:43
450+#, python-format
451+msgid "Please define sequence on invoice journal"
452+msgstr "Please define sequence on invoice journal"
453+
454+#. module: account_storno
455+#: field:account.journal,refund_journal_id:0
456+msgid "Invoice refund journal"
457+msgstr "Invoice refund journal"
458+
459+#. module: account_storno
460+#: selection:account.journal,posting_policy:0
461+msgid "Storno (-)"
462+msgstr "Storno (-)"
463+
464+#. module: account_storno
465+#: model:ir.model,name:account_storno.model_account_move_line
466+msgid "Journal Items"
467+msgstr "Journal Items"
468+
469+#. module: account_storno
470+#: constraint:account.move.line:0
471+msgid "You can not create journal items on an account of type view."
472+msgstr "You can not create journal items on an account of type view."
473+
474+#. module: account_storno
475+#: code:addons/account_storno/invoice.py:161
476+#, python-format
477+msgid "You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu."
478+msgstr "You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu."
479+
480+#. module: account_storno
481+#: code:addons/account_storno/account_invoice_refund.py:250
482+#, python-format
483+msgid "No Period found on Invoice!"
484+msgstr "No Period found on Invoice!"
485+
486+#. module: account_storno
487+#: sql_constraint:account.model.line:0
488+msgid "Wrong credit or debit value in model (Credit + Debit Must Be greater \"0\")!"
489+msgstr "Wrong credit or debit value in model (Credit + Debit Must Be greater \"0\")!"
490+
491+#. module: account_storno
492+#: model:ir.model,name:account_storno.model_account_model_line
493+msgid "Account Model Entries"
494+msgstr "Account Model Entries"
495+
496+#. module: account_storno
497+#: constraint:account.move.line:0
498+msgid "You can not create journal items on closed account."
499+msgstr "You can not create journal items on closed account."
500+
501+#. module: account_storno
502+#: constraint:account.journal:0
503+msgid "Configuration error! The currency chosen should be shared by the default accounts too."
504+msgstr "Configuration error! The currency chosen should be shared by the default accounts too."
505+
506+#. module: account_storno
507+#: sql_constraint:account.move.line:0
508+msgid "Wrong credit or debit value in accounting entry !"
509+msgstr "Wrong credit or debit value in accounting entry !"
510+
511+#. module: account_storno
512+#: code:addons/account_storno/invoice.py:160
513+#, python-format
514+msgid "UserError"
515+msgstr "UserError"
516+
517+#. module: account_storno
518+#: sql_constraint:account.invoice:0
519+msgid "Invoice Number must be unique per Company!"
520+msgstr "Invoice Number must be unique per Company!"
521+
522+#. module: account_storno
523+#: code:addons/account_storno/invoice.py:62
524+#, python-format
525+msgid "Please verify the price of the invoice !\n"
526+"The real total does not match the computed total."
527+msgstr "Please verify the price of the invoice !\n"
528+"The real total does not match the computed total."
529+
530+#. module: account_storno
531+#: model:ir.model,name:account_storno.model_account_invoice_refund
532+msgid "Invoice Refund"
533+msgstr "Invoice Refund"
534+
535+#. module: account_storno
536+#: code:addons/account_storno/account_invoice_refund.py:249
537+#, python-format
538+msgid "Data Insufficient !"
539+msgstr "Data Insufficient !"
540+
541+#. module: account_storno
542+#: field:account.journal,posting_policy:0
543+msgid "Storno or Contra"
544+msgstr "Storno or Contra"
545+
546+#. module: account_storno
547+#: constraint:account.move.line:0
548+msgid "The selected account of your Journal Entry forces to provide a secondary currency. You should remove the secondary currency on the account or select a multi-currency view on the journal."
549+msgstr "The selected account of your Journal Entry forces to provide a secondary currency. You should remove the secondary currency on the account or select a multi-currency view on the journal."
550+
551+#. module: account_storno
552+#: constraint:account.move.line:0
553+msgid "The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal."
554+msgstr "The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal."
555+
556+#. module: account_storno
557+#: code:addons/account_storno/account_invoice_refund.py:214
558+#, python-format
559+msgid "Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice"
560+msgstr "Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice"
561+
562+#. module: account_storno
563+#: sql_constraint:account.journal:0
564+msgid "The code of the journal must be unique per company !"
565+msgstr "The code of the journal must be unique per company !"
566+
567+#. module: account_storno
568+#: model:ir.model,name:account_storno.model_account_invoice
569+msgid "Invoice"
570+msgstr "Invoice"
571+
572+#. module: account_storno
573+#: help:account.journal,posting_policy:0
574+msgid "Contra doesn't allow negative posting by swaping credit and debit side. Storno allows minus postings."
575+msgstr "Contra doesn't allow negative posting by swaping credit and debit side. Storno allows minus postings."
576+
577
578=== added file 'account_storno/i18n/hr.po'
579--- account_storno/i18n/hr.po 1970-01-01 00:00:00 +0000
580+++ account_storno/i18n/hr.po 2013-04-10 09:33:20 +0000
581@@ -0,0 +1,212 @@
582+# Translation of OpenERP Server.
583+# This file contains the translation of the following modules:
584+# * account_storno
585+#
586+msgid ""
587+msgstr ""
588+"Project-Id-Version: OpenERP Server 6.1beta\n"
589+"Report-Msgid-Bugs-To: \n"
590+"POT-Creation-Date: 2012-01-04 12:30+0000\n"
591+"PO-Revision-Date: 2012-01-04 12:30+0000\n"
592+"Last-Translator: <>\n"
593+"Language-Team: \n"
594+"MIME-Version: 1.0\n"
595+"Content-Type: text/plain; charset=UTF-8\n"
596+"Content-Transfer-Encoding: \n"
597+"Plural-Forms: \n"
598+
599+#. module: account_storno
600+#: code:addons/account_storno/account_invoice_refund.py:212
601+#, python-format
602+msgid "Can not %s draft/proforma/cancel invoice."
603+msgstr "Can not %s draft/proforma/cancel invoice."
604+
605+#. module: account_storno
606+#: constraint:account.move.line:0
607+msgid "Company must be the same for its related account and period."
608+msgstr "Company must be the same for its related account and period."
609+
610+#. module: account_storno
611+#: code:addons/account_storno/invoice.py:45
612+#, python-format
613+msgid "No Invoice Lines !"
614+msgstr "No Invoice Lines !"
615+
616+#. module: account_storno
617+#: sql_constraint:account.journal:0
618+msgid "The name of the journal must be unique per company !"
619+msgstr "The name of the journal must be unique per company !"
620+
621+#. module: account_storno
622+#: code:addons/account_storno/invoice.py:62
623+#, python-format
624+msgid "Bad total !"
625+msgstr "Bad total !"
626+
627+#. module: account_storno
628+#: code:addons/account_storno/invoice.py:73
629+#, python-format
630+msgid "Can not create the invoice !\n"
631+"The related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount."
632+msgstr "Can not create the invoice !\n"
633+"The related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount."
634+
635+#. module: account_storno
636+#: code:addons/account_storno/invoice.py:45
637+#, python-format
638+msgid "Please create some invoice lines."
639+msgstr "Please create some invoice lines."
640+
641+#. module: account_storno
642+#: sql_constraint:account.model.line:0
643+msgid "Wrong credit or debit value in model, they must be positive!"
644+msgstr "Wrong credit or debit value in model, they must be positive!"
645+
646+#. module: account_storno
647+#: code:addons/account_storno/account_invoice_refund.py:212
648+#: code:addons/account_storno/account_invoice_refund.py:214
649+#: code:addons/account_storno/invoice.py:43
650+#: code:addons/account_storno/invoice.py:73
651+#, python-format
652+msgid "Error !"
653+msgstr "Error !"
654+
655+#. module: account_storno
656+#: model:ir.model,name:account_storno.model_account_journal
657+msgid "Journal"
658+msgstr "Journal"
659+
660+#. module: account_storno
661+#: selection:account.journal,posting_policy:0
662+msgid "Contra (debit<->credit)"
663+msgstr "Contra (debit<->credit)"
664+
665+#. module: account_storno
666+#: code:addons/account_storno/invoice.py:43
667+#, python-format
668+msgid "Please define sequence on invoice journal"
669+msgstr "Please define sequence on invoice journal"
670+
671+#. module: account_storno
672+#: field:account.journal,refund_journal_id:0
673+msgid "Invoice refund journal"
674+msgstr "Invoice refund journal"
675+
676+#. module: account_storno
677+#: selection:account.journal,posting_policy:0
678+msgid "Storno (-)"
679+msgstr "Storno (-)"
680+
681+#. module: account_storno
682+#: model:ir.model,name:account_storno.model_account_move_line
683+msgid "Journal Items"
684+msgstr "Journal Items"
685+
686+#. module: account_storno
687+#: constraint:account.move.line:0
688+msgid "You can not create journal items on an account of type view."
689+msgstr "You can not create journal items on an account of type view."
690+
691+#. module: account_storno
692+#: code:addons/account_storno/invoice.py:161
693+#, python-format
694+msgid "You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu."
695+msgstr "You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu."
696+
697+#. module: account_storno
698+#: code:addons/account_storno/account_invoice_refund.py:250
699+#, python-format
700+msgid "No Period found on Invoice!"
701+msgstr "No Period found on Invoice!"
702+
703+#. module: account_storno
704+#: sql_constraint:account.model.line:0
705+msgid "Wrong credit or debit value in model (Credit + Debit Must Be greater \"0\")!"
706+msgstr "Wrong credit or debit value in model (Credit + Debit Must Be greater \"0\")!"
707+
708+#. module: account_storno
709+#: model:ir.model,name:account_storno.model_account_model_line
710+msgid "Account Model Entries"
711+msgstr "Account Model Entries"
712+
713+#. module: account_storno
714+#: constraint:account.move.line:0
715+msgid "You can not create journal items on closed account."
716+msgstr "You can not create journal items on closed account."
717+
718+#. module: account_storno
719+#: constraint:account.journal:0
720+msgid "Configuration error! The currency chosen should be shared by the default accounts too."
721+msgstr "Configuration error! The currency chosen should be shared by the default accounts too."
722+
723+#. module: account_storno
724+#: sql_constraint:account.move.line:0
725+msgid "Wrong credit or debit value in accounting entry !"
726+msgstr "Wrong credit or debit value in accounting entry !"
727+
728+#. module: account_storno
729+#: code:addons/account_storno/invoice.py:160
730+#, python-format
731+msgid "UserError"
732+msgstr "UserError"
733+
734+#. module: account_storno
735+#: sql_constraint:account.invoice:0
736+msgid "Invoice Number must be unique per Company!"
737+msgstr "Invoice Number must be unique per Company!"
738+
739+#. module: account_storno
740+#: code:addons/account_storno/invoice.py:62
741+#, python-format
742+msgid "Please verify the price of the invoice !\n"
743+"The real total does not match the computed total."
744+msgstr "Please verify the price of the invoice !\n"
745+"The real total does not match the computed total."
746+
747+#. module: account_storno
748+#: model:ir.model,name:account_storno.model_account_invoice_refund
749+msgid "Invoice Refund"
750+msgstr "Invoice Refund"
751+
752+#. module: account_storno
753+#: code:addons/account_storno/account_invoice_refund.py:249
754+#, python-format
755+msgid "Data Insufficient !"
756+msgstr "Data Insufficient !"
757+
758+#. module: account_storno
759+#: field:account.journal,posting_policy:0
760+msgid "Storno or Contra"
761+msgstr "Storno or Contra"
762+
763+#. module: account_storno
764+#: constraint:account.move.line:0
765+msgid "The selected account of your Journal Entry forces to provide a secondary currency. You should remove the secondary currency on the account or select a multi-currency view on the journal."
766+msgstr "The selected account of your Journal Entry forces to provide a secondary currency. You should remove the secondary currency on the account or select a multi-currency view on the journal."
767+
768+#. module: account_storno
769+#: constraint:account.move.line:0
770+msgid "The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal."
771+msgstr "The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal."
772+
773+#. module: account_storno
774+#: code:addons/account_storno/account_invoice_refund.py:214
775+#, python-format
776+msgid "Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice"
777+msgstr "Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice"
778+
779+#. module: account_storno
780+#: sql_constraint:account.journal:0
781+msgid "The code of the journal must be unique per company !"
782+msgstr "The code of the journal must be unique per company !"
783+
784+#. module: account_storno
785+#: model:ir.model,name:account_storno.model_account_invoice
786+msgid "Invoice"
787+msgstr "Invoice"
788+
789+#. module: account_storno
790+#: help:account.journal,posting_policy:0
791+msgid "Contra doesn't allow negative posting by swaping credit and debit side. Storno allows minus postings."
792+msgstr "Contra doesn't allow negative posting by swaping credit and debit side. Storno allows minus postings."
793+
794
795=== added file 'account_storno/invoice.py'
796--- account_storno/invoice.py 1970-01-01 00:00:00 +0000
797+++ account_storno/invoice.py 2013-04-10 09:33:20 +0000
798@@ -0,0 +1,88 @@
799+# -*- encoding: utf-8 -*-
800+##############################################################################
801+#
802+# OpenERP, Open Source Management Solution
803+# Module: account_storno
804+# Author: Goran Kliska
805+# mail: gkliskaATgmail.com
806+# Copyright (C) 2013- Slobodni programi d.o.o., Zagreb
807+# Contributions:
808+#
809+# This program is free software: you can redistribute it and/or modify
810+# it under the terms of the GNU Affero General Public License as
811+# published by the Free Software Foundation, either version 3 of the
812+# License, or (at your option) any later version.
813+#
814+# This program is distributed in the hope that it will be useful,
815+# but WITHOUT ANY WARRANTY; without even the implied warranty of
816+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
817+# GNU Affero General Public License for more details.
818+#
819+# You should have received a copy of the GNU Affero General Public License
820+# along with this program. If not, see <http://www.gnu.org/licenses/>.
821+#
822+##############################################################################
823+
824+from osv import fields, osv, orm
825+import time
826+from tools.translate import _
827+
828+class account_invoice(osv.osv):
829+ _inherit = "account.invoice"
830+
831+ def action_move_create(self, cr, uid, ids, context=None):
832+ """Creates invoice related analytics and financial move lines
833+ We have to go one by one to inject invoice to line_get_convert
834+ """
835+ if context is None:
836+ context = {}
837+ for inv in self.browse(cr, uid, ids, context=context):
838+ context.update({'brw_invoice': inv})
839+ super(account_invoice,self).action_move_create(cr, uid, [inv.id], context=context)
840+ return True
841+
842+ def line_get_convert(self, cr, uid, x, part, date, context=None):
843+ res =super(account_invoice,self).line_get_convert(cr, uid, x, part, date, context=context)
844+ if context is None:
845+ context = {}
846+ invoice = context.get('brw_invoice',False)
847+ if invoice and invoice.journal_id.posting_policy=='storno':
848+ credit = debit = 0.0
849+ if invoice.type in ('out_invoice', 'out_refund'):
850+ if x.get('type','src') in ('dest'):
851+ debit = x['price'] # for OUT_invoice dest (tot. amount goes to debit)
852+ else: # in('src','tax')
853+ credit = x['price'] * (-1)
854+ else: #in ('in_invoice', 'in_refund')
855+ if x.get('type','src') in ('dest'):
856+ credit = x['price'] * (-1)
857+ else:
858+ debit = x['price']
859+ res['debit'] = debit
860+ res['credit'] = credit
861+ return res
862+
863+ def group_lines(self, cr, uid, iml, line, inv):
864+ """Merge account move lines (and hence analytic lines) if invoice line hashcodes are equals"""
865+ if inv.journal_id.group_invoice_lines:
866+ if inv.journal_id.posting_policy == 'contra':
867+ return super(account_invoice,self).group_lines(cr, uid, iml, line, inv)
868+ if inv.journal_id.posting_policy == 'storno':
869+ line2 = {}
870+ for x, y, l in line:
871+ hash = self.inv_line_characteristic_hashcode(inv, l)
872+ side = l['debit'] > 0 and 'debit' or 'credit'
873+ tmp = '-'.join((hash,side))
874+ if tmp in line2:
875+ line2[tmp]['debit'] += l['debit'] or 0.0
876+ line2[tmp]['credit'] += l['credit'] or 0.00
877+ line2[tmp]['tax_amount'] += l['tax_amount']
878+ line2[tmp]['analytic_lines'] += l['analytic_lines']
879+ line2[tmp]['amount_currency'] += l['amount_currency']
880+ line2[tmp]['quantity'] += l['quantity']
881+ else:
882+ line2[tmp] = l
883+ line = []
884+ for key, val in line2.items():
885+ line.append((0,0,val))
886+ return line

Subscribers

People subscribed via source and target branches