Merge lp:~borjals/openobject-addons/5.0-bugfix-509204 into lp:openobject-addons/5.0

Proposed by Borja López Soilán (NeoPolus)
Status: Work in progress
Proposed branch: lp:~borjals/openobject-addons/5.0-bugfix-509204
Merge into: lp:openobject-addons/5.0
Diff against target: 80 lines (+21/-2)
5 files modified
account/account.py (+2/-0)
account/account_view.xml (+2/-0)
account/i18n/account.pot (+5/-0)
account/i18n/es_ES.po (+6/-1)
account/invoice.py (+6/-1)
To merge this branch: bzr merge lp:~borjals/openobject-addons/5.0-bugfix-509204
Reviewer Review Type Date Requested Status
Borja López Soilán (NeoPolus) (community) Needs Information
OpenERP Core Team Pending
Review via email: mp+25590@code.launchpad.net

Description of the change

Fixes the bug 509204 that is critical for some countries (like Spain; where it is a legal requirement having separate invoice and invoice refund sequences)

It adds a new field to the journals, to let the user specify a
different sequence for refund invoices (if he wants).

(The problem was that if no invoice sequence was specified for the
jornal, then OpenERP used automatically one invoice sequence or one
refund invoice sequence given the current invoice type.
But if an invoice sequence was defined for the jornal, OpenERP used it
always, for both the invoices and refunds.)

To post a comment you must log in.
Revision history for this message
Borja López Soilán (NeoPolus) (borjals) wrote :

Jordi Esteve wrote:
> No tengo claro que este merge que propones sea necesario, o sea añadir en los
> diarios una nueva secuencia para las facturas rectificativas, pues esta
> funcionalidad ya está implementada de serie en el módulo account.

Thanks for your review Jordi (even if it is in Spanish :) )

> Si debes usar 2 secuencias distintas, una para facturas normales y otra para
> las rectificativas, puedes definir dos diarios distintos, cada uno con su
> secuencia distinta, los dos diarios de tipo Venta, y en uno marcas la casilla
> Diario de reintegro y en el otro no. Lo mismo haríamos definiendo 2 diarios
> de tipo Compra, uno con la casilla Diario de reintegro marcada y en el otro
> no y cada uno con secuencias distintas. Creo que lo probé y funcionaba.

If you take a look at the bug report you will see a note about that: I know that if you can set a journal as "refund journal". But when you create refund invoices from normal invoices (you select an invoice you wish to refund, and use the Credit Note ("Factura de abono" on Spanish), the refund invoices are created on the same journal as the original invoice (if the original invoice was on the Sales Journal, the new invoice is on the Sales Journal too). That's why I proposed having the option to set the sequence to use for this kind of "refund invoices on the same journal".

Another option I can propose, is having the "Credit Note" (account.invoice.refund) wizard search for the "refund journal" of the same type of the current one (so if you have a Sales Journal, it should use the Sales Refunds Journal for the created invoices).

> Por tanto es posible q te denieguen el merge. No lo
> explico en inglés pq voy muy escaso de tiempo, ya lo probarás y lo comentarás.
> PD: La otra propuesta de merge si me parece muy acertada.
>
> Jordi

Ok, I marked this Merge status as "Work in progress" just to wait until somebody else puts his two cents :)

Should I propose the other option too?

review: Needs Information
Revision history for this message
Jordi Esteve (www.zikzakmedia.com) (jesteve-zikzakmedia) wrote :

Thanks for your explanation, Borja, now I see better the real problem:

When you create refund invoices from normal invoices (you select an invoice you wish to refund, and use the Credit Note wizard), the refund invoices are created on the same journal as the original invoice, instead of the refund journal, so they cannot take into account a different invoice sequence.

Maybe the second solution, the "Credit Note" (account.invoice.refund) wizard must search for the "refund journal" of the same type of the current one (sale -> sale refund, purchase -> purchase refund) is better as it does not affect the kernel of account module. IMHO the current "Credit Note" wizard has a bug if it cannot select the proper "refund" journal.

Unmerged revisions

2739. By Borja López Soilán (NeoPolus)

