Merge lp:~camptocamp/account-invoicing/7.0-add-swedish_rounding-yvr into lp:~account-core-editors/account-invoicing/7.0

Proposed by Yannick Vaucher @ Camptocamp
Status: Merged
Merged at revision: 32
Proposed branch: lp:~camptocamp/account-invoicing/7.0-add-swedish_rounding-yvr
Merge into: lp:~account-core-editors/account-invoicing/7.0
Diff against target: 661 lines (+622/-0)
7 files modified
account_invoice_rounding/__init__.py (+23/-0)
account_invoice_rounding/__openerp__.py (+57/-0)
account_invoice_rounding/account.py (+313/-0)
account_invoice_rounding/company.py (+52/-0)
account_invoice_rounding/i18n/account_invoice_rounding.pot (+74/-0)
account_invoice_rounding/res_config.py (+77/-0)
account_invoice_rounding/res_config_view.xml (+26/-0)
To merge this branch: bzr merge lp:~camptocamp/account-invoicing/7.0-add-swedish_rounding-yvr
Reviewer Review Type Date Requested Status
Leonardo Pistone code review Approve
Yannick Vaucher @ Camptocamp Abstain
Frederic Clementi - Camptocamp (community) functional Approve
Joël Grand-Guillaume @ camptocamp code review, no tests Approve
Nicolas Bessi - Camptocamp Pending
Review via email: mp+201598@code.launchpad.net

This proposal supersedes a proposal from 2013-06-25.

Description of the change

Resubmit on account-invoicing making it a bit more generic by renaming l10n_ch by swedish due to http://en.wikipedia.org/wiki/Swedish_rounding

To post a comment you must log in.
Revision history for this message
Nicolas Bessi - Camptocamp (nbessi-c2c-deactivatedaccount) wrote : Posted in a previous version of this proposal

Hello,

Should we put this addons in account-financial-tools + a configuration addons in l10n_ch

review: Needs Information
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : Posted in a previous version of this proposal

It would make sense if in other countries you also have a unit different than a base of 10. Likes we do in Switzerland as our lowest unit is 5 cts.

Otherwise, if in other countries you are allowed / want to give a rounded tax amount to round your total on an other base that 10.

I couldn't found such information about this need for other countries.

review: Needs Information
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : Posted in a previous version of this proposal

> It would make sense if in other countries you also have a unit different than
> a base of 10. Likes we do in Switzerland as our lowest unit is 5 cts.
>
> Otherwise, if in other countries you are allowed / want to give a rounded tax
> amount to round your total on an other base that 10.
>
> I couldn't found such information about this need for other countries.

Here is an interesting link: http://en.wikipedia.org/wiki/Swedish_rounding, it may be useful for other countries with 5 øre intervals. (the 25 øre is no longer used).

Revision history for this message
Frederic Clementi - Camptocamp (frederic-clementi) wrote : Posted in a previous version of this proposal

> Hello,
>
> Should we put this addons in account-financial-tools + a configuration addons
> in l10n_ch

Guewen link shows that this module is generic -> yes let's put this into account-financial-tools + a module in l10n_ch

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : Posted in a previous version of this proposal

Go for this one, more appropriate: https://launchpad.net/account-invoicing

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) :
review: Abstain
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Ready for reviews

Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

Hi,

Thanks a lot for this module ! LGTM

Joël

review: Approve (code review, no tests)
Revision history for this message
Frederic Clementi - Camptocamp (frederic-clementi) wrote :

Functional test Ok

review: Approve (functional)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

account_invoice_rounding/__openerp__.py:21:8: E203 whitespace before ':'
account_invoice_rounding/__openerp__.py:22:11: E203 whitespace before ':'
account_invoice_rounding/__openerp__.py:25:1: E128 continuation line under-indented for visual indent
account_invoice_rounding/__openerp__.py:49:10: E203 whitespace before ':'
account_invoice_rounding/__openerp__.py:52:11: E203 whitespace before ':'

