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
=== added directory 'account_storno'
=== added file 'account_storno/__init__.py'
--- account_storno/__init__.py 1970-01-01 00:00:00 +0000
+++ account_storno/__init__.py 2013-04-10 09:33:20 +0000
@@ -0,0 +1,30 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Module: account_storno
6# Author: Goran Kliska
7# mail: gkliskaATgmail.com
8# Copyright (C) 2011- Slobodni programi d.o.o., Zagreb
9# Contributions:
10#
11# This program is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Affero General Public License as
13# published by the Free Software Foundation, either version 3 of the
14# License, or (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU Affero General Public License for more details.
20#
21# You should have received a copy of the GNU Affero General Public License
22# along with this program. If not, see <http://www.gnu.org/licenses/>.
23#
24##############################################################################
25
26import account
27import invoice
28import account_invoice_refund
29
30# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file31\ No newline at end of file
132
=== added file 'account_storno/__openerp__.py'
--- account_storno/__openerp__.py 1970-01-01 00:00:00 +0000
+++ account_storno/__openerp__.py 2013-04-10 09:33:20 +0000
@@ -0,0 +1,62 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Module: account_storno
6# Author: Goran Kliska
7# mail: gkliskaATgmail.com
8# Copyright (C) 2011- Slobodni programi d.o.o., Zagreb
9# http://www.slobodni-programi.hr
10# Contributions:
11#
12# This program is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Affero General Public License as
14# published by the Free Software Foundation, either version 3 of the
15# License, or (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU Affero General Public License for more details.
21#
22# You should have received a copy of the GNU Affero General Public License
23# along with this program. If not, see <http://www.gnu.org/licenses/>.
24#
25##############################################################################
26
27{
28 "name" : "Account storno",
29 "description" : """
30
31Author: Goran Kliska @ Slobodni programi d.o.o.
32 http://www.slobodni-programi.hr
33Contributions:
34 Ivan Vađić @ Slobodni programi d.o.o.
35 Tomislav Bošnjaković @ Storm Computers d.o.o.: Bugs report
36
37Description:
38 Enables Storno Accounting, a business practice commonly used in Eastern European countries.
39 Adds new field "Posting policy" with values Storno/Contra on the Journal.
40 For Storno Journals refund invoices are (usually) done in the same journal with negative *(-1) quantities.
41
42 Countries where Storno accounting is mandatory or considered as best practice:
43 Czech Republic, Poland, Romania, Russia, China, Slovakia, Slovenia, Ukraine, Croatia, Bosnia and Herzegovina, Serbia, Romania, ...
44
45WARNING:
46 This module is managing accounting, invoices, and refund wizard.
47 Other modules are required for stock, voucher, etc. storno posting.
48
49""",
50 "version" : "13.1",
51 "author" : "Slobodni programi d.o.o.",
52 "category" : "Localisation/Croatia",
53 "website": "http://www.slobodni-programi.hr",
54 'depends': ['account',],
55 'init_xml': [],
56 'update_xml': [ 'account_view.xml',],
57 "demo_xml" : [],
58 'test' : [],
59 "active": False,
60 "installable": True,
61}
62# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0\ No newline at end of file63\ No newline at end of file
164
=== added file 'account_storno/account.py'
--- account_storno/account.py 1970-01-01 00:00:00 +0000
+++ account_storno/account.py 2013-04-10 09:33:20 +0000
@@ -0,0 +1,96 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Module: account_storno
6# Author: Goran Kliska
7# mail: gkliskaATgmail.com,
8# Copyright (C) 2011- Slobodni programi d.o.o., Zagreb www.slobodni-programi.hr
9# Contributions:
10#
11# This program is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Affero General Public License as
13# published by the Free Software Foundation, either version 3 of the
14# License, or (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU Affero General Public License for more details.
20#
21# You should have received a copy of the GNU Affero General Public License
22# along with this program. If not, see <http://www.gnu.org/licenses/>.
23#
24##############################################################################
25
26from osv import fields, osv, orm
27from openerp.tools import float_compare
28from openerp.tools.translate import _
29import decimal_precision as dp
30
31class account_journal(osv.osv):
32 _inherit = "account.journal"
33 _columns = {
34 'posting_policy':fields.selection([
35 ('contra', 'Contra (debit<->credit)'),
36 ('storno', 'Storno (-)'),
37 ],
38 'Storno or Contra', size=16, required=True,
39 help="Storno allows minus postings, Refunds are posted on the same joural/account * (-1).\n"
40 "Contra doesn't allow negative posting. Refunds are posted by swaping credit and debit side."
41 ),
42 'refund_journal_id':fields.many2one('account.journal', 'Refund journal',
43 help="Journal for refunds/returns from this journal. Leave empty to use same journal for normal and refund/return postings.",
44 ),
45 }
46 _defaults = {'posting_policy': 'storno',
47 }
48
49
50class account_move_line(osv.osv):
51 _inherit = "account.move.line"
52 #Original constraints
53 #_sql_constraints = [
54 #('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in accounting entry !'),
55 #('credit_debit2', 'CHECK (credit+debit>=0)', 'Wrong credit or debit value in accounting entry !'),
56 #]
57 # credit_debit1 is valid constraint. Clear message
58 # credit_debit2 is replaced with dummy constraint that is always true.
59
60 _sql_constraints = [
61 ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in accounting entry! Either credit or debit must be 0.00.'),
62 ('credit_debit2', 'CHECK (abs(credit+debit)>=0)', 'Wrong credit or debit value in accounting entry !'),
63 ]
64
65 def _check_contra_minus(self, cr, uid, ids, context=None):
66 """ This is to restore credit_debit2 check functionality, for contra journals
67 """
68 for l in self.browse(cr, uid, ids, context=context):
69 if l.journal_id.posting_policy == 'contra':
70 if l.debit + l.credit < 0.0:
71 return False
72 return True
73
74 def _check_storno_tax(self, cr, uid, ids, context=None):
75 """For Storno accounting Tax/Base amount is always == (debit + credit)
76 Still trying to find the case where it is not.
77 Maybe for contra check is abs(tax_amount) = abs(debit + credit) ???
78 """
79 for l in self.browse(cr, uid, ids, context=context):
80 if l.journal_id.posting_policy == 'storno' and l.tax_code_id:
81 if float_compare((l.debit + l.credit), l.tax_amount, precision_digits = 2) != 0: #precision_digits=dp.get_precision('Account')[1])
82 return False
83 return True
84
85 _constraints = [
86 (_check_contra_minus, _('Negative credit or debit amount is not allowed for "contra" journal policy.'), ['journal_id']),
87 (_check_storno_tax, _('Invalid tax amount. Tax amount can be 0.00 or equal to (Credit + Debit).'), ['journal_id']),
88 ]
89
90
91class account_model_line(osv.osv):
92 _inherit = "account.model.line"
93 _sql_constraints = [
94 ('credit_debit1', 'CHECK (credit*debit=0)', 'Wrong credit or debit value in model! Either credit or debit must be 0.00.'),
95 ('credit_debit2', 'CHECK (abs(credit+debit)>=0)', 'Wrong credit or debit value in accounting entry !'),
96 ]
097
=== added file 'account_storno/account_invoice_refund.py'
--- account_storno/account_invoice_refund.py 1970-01-01 00:00:00 +0000
+++ account_storno/account_invoice_refund.py 2013-04-10 09:33:20 +0000
@@ -0,0 +1,125 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Module: account_storno
6# Author: Goran Kliska
7# mail: gkliskaATgmail.com
8# Copyright (C) 2011- Slobodni programi d.o.o., Zagreb
9# Contributions:
10#
11# This program is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Affero General Public License as
13# published by the Free Software Foundation, either version 3 of the
14# License, or (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU Affero General Public License for more details.
20#
21# You should have received a copy of the GNU Affero General Public License
22# along with this program. If not, see <http://www.gnu.org/licenses/>.
23#
24##############################################################################
25import time
26from osv import fields, osv
27from tools.translate import _
28import netsvc
29
30class account_invoice(osv.osv):
31 """Not knowing legal requirements of all storno countries about journals
32 This version is for Croatia, Bih, Serbia...
33 Candidate for new module?
34 """
35 _inherit = "account.invoice"
36
37 def _journal_invoice_type_dict(self):
38 return {'sale': 'out_invoice', # Customer Invoice
39 'purchase': 'in_invoice', # Customer Refund
40 'sale_refund': 'out_refund', # Supplier Invoice
41 'purchase_refund': 'in_refund', # Supplier Refund
42 }
43
44 def refund(self, cr, uid, ids, date=None, period_id=None, description=None, journal_id=None):
45 #Where is the context, per invoice method?
46 #This approach is slow, updating after creating, but maybe better than copy-paste whole method
47 res = super(account_invoice, self).refund(cr, uid, ids, date=date, period_id=period_id, description=description, journal_id=journal_id)
48 for invoice in self.pool.get('account.invoice').browse(cr, uid, res):
49 self.pool.get('account.invoice').write(cr, uid, [invoice.id],
50 {'type': self._journal_invoice_type_dict()[invoice.journal_id.type] })
51 if invoice.journal_id.posting_policy == 'storno':
52 for inv_line in invoice.invoice_line:
53 self.pool.get('account.invoice.line').write(cr, uid,
54 [inv_line.id],
55 {'quantity': inv_line.quantity * (-1) })
56 for tax_line in invoice.tax_line:
57 if tax_line.manual or True:
58 self.pool.get('account.invoice.tax').write(cr, uid,
59 [tax_line.id],
60 {'base': tax_line.base * (-1),
61 'amount': tax_line.amount * (-1),
62 'base_amount': tax_line.base_amount * (-1),
63 'tax_amount': tax_line.tax_amount * (-1),
64 })
65 return res
66
67
68class account_invoice_refund(osv.osv_memory):
69 _inherit = "account.invoice.refund"
70
71 def _get_journal(self, cr, uid, context=None):
72 """"in Croatia, for out invoice refunds must go to same journal #TODO for localization
73 """
74 #borrowed from Akretion account_journal_sale_refund_link
75 #compatibility with crm_claim_rma module
76 invoice_id = context.get('invoice_ids', [context['active_id']])[0]
77 invoice = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context)
78 refund_journal_id = invoice.journal_id.refund_journal_id
79 if refund_journal_id:
80 return refund_journal_id.id
81 elif invoice.journal_id.posting_policy == 'storno':
82 return False #meaning: same journal as original
83 else:
84 return super(account_invoice_refund, self)._get_journal(cr, uid, context)
85
86 _defaults = {
87 'journal_id': _get_journal,
88 'filter_refund': 'modify',
89 }
90
91 def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
92 journal_obj = self.pool.get('account.journal')
93 user_obj = self.pool.get('res.users')
94 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)
95 company_id = user_obj.browse(cr, uid, uid, context=context).company_id.id
96 #I would love to have invoice.journal_id.posting_policy here
97 invoice_type = context.get('type', 'all')
98 if invoice_type in ('out_invoice', 'out_refund'):
99 journal_types = ('sale','sale_refund')
100 elif invoice_type in ('in_invoice', 'in_refund'):
101 journal_types = ('purchase','purchase_refund')
102 else:
103 journal_types = ('sale','sale_refund','purchase','purchase_refund')
104 journal_select = journal_obj._name_search(cr, uid, '', [('type', 'in', journal_types), ('company_id','child_of',[company_id])], context=context)
105 #original for loop needed???
106 res['fields']['journal_id']['selection'] = journal_select
107 return res
108
109 def compute_refund(self, cr, uid, ids, mode='refund', context=None):
110 mod_obj = self.pool.get('ir.model.data')
111 act_obj = self.pool.get('ir.actions.act_window')
112 res = super(account_invoice_refund,self).compute_refund(cr, uid, ids, mode=mode, context=context)
113 last_inv_id = res['domain'][1][2][-1] #yupiii here is last created invoice id, great hook
114 inv = self.pool.get('account.invoice').browse(cr, uid, [last_inv_id])[0]
115 xml_id = (inv.type == 'out_refund') and 'action_invoice_tree3' or \
116 (inv.type == 'in_refund') and 'action_invoice_tree4' or \
117 (inv.type == 'out_invoice') and 'action_invoice_tree1' or \
118 (inv.type == 'in_invoice') and 'action_invoice_tree2'
119 result = mod_obj.get_object_reference(cr, uid, 'account', xml_id)
120 id = result and result[1] or False
121 result = act_obj.read(cr, uid, id, context=context)
122 invoice_domain = eval(result['domain'])
123 invoice_domain.append(('id', 'in', res['domain'][1][2] ))
124 result['domain'] = invoice_domain
125 return result
0126
=== added file 'account_storno/account_view.xml'
--- account_storno/account_view.xml 1970-01-01 00:00:00 +0000
+++ account_storno/account_view.xml 2013-04-10 09:33:20 +0000
@@ -0,0 +1,17 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4 <record id="view_account_journal_form_posting_policy" model="ir.ui.view">
5 <field name="name">account.journal.form.storno</field>
6 <field name="model">account.journal</field>
7 <field name="type">form</field>
8 <field name="inherit_id" ref="account.view_account_journal_form" />
9 <field name="arch" type="xml">
10 <field name="centralisation" position="after">
11 <field name="posting_policy" groups="account.group_account_manager"/>
12 <field name="refund_journal_id" groups="account.group_account_manager"/>
13 </field>
14 </field>
15 </record>
16 </data>
17</openerp>
0\ No newline at end of file18\ No newline at end of file
119
=== added directory 'account_storno/i18n'
=== added file 'account_storno/i18n/account_storno.pot'
--- account_storno/i18n/account_storno.pot 1970-01-01 00:00:00 +0000
+++ account_storno/i18n/account_storno.pot 2013-04-10 09:33:20 +0000
@@ -0,0 +1,212 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * account_storno
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.1beta\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2012-01-04 12:30+0000\n"
10"PO-Revision-Date: 2012-01-04 12:30+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: account_storno
19#: code:addons/account_storno/account_invoice_refund.py:212
20#, python-format
21msgid "Can not %s draft/proforma/cancel invoice."
22msgstr "Can not %s draft/proforma/cancel invoice."
23
24#. module: account_storno
25#: constraint:account.move.line:0
26msgid "Company must be the same for its related account and period."
27msgstr "Company must be the same for its related account and period."
28
29#. module: account_storno
30#: code:addons/account_storno/invoice.py:45
31#, python-format
32msgid "No Invoice Lines !"
33msgstr "No Invoice Lines !"
34
35#. module: account_storno
36#: sql_constraint:account.journal:0
37msgid "The name of the journal must be unique per company !"
38msgstr "The name of the journal must be unique per company !"
39
40#. module: account_storno
41#: code:addons/account_storno/invoice.py:62
42#, python-format
43msgid "Bad total !"
44msgstr "Bad total !"
45
46#. module: account_storno
47#: code:addons/account_storno/invoice.py:73
48#, python-format
49msgid "Can not create the invoice !\n"
50"The related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount."
51msgstr "Can not create the invoice !\n"
52"The related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount."
53
54#. module: account_storno
55#: code:addons/account_storno/invoice.py:45
56#, python-format
57msgid "Please create some invoice lines."
58msgstr "Please create some invoice lines."
59
60#. module: account_storno
61#: sql_constraint:account.model.line:0
62msgid "Wrong credit or debit value in model, they must be positive!"
63msgstr "Wrong credit or debit value in model, they must be positive!"
64
65#. module: account_storno
66#: code:addons/account_storno/account_invoice_refund.py:212
67#: code:addons/account_storno/account_invoice_refund.py:214
68#: code:addons/account_storno/invoice.py:43
69#: code:addons/account_storno/invoice.py:73
70#, python-format
71msgid "Error !"
72msgstr "Error !"
73
74#. module: account_storno
75#: model:ir.model,name:account_storno.model_account_journal
76msgid "Journal"
77msgstr "Journal"
78
79#. module: account_storno
80#: selection:account.journal,posting_policy:0
81msgid "Contra (debit<->credit)"
82msgstr "Contra (debit<->credit)"
83
84#. module: account_storno
85#: code:addons/account_storno/invoice.py:43
86#, python-format
87msgid "Please define sequence on invoice journal"
88msgstr "Please define sequence on invoice journal"
89
90#. module: account_storno
91#: field:account.journal,refund_journal_id:0
92msgid "Invoice refund journal"
93msgstr "Invoice refund journal"
94
95#. module: account_storno
96#: selection:account.journal,posting_policy:0
97msgid "Storno (-)"
98msgstr "Storno (-)"
99
100#. module: account_storno
101#: model:ir.model,name:account_storno.model_account_move_line
102msgid "Journal Items"
103msgstr "Journal Items"
104
105#. module: account_storno
106#: constraint:account.move.line:0
107msgid "You can not create journal items on an account of type view."
108msgstr "You can not create journal items on an account of type view."
109
110#. module: account_storno
111#: code:addons/account_storno/invoice.py:161
112#, python-format
113msgid "You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu."
114msgstr "You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu."
115
116#. module: account_storno
117#: code:addons/account_storno/account_invoice_refund.py:250
118#, python-format
119msgid "No Period found on Invoice!"
120msgstr "No Period found on Invoice!"
121
122#. module: account_storno
123#: sql_constraint:account.model.line:0
124msgid "Wrong credit or debit value in model (Credit + Debit Must Be greater \"0\")!"
125msgstr "Wrong credit or debit value in model (Credit + Debit Must Be greater \"0\")!"
126
127#. module: account_storno
128#: model:ir.model,name:account_storno.model_account_model_line
129msgid "Account Model Entries"
130msgstr "Account Model Entries"
131
132#. module: account_storno
133#: constraint:account.move.line:0
134msgid "You can not create journal items on closed account."
135msgstr "You can not create journal items on closed account."
136
137#. module: account_storno
138#: constraint:account.journal:0
139msgid "Configuration error! The currency chosen should be shared by the default accounts too."
140msgstr "Configuration error! The currency chosen should be shared by the default accounts too."
141
142#. module: account_storno
143#: sql_constraint:account.move.line:0
144msgid "Wrong credit or debit value in accounting entry !"
145msgstr "Wrong credit or debit value in accounting entry !"
146
147#. module: account_storno
148#: code:addons/account_storno/invoice.py:160
149#, python-format
150msgid "UserError"
151msgstr "UserError"
152
153#. module: account_storno
154#: sql_constraint:account.invoice:0
155msgid "Invoice Number must be unique per Company!"
156msgstr "Invoice Number must be unique per Company!"
157
158#. module: account_storno
159#: code:addons/account_storno/invoice.py:62
160#, python-format
161msgid "Please verify the price of the invoice !\n"
162"The real total does not match the computed total."
163msgstr "Please verify the price of the invoice !\n"
164"The real total does not match the computed total."
165
166#. module: account_storno
167#: model:ir.model,name:account_storno.model_account_invoice_refund
168msgid "Invoice Refund"
169msgstr "Invoice Refund"
170
171#. module: account_storno
172#: code:addons/account_storno/account_invoice_refund.py:249
173#, python-format
174msgid "Data Insufficient !"
175msgstr "Data Insufficient !"
176
177#. module: account_storno
178#: field:account.journal,posting_policy:0
179msgid "Storno or Contra"
180msgstr "Storno or Contra"
181
182#. module: account_storno
183#: constraint:account.move.line:0
184msgid "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."
185msgstr "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."
186
187#. module: account_storno
188#: constraint:account.move.line:0
189msgid "The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal."
190msgstr "The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal."
191
192#. module: account_storno
193#: code:addons/account_storno/account_invoice_refund.py:214
194#, python-format
195msgid "Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice"
196msgstr "Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice"
197
198#. module: account_storno
199#: sql_constraint:account.journal:0
200msgid "The code of the journal must be unique per company !"
201msgstr "The code of the journal must be unique per company !"
202
203#. module: account_storno
204#: model:ir.model,name:account_storno.model_account_invoice
205msgid "Invoice"
206msgstr "Invoice"
207
208#. module: account_storno
209#: help:account.journal,posting_policy:0
210msgid "Contra doesn't allow negative posting by swaping credit and debit side. Storno allows minus postings."
211msgstr "Contra doesn't allow negative posting by swaping credit and debit side. Storno allows minus postings."
212
0213
=== added file 'account_storno/i18n/hr.po'
--- account_storno/i18n/hr.po 1970-01-01 00:00:00 +0000
+++ account_storno/i18n/hr.po 2013-04-10 09:33:20 +0000
@@ -0,0 +1,212 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * account_storno
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 6.1beta\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2012-01-04 12:30+0000\n"
10"PO-Revision-Date: 2012-01-04 12:30+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: account_storno
19#: code:addons/account_storno/account_invoice_refund.py:212
20#, python-format
21msgid "Can not %s draft/proforma/cancel invoice."
22msgstr "Can not %s draft/proforma/cancel invoice."
23
24#. module: account_storno
25#: constraint:account.move.line:0
26msgid "Company must be the same for its related account and period."
27msgstr "Company must be the same for its related account and period."
28
29#. module: account_storno
30#: code:addons/account_storno/invoice.py:45
31#, python-format
32msgid "No Invoice Lines !"
33msgstr "No Invoice Lines !"
34
35#. module: account_storno
36#: sql_constraint:account.journal:0
37msgid "The name of the journal must be unique per company !"
38msgstr "The name of the journal must be unique per company !"
39
40#. module: account_storno
41#: code:addons/account_storno/invoice.py:62
42#, python-format
43msgid "Bad total !"
44msgstr "Bad total !"
45
46#. module: account_storno
47#: code:addons/account_storno/invoice.py:73
48#, python-format
49msgid "Can not create the invoice !\n"
50"The related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount."
51msgstr "Can not create the invoice !\n"
52"The related payment term is probably misconfigured as it gives a computed amount greater than the total invoiced amount."
53
54#. module: account_storno
55#: code:addons/account_storno/invoice.py:45
56#, python-format
57msgid "Please create some invoice lines."
58msgstr "Please create some invoice lines."
59
60#. module: account_storno
61#: sql_constraint:account.model.line:0
62msgid "Wrong credit or debit value in model, they must be positive!"
63msgstr "Wrong credit or debit value in model, they must be positive!"
64
65#. module: account_storno
66#: code:addons/account_storno/account_invoice_refund.py:212
67#: code:addons/account_storno/account_invoice_refund.py:214
68#: code:addons/account_storno/invoice.py:43
69#: code:addons/account_storno/invoice.py:73
70#, python-format
71msgid "Error !"
72msgstr "Error !"
73
74#. module: account_storno
75#: model:ir.model,name:account_storno.model_account_journal
76msgid "Journal"
77msgstr "Journal"
78
79#. module: account_storno
80#: selection:account.journal,posting_policy:0
81msgid "Contra (debit<->credit)"
82msgstr "Contra (debit<->credit)"
83
84#. module: account_storno
85#: code:addons/account_storno/invoice.py:43
86#, python-format
87msgid "Please define sequence on invoice journal"
88msgstr "Please define sequence on invoice journal"
89
90#. module: account_storno
91#: field:account.journal,refund_journal_id:0
92msgid "Invoice refund journal"
93msgstr "Invoice refund journal"
94
95#. module: account_storno
96#: selection:account.journal,posting_policy:0
97msgid "Storno (-)"
98msgstr "Storno (-)"
99
100#. module: account_storno
101#: model:ir.model,name:account_storno.model_account_move_line
102msgid "Journal Items"
103msgstr "Journal Items"
104
105#. module: account_storno
106#: constraint:account.move.line:0
107msgid "You can not create journal items on an account of type view."
108msgstr "You can not create journal items on an account of type view."
109
110#. module: account_storno
111#: code:addons/account_storno/invoice.py:161
112#, python-format
113msgid "You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu."
114msgstr "You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu."
115
116#. module: account_storno
117#: code:addons/account_storno/account_invoice_refund.py:250
118#, python-format
119msgid "No Period found on Invoice!"
120msgstr "No Period found on Invoice!"
121
122#. module: account_storno
123#: sql_constraint:account.model.line:0
124msgid "Wrong credit or debit value in model (Credit + Debit Must Be greater \"0\")!"
125msgstr "Wrong credit or debit value in model (Credit + Debit Must Be greater \"0\")!"
126
127#. module: account_storno
128#: model:ir.model,name:account_storno.model_account_model_line
129msgid "Account Model Entries"
130msgstr "Account Model Entries"
131
132#. module: account_storno
133#: constraint:account.move.line:0
134msgid "You can not create journal items on closed account."
135msgstr "You can not create journal items on closed account."
136
137#. module: account_storno
138#: constraint:account.journal:0
139msgid "Configuration error! The currency chosen should be shared by the default accounts too."
140msgstr "Configuration error! The currency chosen should be shared by the default accounts too."
141
142#. module: account_storno
143#: sql_constraint:account.move.line:0
144msgid "Wrong credit or debit value in accounting entry !"
145msgstr "Wrong credit or debit value in accounting entry !"
146
147#. module: account_storno
148#: code:addons/account_storno/invoice.py:160
149#, python-format
150msgid "UserError"
151msgstr "UserError"
152
153#. module: account_storno
154#: sql_constraint:account.invoice:0
155msgid "Invoice Number must be unique per Company!"
156msgstr "Invoice Number must be unique per Company!"
157
158#. module: account_storno
159#: code:addons/account_storno/invoice.py:62
160#, python-format
161msgid "Please verify the price of the invoice !\n"
162"The real total does not match the computed total."
163msgstr "Please verify the price of the invoice !\n"
164"The real total does not match the computed total."
165
166#. module: account_storno
167#: model:ir.model,name:account_storno.model_account_invoice_refund
168msgid "Invoice Refund"
169msgstr "Invoice Refund"
170
171#. module: account_storno
172#: code:addons/account_storno/account_invoice_refund.py:249
173#, python-format
174msgid "Data Insufficient !"
175msgstr "Data Insufficient !"
176
177#. module: account_storno
178#: field:account.journal,posting_policy:0
179msgid "Storno or Contra"
180msgstr "Storno or Contra"
181
182#. module: account_storno
183#: constraint:account.move.line:0
184msgid "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."
185msgstr "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."
186
187#. module: account_storno
188#: constraint:account.move.line:0
189msgid "The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal."
190msgstr "The date of your Journal Entry is not in the defined period! You should change the date or remove this constraint from the journal."
191
192#. module: account_storno
193#: code:addons/account_storno/account_invoice_refund.py:214
194#, python-format
195msgid "Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice"
196msgstr "Can not %s invoice which is already reconciled, invoice should be unreconciled first. You can only Refund this invoice"
197
198#. module: account_storno
199#: sql_constraint:account.journal:0
200msgid "The code of the journal must be unique per company !"
201msgstr "The code of the journal must be unique per company !"
202
203#. module: account_storno
204#: model:ir.model,name:account_storno.model_account_invoice
205msgid "Invoice"
206msgstr "Invoice"
207
208#. module: account_storno
209#: help:account.journal,posting_policy:0
210msgid "Contra doesn't allow negative posting by swaping credit and debit side. Storno allows minus postings."
211msgstr "Contra doesn't allow negative posting by swaping credit and debit side. Storno allows minus postings."
212
0213
=== added file 'account_storno/invoice.py'
--- account_storno/invoice.py 1970-01-01 00:00:00 +0000
+++ account_storno/invoice.py 2013-04-10 09:33:20 +0000
@@ -0,0 +1,88 @@
1# -*- encoding: utf-8 -*-
2##############################################################################
3#
4# OpenERP, Open Source Management Solution
5# Module: account_storno
6# Author: Goran Kliska
7# mail: gkliskaATgmail.com
8# Copyright (C) 2013- Slobodni programi d.o.o., Zagreb
9# Contributions:
10#
11# This program is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Affero General Public License as
13# published by the Free Software Foundation, either version 3 of the
14# License, or (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU Affero General Public License for more details.
20#
21# You should have received a copy of the GNU Affero General Public License
22# along with this program. If not, see <http://www.gnu.org/licenses/>.
23#
24##############################################################################
25
26from osv import fields, osv, orm
27import time
28from tools.translate import _
29
30class account_invoice(osv.osv):
31 _inherit = "account.invoice"
32
33 def action_move_create(self, cr, uid, ids, context=None):
34 """Creates invoice related analytics and financial move lines
35 We have to go one by one to inject invoice to line_get_convert
36 """
37 if context is None:
38 context = {}
39 for inv in self.browse(cr, uid, ids, context=context):
40 context.update({'brw_invoice': inv})
41 super(account_invoice,self).action_move_create(cr, uid, [inv.id], context=context)
42 return True
43
44 def line_get_convert(self, cr, uid, x, part, date, context=None):
45 res =super(account_invoice,self).line_get_convert(cr, uid, x, part, date, context=context)
46 if context is None:
47 context = {}
48 invoice = context.get('brw_invoice',False)
49 if invoice and invoice.journal_id.posting_policy=='storno':
50 credit = debit = 0.0
51 if invoice.type in ('out_invoice', 'out_refund'):
52 if x.get('type','src') in ('dest'):
53 debit = x['price'] # for OUT_invoice dest (tot. amount goes to debit)
54 else: # in('src','tax')
55 credit = x['price'] * (-1)
56 else: #in ('in_invoice', 'in_refund')
57 if x.get('type','src') in ('dest'):
58 credit = x['price'] * (-1)
59 else:
60 debit = x['price']
61 res['debit'] = debit
62 res['credit'] = credit
63 return res
64
65 def group_lines(self, cr, uid, iml, line, inv):
66 """Merge account move lines (and hence analytic lines) if invoice line hashcodes are equals"""
67 if inv.journal_id.group_invoice_lines:
68 if inv.journal_id.posting_policy == 'contra':
69 return super(account_invoice,self).group_lines(cr, uid, iml, line, inv)
70 if inv.journal_id.posting_policy == 'storno':
71 line2 = {}
72 for x, y, l in line:
73 hash = self.inv_line_characteristic_hashcode(inv, l)
74 side = l['debit'] > 0 and 'debit' or 'credit'
75 tmp = '-'.join((hash,side))
76 if tmp in line2:
77 line2[tmp]['debit'] += l['debit'] or 0.0
78 line2[tmp]['credit'] += l['credit'] or 0.00
79 line2[tmp]['tax_amount'] += l['tax_amount']
80 line2[tmp]['analytic_lines'] += l['analytic_lines']
81 line2[tmp]['amount_currency'] += l['amount_currency']
82 line2[tmp]['quantity'] += l['quantity']
83 else:
84 line2[tmp] = l
85 line = []
86 for key, val in line2.items():
87 line.append((0,0,val))
88 return line

Subscribers

People subscribed via source and target branches