[FIX] account: Refund invoices didn't support sequences by fiscal year

  It was not possible to use a sequence by fiscal year for the invoices,
  and a different sequence by fiscal year for the refund invoices.

  This is a legal requirement on some countries (like Spain).

  The problem was that if no invoice sequence was specified for the
  jornal, then OpenERP used automatically one invoice sequence or one
  refund invoice sequence given the current invoice type.
  But if an invoice sequence was defined for the jornal, OpenERP used it
  always, for both the invoices and refunds.

  This fix adds a new field to the journals, to let the user specify a
  different sequence for refund invoices (if he wants).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account.py'
2--- account/account.py 2010-04-29 09:49:15 +0000
3+++ account/account.py 2010-05-19 08:32:27 +0000
4@@ -537,6 +537,8 @@
5 'company_id': fields.related('default_credit_account_id','company_id',type='many2one', relation="res.company", string="Company"),
6 'invoice_sequence_id': fields.many2one('ir.sequence', 'Invoice Sequence', \
7 help="The sequence used for invoice numbers in this journal."),
8+ 'refund_sequence_id': fields.many2one('ir.sequence', 'Refund Sequence', \
9+ help="The sequence used for refund invoice numbers in this journal."),
10 }
11
12 _defaults = {
13
14=== modified file 'account/account_view.xml'
15--- account/account_view.xml 2010-04-05 08:57:54 +0000
16+++ account/account_view.xml 2010-05-19 08:32:27 +0000
17@@ -263,7 +263,9 @@
18 <field name="view_id"/>
19 <field name="currency"/>
20 <field name="sequence_id"/>
21+ <newline/>
22 <field name="invoice_sequence_id"/>
23+ <field name="refund_sequence_id"/>
24 <field name="default_debit_account_id" attrs="{'required':[('type','=','cash')]}" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
25 <field name="default_credit_account_id" attrs="{'required':[('type','=','cash')]}" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
26 <field name="user_id" groups="base.group_extended"/>
27
28=== modified file 'account/i18n/account.pot'
29--- account/i18n/account.pot 2010-05-05 14:48:06 +0000
30+++ account/i18n/account.pot 2010-05-19 08:32:27 +0000
31@@ -2354,6 +2354,11 @@
32 msgstr ""
33
34 #. module: account
35+#: field:account.journal,refund_sequence_id:0
36+msgid "Refund Inv. Sequence"
37+msgstr ""
38+
39+#. module: account
40 #: wizard_view:account.automatic.reconcile,init:0
41 msgid "Options"
42 msgstr ""
43
44=== modified file 'account/i18n/es_ES.po'
45--- account/i18n/es_ES.po 2010-05-05 14:48:06 +0000
46+++ account/i18n/es_ES.po 2010-05-19 08:32:27 +0000
47@@ -2351,7 +2351,12 @@
48 #. module: account
49 #: field:account.journal,invoice_sequence_id:0
50 msgid "Invoice Sequence"
51-msgstr "factura de secuencia"
52+msgstr "Secuencia de factura"
53+
54+#. module: account
55+#: field:account.journal,refund_sequence_id:0
56+msgid "Refund Inv. Sequence"
57+msgstr "Secuencia de fact. rect."
58
59 #. module: account
60 #: wizard_view:account.automatic.reconcile,init:0
61
62=== modified file 'account/invoice.py'
63--- account/invoice.py 2010-04-30 11:20:11 +0000
64+++ account/invoice.py 2010-05-19 08:32:27 +0000
65@@ -744,9 +744,14 @@
66 obj_inv = self.browse(cr, uid, ids)[0]
67 for (id, invtype, number, move_id, reference) in cr.fetchall():
68 if not number:
69- if obj_inv.journal_id.invoice_sequence_id:
70+ if invtype in ('in_invoice', 'out_invoice') \
71+ and obj_inv.journal_id.invoice_sequence_id:
72 sid = obj_inv.journal_id.invoice_sequence_id.id
73 number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id=%s', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id})
74+ elif invtype in ('in_refund', 'out_refund') \
75+ and obj_inv.journal_id.refund_sequence_id:
76+ sid = obj_inv.journal_id.refund_sequence_id.id
77+ number = self.pool.get('ir.sequence').get_id(cr, uid, sid, 'id=%s', {'fiscalyear_id': obj_inv.period_id.fiscalyear_id.id})
78 else:
79 number = self.pool.get('ir.sequence').get(cr, uid,
80 'account.invoice.' + invtype)