review: Needs Fixing
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) :
review: Abstain
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Fixed PEP8 according to jenkins

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Good!

One small remark: why is the function _all_invoice_tax_line_computed not in the invoice class?

To show that it does not use any class or instance data, we can make it a @staticmethod.

I do not consider this a significant problem though, so I approve in any case.

Thanks

review: Approve (code review)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Well no idea why I did that at that time. I'll make it static. Thanks for the review.
And I'll give it a doc string.

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Moved _all_invoice_tax_line_computed inside invoice class

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Thanks Yannick!

review: Approve (code review)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'account_invoice_rounding'
2=== added file 'account_invoice_rounding/__init__.py'
3--- account_invoice_rounding/__init__.py 1970-01-01 00:00:00 +0000
4+++ account_invoice_rounding/__init__.py 2014-02-24 15:21:21 +0000
5@@ -0,0 +1,23 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Author: Yannick Vaucher
10+# Copyright 2013 Camptocamp SA
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+from . import company
27+from . import res_config
28+from . import account
29
30=== added file 'account_invoice_rounding/__openerp__.py'
31--- account_invoice_rounding/__openerp__.py 1970-01-01 00:00:00 +0000
32+++ account_invoice_rounding/__openerp__.py 2014-02-24 15:21:21 +0000
33@@ -0,0 +1,57 @@
34+# -*- coding: utf-8 -*-
35+##############################################################################
36+#
37+# Author: Yannick Vaucher
38+# Copyright 2013 Camptocamp SA
39+#
40+# This program is free software: you can redistribute it and/or modify
41+# it under the terms of the GNU Affero General Public License as
42+# published by the Free Software Foundation, either version 3 of the
43+# License, or (at your option) any later version.
44+#
45+# This program is distributed in the hope that it will be useful,
46+# but WITHOUT ANY WARRANTY; without even the implied warranty of
47+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48+# GNU Affero General Public License for more details.
49+#
50+# You should have received a copy of the GNU Affero General Public License
51+# along with this program. If not, see <http://www.gnu.org/licenses/>.
52+#
53+##############################################################################
54+{'name': 'Unit rounded invoice',
55+ 'version': '1.0',
56+ 'category': 'Accounting',
57+ 'description': """
58+Unit rounded invoice (_`Swedish rounding`)
59+==========================================
60+
61+Add a parameter to give a unit for rounding such as CHF 0.05 for Swiss
62+invoices
63+
64+In Settings -> Configuration -> Accounting you will find 2 new types of
65+rounding
66+
67+- `Swedish Round globally`
68+
69+ To round your invoice total amount, this option will do the adjustment in
70+ the most important tax line of your invoice.
71+
72+- `Swedish Round by adding an invoice line`
73+
74+ To round your invoice total amount, this option create a invoice line without
75+ taxes on it. This invoice line is tagged as `is_rounding`
76+
77+You can choose the account on which the invoice line will be written
78+
79+.. _Swedish rounding : https://en.wikipedia.org/wiki/Swedish_rounding
80+""",
81+ 'author': 'Camptocamp',
82+ 'maintainer': 'Camptocamp',
83+ 'website': 'http://www.camptocamp.com/',
84+ 'depends': ['account'],
85+ 'data': ['res_config_view.xml'],
86+ 'test': [],
87+ 'installable': True,
88+ 'auto_install': False,
89+ 'application': True,
90+ }
91
92=== added file 'account_invoice_rounding/account.py'
93--- account_invoice_rounding/account.py 1970-01-01 00:00:00 +0000
94+++ account_invoice_rounding/account.py 2014-02-24 15:21:21 +0000
95@@ -0,0 +1,313 @@
96+# -*- coding: utf-8 -*-
97+##############################################################################
98+#
99+# Author: Yannick Vaucher
100+# Copyright 2013 Camptocamp SA
101+#
102+# This program is free software: you can redistribute it and/or modify
103+# it under the terms of the GNU Affero General Public License as
104+# published by the Free Software Foundation, either version 3 of the
105+# License, or (at your option) any later version.
106+#
107+# This program is distributed in the hope that it will be useful,
108+# but WITHOUT ANY WARRANTY; without even the implied warranty of
109+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
110+# GNU Affero General Public License for more details.
111+#
112+# You should have received a copy of the GNU Affero General Public License
113+# along with this program. If not, see <http://www.gnu.org/licenses/>.
114+#
115+##############################################################################
116+from openerp.osv import orm, fields
117+from openerp.tools.float_utils import float_round, float_compare
118+from openerp.tools.translate import _
119+
120+import openerp.addons.decimal_precision as dp
121+
122+
123+class AccountInvoice(orm.Model):
124+ _inherit = "account.invoice"
125+
126+ def _swedish_add_invoice_line(self, cr, uid, invoice, amounts,
127+ rounded_total, delta, context=None):
128+ """ Create a invoice_line with the diff of rounding """
129+ invoice_line_obj = self.pool.get('account.invoice.line')
130+ obj_precision = self.pool.get('decimal.precision')
131+ prec = obj_precision.precision_get(cr, uid, 'Account')
132+
133+ company = invoice.company_id
134+ if not invoice.global_round_line_id:
135+ new_invoice_line = {
136+ 'name': _('Rounding'),
137+ 'price_unit': -delta,
138+ 'account_id': company.tax_calculation_rounding_account_id.id,
139+ 'invoice_id': invoice.id,
140+ 'is_rounding': True,
141+ }
142+ invoice_line_obj.create(cr, uid, new_invoice_line, context=context)
143+ elif float_compare(invoice.global_round_line_id.price_unit, -delta,
144+ precision_digits=prec) != 0:
145+ invoice_line_obj.write(
146+ cr, uid, invoice.global_round_line_id.id,
147+ {'price_unit': -delta}, context=context)
148+
149+ amount_untaxed = float_round(amounts['amount_untaxed'] - delta,
150+ precision_digits=prec)
151+ return {'amount_total': rounded_total,
152+ 'amount_untaxed': amount_untaxed}
153+
154+ @staticmethod
155+ def _all_invoice_tax_line_computed(invoice):
156+ """ Check if all taxes have been computed on invoice lines
157+
158+ :return boolean True if all tax were computed
159+ """
160+ tax_ids = set()
161+ for line in invoice.invoice_line:
162+ # invoice_line_tax_id is a many2many if you wonder about it
163+ for tax in line.invoice_line_tax_id:
164+ if not tax.price_include:
165+ tax_ids.add(tax.id)
166+ computed_tax_ids = [tax.id for tax in invoice.tax_line]
167+ return len(tax_ids) == len(computed_tax_ids)
168+
169+ def _swedish_round_globally(self, cr, uid, invoice, amounts,
170+ rounded_total, delta, context=None):
171+ """ Add the diff to the biggest tax line
172+
173+ This ajustment must be done only after all tax are computed
174+
175+ """
176+ # Here we identify that all taxe lines have been computed
177+ if not self._all_invoice_tax_line_computed(invoice):
178+ return {}
179+
180+ obj_precision = self.pool.get('decimal.precision')
181+ prec = obj_precision.precision_get(cr, uid, 'Account')
182+ inv_tax_obj = self.pool.get('account.invoice.tax')
183+
184+ ajust_line = None
185+ for tax_line in invoice.tax_line:
186+ if not ajust_line or tax_line.amount > ajust_line.amount:
187+ ajust_line = tax_line
188+ if ajust_line:
189+ amount = ajust_line.amount - delta
190+ vals = inv_tax_obj.amount_change(
191+ cr, uid, [ajust_line.id],
192+ amount,
193+ currency_id=invoice.currency_id.id,
194+ company_id=invoice.company_id.id,
195+ date_invoice=invoice.date_invoice)['value']
196+ ajust_line.write({'amount': amount,
197+ 'tax_amount': vals['tax_amount']},
198+ context=context)
199+
200+ amount_tax = float_round(amounts['amount_tax'] - delta,
201+ precision_digits=prec)
202+ return {'amount_total': rounded_total,
203+ 'amount_tax': amount_tax}
204+ return {}
205+
206+ def _compute_swedish_rounding(self, cr, uid, invoice, amounts,
207+ context=None):
208+ """
209+ Depending on the method defined, we add an invoice line or adapt the
210+ tax lines to have a rounded total amount on the invoice
211+
212+ :param invoice: invoice browse record
213+ :param amounts: unrounded computed totals for the invoice
214+ :return dict: updated values for _amount_all
215+
216+ """
217+ obj_precision = self.pool.get('decimal.precision')
218+
219+ # avoid recusivity
220+ if 'swedish_write' in context:
221+ return {}
222+
223+ company = invoice.company_id
224+ round_method = company.tax_calculation_rounding_method
225+
226+ if round_method[:7] != 'swedish':
227+ return {}
228+
229+ prec = obj_precision.precision_get(cr, uid, 'Account')
230+ rounding_prec = company.tax_calculation_rounding
231+ rounded_total = float_round(amounts['amount_total'],
232+ precision_rounding=rounding_prec)
233+
234+ if float_compare(rounded_total, amounts['amount_total'],
235+ precision_digits=prec) == 0:
236+ return {}
237+
238+ # To avoid recursivity as we need to write on invoice or
239+ # on objects triggering computation of _amount_all
240+ ctx = context.copy()
241+ ctx['swedish_write'] = True
242+
243+ delta = float_round(amounts['amount_total'] - rounded_total,
244+ precision_digits=prec)
245+
246+ if round_method == 'swedish_add_invoice_line':
247+ return self._swedish_add_invoice_line(cr, uid, invoice, amounts,
248+ rounded_total, delta,
249+ context=ctx)
250+ elif round_method == 'swedish_round_globally':
251+ return self._swedish_round_globally(cr, uid, invoice, amounts,
252+ rounded_total, delta,
253+ context=ctx)
254+ return {}
255+
256+ def _amount_all(self, cr, uid, ids, name, args, context=None):
257+ """ Add swedish rounding computing
258+
259+ Makes sure invoice line for rounding is not computed in totals
260+
261+ """
262+ res = super(AccountInvoice, self
263+ )._amount_all(cr, uid, ids, name, args, context=context)
264+
265+ for invoice in self.browse(cr, uid, ids, context=context):
266+ if invoice.type in ('out_invoice', 'out_refund'):
267+ line = invoice.global_round_line_id
268+ if line:
269+ res[invoice.id]['amount_untaxed'] -= line.price_subtotal
270+
271+ amount_total = res[invoice.id]['amount_tax'] + res[invoice.id]['amount_untaxed']
272+ res[invoice.id]['amount_total'] = amount_total
273+
274+ swedish_rounding = self._compute_swedish_rounding(
275+ cr, uid, invoice, res[invoice.id], context=context)
276+ res[invoice.id].update(swedish_rounding)
277+ return res
278+
279+ def _get_rounding_invoice_line_id(self, cr, uid, ids, name, args,
280+ context=None):
281+ """
282+ :return dict: {invoice id: global_rounding_line_id}
283+
284+ """
285+ line_obj = self.pool.get('account.invoice.line')
286+ res = {}
287+ for invoice_id in ids:
288+ line_ids = line_obj.search(
289+ cr, uid,
290+ [('invoice_id', '=', invoice_id),
291+ ('is_rounding', '=', True)],
292+ context=context)
293+ res[invoice_id] = line_ids and line_ids[0] or False
294+ return res
295+
296+ def _get_invoice_line(self, cr, uid, ids, context=None):
297+ """ Use super's trigger """
298+ return super(AccountInvoice, self.pool.get('account.invoice')
299+ )._get_invoice_line(cr, uid, ids, context=context)
300+
301+ def _get_invoice_tax(self, cr, uid, ids, context=None):
302+ """Use super's trigger"""
303+ return super(AccountInvoice, self.pool.get('account.invoice')
304+ )._get_invoice_tax(cr, uid, ids, context=context)
305+
306+ _columns = {
307+ 'global_round_line_id': fields.function(
308+ _get_rounding_invoice_line_id,
309+ type='many2one',
310+ relation='account.invoice.line',
311+ string='Invoice Line for total rounding',
312+ readonly=True),
313+ 'amount_untaxed': fields.function(
314+ _amount_all,
315+ digits_compute=dp.get_precision('Account'),
316+ string='Subtotal',
317+ track_visibility='always',
318+ store={
319+ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids,
320+ ['invoice_line'], 20),
321+ 'account.invoice.tax': (_get_invoice_tax, None, 20),
322+ 'account.invoice.line': (_get_invoice_line,
323+ ['price_unit',
324+ 'invoice_line_tax_id',
325+ 'quantity'
326+ 'discount',
327+ 'invoice_id'], 20),
328+ },
329+ multi='all'),
330+ 'amount_tax': fields.function(
331+ _amount_all,
332+ digits_compute=dp.get_precision('Account'),
333+ string='Tax',
334+ store={
335+ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids,
336+ ['invoice_line'], 20),
337+ 'account.invoice.tax': (_get_invoice_tax, None, 20),
338+ 'account.invoice.line': (_get_invoice_line,
339+ ['price_unit',
340+ 'invoice_line_tax_id',
341+ 'quantity',
342+ 'discount',
343+ 'invoice_id'], 20),
344+ },
345+ multi='all'),
346+ 'amount_total': fields.function(
347+ _amount_all,
348+ digits_compute=dp.get_precision('Account'),
349+ string='Total',
350+ store={
351+ 'account.invoice': (lambda self, cr, uid, ids, c={}: ids,
352+ ['invoice_line'], 20),
353+ 'account.invoice.tax': (_get_invoice_tax, None, 20),
354+ 'account.invoice.line': (_get_invoice_line,
355+ ['price_unit',
356+ 'invoice_line_tax_id',
357+ 'quantity',
358+ 'discount',
359+ 'invoice_id'], 20),
360+ },
361+ multi='all'),
362+ }
363+
364+
365+class AccountInvoiceLine(orm.Model):
366+ _inherit = 'account.invoice.line'
367+
368+ _columns = {
369+ 'is_rounding': fields.boolean('Rounding Line')
370+ }
371+
372+
373+class AccountTax(orm.Model):
374+ _inherit = 'account.tax'
375+
376+ def compute_inv(self, cr, uid, taxes, price_unit, quantity,
377+ product=None, partner=None, precision=None):
378+ """
379+ Using swedish rounding we want to keep standard global precision
380+ so we add precision to do global computation
381+
382+ """
383+ if taxes and taxes[0].company_id.tax_calculation_rounding_method[:7] == 'swedish':
384+ if not precision:
385+ precision = self.pool.get('decimal.precision').precision_get(
386+ cr, uid, 'Account')
387+ precision += 5
388+ return super(AccountTax, self
389+ ).compute_inv(cr, uid, taxes, price_unit,
390+ quantity, product=product,
391+ partner=partner, precision=precision)
392+
393+ def _compute(self, cr, uid, taxes, price_unit, quantity,
394+ product=None, partner=None, precision=None):
395+ """
396+ Using swedish rounding we want to keep standard global precision
397+ so we add precision to do global computation
398+
399+ """
400+ if taxes and taxes[0].company_id.tax_calculation_rounding_method[:7] == 'swedish':
401+ if not precision:
402+ precision = self.pool.get('decimal.precision'
403+ ).precision_get(cr, uid, 'Account')
404+ precision += 5
405+ return super(AccountTax, self
406+ )._compute(cr, uid, taxes, price_unit,
407+ quantity, product=product,
408+ partner=partner, precision=precision)
409
410=== added file 'account_invoice_rounding/company.py'
411--- account_invoice_rounding/company.py 1970-01-01 00:00:00 +0000
412+++ account_invoice_rounding/company.py 2014-02-24 15:21:21 +0000
413@@ -0,0 +1,52 @@
414+# -*- coding: utf-8 -*-
415+##############################################################################
416+#
417+# Author: Yannick Vaucher
418+# Copyright 2013 Camptocamp SA
419+#
420+# This program is free software: you can redistribute it and/or modify
421+# it under the terms of the GNU Affero General Public License as
422+# published by the Free Software Foundation, either version 3 of the
423+# License, or (at your option) any later version.
424+#
425+# This program is distributed in the hope that it will be useful,
426+# but WITHOUT ANY WARRANTY; without even the implied warranty of
427+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
428+# GNU Affero General Public License for more details.
429+#
430+# You should have received a copy of the GNU Affero General Public License
431+# along with this program. If not, see <http://www.gnu.org/licenses/>.
432+#
433+##############################################################################
434+from openerp.osv import orm, fields
435+
436+
437+class ResCompany(orm.Model):
438+ _inherit = 'res.company'
439+
440+ _columns = {
441+ 'tax_calculation_rounding': fields.float(
442+ 'Tax Rounding unit'),
443+ 'tax_calculation_rounding_method': fields.selection(
444+ [('round_per_line', 'Round per Line'),
445+ ('round_globally', 'Round Globally'),
446+ ('swedish_round_globally', 'Swedish Round globally'),
447+ ('swedish_add_invoice_line', 'Swedish Round by adding a line'),
448+ ],
449+ 'Tax Calculation Rounding Method',
450+ help="If you select 'Round per line' : for each tax, the tax "
451+ "amount will first be computed and rounded for each "
452+ "PO/SO/invoice line and then these rounded amounts will be "
453+ "summed, leading to the total amount for that tax. If you "
454+ "select 'Round globally': for each tax, the tax amount will "
455+ "be computed for each PO/SO/invoice line, then these amounts"
456+ " will be summed and eventually this total tax amount will "
457+ "be rounded. If you sell with tax included, you should "
458+ "choose 'Round per line' because you certainly want the sum "
459+ "of your tax-included line subtotals to be equal to the "
460+ "total amount with taxes."),
461+ 'tax_calculation_rounding_account_id': fields.many2one(
462+ 'account.account',
463+ 'Tax Rounding Account',
464+ domain=[('type', '<>', 'view')]),
465+ }
466
467=== added directory 'account_invoice_rounding/documentation'
468=== added file 'account_invoice_rounding/documentation/DOC_l10n_ch_5cts_roundings.ods'
469Binary files account_invoice_rounding/documentation/DOC_l10n_ch_5cts_roundings.ods 1970-01-01 00:00:00 +0000 and account_invoice_rounding/documentation/DOC_l10n_ch_5cts_roundings.ods 2014-02-24 15:21:21 +0000 differ
470=== added directory 'account_invoice_rounding/i18n'
471=== added file 'account_invoice_rounding/i18n/account_invoice_rounding.pot'
472--- account_invoice_rounding/i18n/account_invoice_rounding.pot 1970-01-01 00:00:00 +0000
473+++ account_invoice_rounding/i18n/account_invoice_rounding.pot 2014-02-24 15:21:21 +0000
474@@ -0,0 +1,74 @@
475+# Translation of OpenERP Server.
476+# This file contains the translation of the following modules:
477+# * account_invoice_rounding
478+#
479+msgid ""
480+msgstr ""
481+"Project-Id-Version: OpenERP Server 7.0\n"
482+"Report-Msgid-Bugs-To: \n"
483+"POT-Creation-Date: 2014-01-14 15:15+0000\n"
484+"PO-Revision-Date: 2014-01-14 15:15+0000\n"
485+"Last-Translator: <>\n"
486+"Language-Team: \n"
487+"MIME-Version: 1.0\n"
488+"Content-Type: text/plain; charset=UTF-8\n"
489+"Content-Transfer-Encoding: \n"
490+"Plural-Forms: \n"
491+
492+#. module: account_invoice_rounding
493+#: field:res.company,tax_calculation_rounding_account_id:0
494+msgid "Tax Rounding Account"
495+msgstr ""
496+
497+#. module: account_invoice_rounding
498+#: field:account.invoice,global_round_line_id:0
499+msgid "Invoice Line for total rounding"
500+msgstr ""
501+
502+#. module: account_invoice_rounding
503+#: model:ir.model,name:account_invoice_rounding.model_account_config_settings
504+msgid "account.config.settings"
505+msgstr ""
506+
507+#. module: account_invoice_rounding
508+#: code:addons/account_invoice_rounding/account.py:52
509+#, python-format
510+msgid "Rounding"
511+msgstr ""
512+
513+#. module: account_invoice_rounding
514+#: model:ir.model,name:account_invoice_rounding.model_res_company
515+msgid "Companies"
516+msgstr ""
517+
518+#. module: account_invoice_rounding
519+#: model:ir.model,name:account_invoice_rounding.model_account_invoice_line
520+msgid "Invoice Line"
521+msgstr ""
522+
523+#. module: account_invoice_rounding
524+#: field:account.config.settings,tax_calculation_rounding:0
525+#: field:res.company,tax_calculation_rounding:0
526+msgid "Tax Rounding unit"
527+msgstr ""
528+
529+#. module: account_invoice_rounding
530+#: field:account.invoice.line,is_rounding:0
531+msgid "Rounding Line"
532+msgstr ""
533+
534+#. module: account_invoice_rounding
535+#: model:ir.model,name:account_invoice_rounding.model_account_invoice
536+msgid "Invoice"
537+msgstr ""
538+
539+#. module: account_invoice_rounding
540+#: field:account.config.settings,tax_calculation_rounding_account_id:0
541+msgid "Tax Rounding account"
542+msgstr ""
543+
544+#. module: account_invoice_rounding
545+#: model:ir.model,name:account_invoice_rounding.model_account_tax
546+msgid "account.tax"
547+msgstr ""
548+
549
550=== added file 'account_invoice_rounding/res_config.py'
551--- account_invoice_rounding/res_config.py 1970-01-01 00:00:00 +0000
552+++ account_invoice_rounding/res_config.py 2014-02-24 15:21:21 +0000
553@@ -0,0 +1,77 @@
554+# -*- coding: utf-8 -*-
555+##############################################################################
556+#
557+# Author: Yannick Vaucher
558+# Copyright 2013 Camptocamp SA
559+#
560+# This program is free software: you can redistribute it and/or modify
561+# it under the terms of the GNU Affero General Public License as
562+# published by the Free Software Foundation, either version 3 of the
563+# License, or (at your option) any later version.
564+#
565+# This program is distributed in the hope that it will be useful,
566+# but WITHOUT ANY WARRANTY; without even the implied warranty of
567+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
568+# GNU Affero General Public License for more details.
569+#
570+# You should have received a copy of the GNU Affero General Public License
571+# along with this program. If not, see <http://www.gnu.org/licenses/>.
572+#
573+##############################################################################
574+from openerp.osv import orm, fields
575+
576+
577+class AccountConfigSettings(orm.TransientModel):
578+ _inherit = 'account.config.settings'
579+
580+ _columns = {
581+ 'tax_calculation_rounding': fields.related(
582+ 'company_id',
583+ 'tax_calculation_rounding',
584+ type='float',
585+ string='Tax Rounding unit'),
586+ 'tax_calculation_rounding_method': fields.related(
587+ 'company_id',
588+ 'tax_calculation_rounding_method',
589+ type='selection',
590+ selection=[
591+ ('round_per_line', 'Round per line'),
592+ ('round_globally', 'Round globally'),
593+ ('swedish_round_globally', 'Swedish Round globally'),
594+ ('swedish_add_invoice_line',
595+ 'Swedish Round by adding an invoice line'),
596+ ],
597+ string='Tax calculation rounding method',
598+ help="If you select 'Round per line' : for each tax, the tax "
599+ "amount will first be computed and rounded for each "
600+ "PO/SO/invoice line and then these rounded amounts will be "
601+ "summed, leading to the total amount for that tax. If you "
602+ "select 'Round globally': for each tax, the tax amount will "
603+ "be computed for each PO/SO/invoice line, then these amounts"
604+ " will be summed and eventually this total tax amount will "
605+ "be rounded. If you sell with tax included, you should "
606+ "choose 'Round per line' because you certainly want the sum "
607+ "of your tax-included line subtotals to be equal to the "
608+ "total amount with taxes."),
609+ 'tax_calculation_rounding_account_id': fields.related(
610+ 'company_id',
611+ 'tax_calculation_rounding_account_id',
612+ type='many2one',
613+ relation='account.account',
614+ string='Tax Rounding account',
615+ domain=[('type', '<>', 'view')]),
616+ }
617+
618+ _defaults = {
619+ 'tax_calculation_rounding': 0.05
620+ }
621+
622+ def onchange_company_id(self, cr, uid, ids, company_id, context=None):
623+ res = super(AccountConfigSettings, self
624+ ).onchange_company_id(cr, uid, ids,
625+ company_id, context=context)
626+ company = self.pool.get('res.company').browse(cr, uid, company_id,
627+ context=context)
628+ res['value']['tax_calculation_rounding'] = company.tax_calculation_rounding
629+ res['value']['tax_calculation_rounding_account_id'] = company.tax_calculation_rounding_account_id.id
630+ return res
631
632=== added file 'account_invoice_rounding/res_config_view.xml'
633--- account_invoice_rounding/res_config_view.xml 1970-01-01 00:00:00 +0000
634+++ account_invoice_rounding/res_config_view.xml 2014-02-24 15:21:21 +0000
635@@ -0,0 +1,26 @@
636+<?xml version="1.0" encoding="utf-8"?>
637+<openerp>
638+ <data>
639+
640+ <record id="view_account_config_settings" model="ir.ui.view">
641+ <field name="name">account settings.add.rounding</field>
642+ <field name="model">account.config.settings</field>
643+ <field name="inherit_id" ref="account.view_account_config_settings"/>
644+ <field name="arch" type="xml">
645+ <xpath expr="//field[@name='tax_calculation_rounding_method']/ancestor::div[1]" position="after">
646+ <div attrs="{'invisible': [('tax_calculation_rounding_method', 'not in', ['swedish_round_globally', 'swedish_add_invoice_line'])]}">
647+ <label for="tax_calculation_rounding"/>
648+ <field name="tax_calculation_rounding" class="oe_inline"/>
649+ </div>
650+ <div attrs="{'invisible': [('tax_calculation_rounding_method', '&lt;&gt;', 'swedish_add_invoice_line')]}">
651+ <label for="tax_calculation_rounding_account_id"/>
652+ <field name="tax_calculation_rounding_account_id"
653+ domain="[('type', '&lt;&gt;', 'view')]"
654+ attrs="{'required': [('tax_calculation_rounding_method', '=', 'swedish_add_invoice_line')]}" class="oe_inline"/>
655+ </div>
656+ </xpath>
657+ </field>
658+ </record>
659+
660+ </data>
661+</openerp>

Subscribers

People subscribed via source and target branches