← Back to team overview

openobject-italia-core-devs team mailing list archive

[Merge] lp:~icsergio/openobject-italia/61_fix_date_invoice_check into lp:openobject-italia/6.1

 

Sergio Corato has proposed merging lp:~icsergio/openobject-italia/61_fix_date_invoice_check into lp:openobject-italia/6.1.

Requested reviews:
  OpenERP Italia core devs (openobject-italia-core-devs)

For more details, see:
https://code.launchpad.net/~icsergio/openobject-italia/61_fix_date_invoice_check/+merge/196993

Registration data of supplier' invoices is checked only on the current period: with this branch it'll be checked on all the periods belonging to the relative fy.
-- 
https://code.launchpad.net/~icsergio/openobject-italia/61_fix_date_invoice_check/+merge/196993
Your team OpenERP Italia core devs is requested to review the proposed merge of lp:~icsergio/openobject-italia/61_fix_date_invoice_check into lp:openobject-italia/6.1.
=== modified file 'l10n_it_account/AUTHORS.txt'
--- l10n_it_account/AUTHORS.txt	2013-05-07 12:26:04 +0000
+++ l10n_it_account/AUTHORS.txt	2013-11-27 23:29:50 +0000
@@ -1,3 +1,4 @@
+Sergio Corato <sergio.corato@xxxxxxxxxxxx>
 Davide Corio <davide.corio@xxxxxxxxxxxx>
 Luca Subiaco <subluca@xxxxxxxxx>
 Simone Orsi <simone.orsi@xxxxxxxxxxxx>

=== modified file 'l10n_it_account/__openerp__.py'
--- l10n_it_account/__openerp__.py	2013-09-05 22:04:55 +0000
+++ l10n_it_account/__openerp__.py	2013-11-27 23:29:50 +0000
@@ -20,7 +20,7 @@
 ##############################################################################
 {
     'name': 'Italian Localisation - Account',
-    'version': '0.1',
+    'version': '0.2',
     'category': 'Localisation/Italy',
     'description': """This module customizes OpenERP in order to fit italian laws and mores - Account version
 

=== modified file 'l10n_it_account/account/invoice.py'
--- l10n_it_account/account/invoice.py	2013-09-10 11:39:49 +0000
+++ l10n_it_account/account/invoice.py	2013-11-27 23:29:50 +0000
@@ -40,22 +40,20 @@
             date_invoice = obj_inv.date_invoice
             reg_date = obj_inv.registration_date
             journal = obj_inv.journal_id.id
-            date_start = obj_inv.registration_date or obj_inv.date_invoice or time.strftime('%Y-%m-%d')
-            date_stop = obj_inv.registration_date or obj_inv.date_invoice or time.strftime('%Y-%m-%d')
+            fy_id = obj_inv.period_id.fiscalyear_id.id
             period_ids = self.pool.get('account.period').search(
-                cr, uid, [('date_start','<=',date_start),('date_stop','>=',date_stop), 
-                ('company_id', '=', obj_inv.company_id.id)])
+                cr, uid, [('fiscalyear_id', '=', fy_id), ('company_id', '=', obj_inv.company_id.id)])
             if inv_type == 'out_invoice' or inv_type == 'out_refund':
-                #check if another invoice with a minor number and a superior date_invoice is posted
                 res = self.search(cr, uid, [('type','=',inv_type),('date_invoice','>',date_invoice), 
-                    ('number', '<', number), ('journal_id','=',journal),('period_id','in',period_ids)])
+                                            ('number', '<', number), ('journal_id', '=', journal),
+                                            ('period_id', 'in', period_ids)])
                 if res:
                     raise orm.except_orm(_('Date Inconsistency'),
                             _('Cannot create invoice! Post the invoice with a greater date'))
             if inv_type == 'in_invoice' or inv_type == 'in_refund':
-                #check if an invoice with a superior registration_date is posted
                 res = self.search(cr, uid, [('type','=',inv_type),('registration_date','>',reg_date), 
-                    ('journal_id','=',journal),('period_id','in',period_ids)], context=context)
+                                            ('number', '<', number), ('journal_id', '=', journal),
+                                            ('period_id', 'in', period_ids)], context=context)
                 if res:
                     raise orm.except_orm(_('Date Inconsistency'),
                         _('Cannot create invoice! Post the invoice with a greater date'))
@@ -63,8 +61,10 @@
                 supplier_invoice_number = obj_inv.supplier_invoice_number
                 partner_id = obj_inv.partner_id.id
                 res = self.search(cr, uid, [('type','=',inv_type),('date_invoice','=',date_invoice), 
-                    ('journal_id','=',journal),('supplier_invoice_number','=',supplier_invoice_number),
-                    ('partner_id','=',partner_id),('state','not in',('draft','cancel'))], context=context)
+                                            ('journal_id', '=', journal),
+                                            ('supplier_invoice_number', '=', supplier_invoice_number),
+                                            ('partner_id', '=', partner_id),
+                                            ('state', 'not in', ('draft', 'cancel'))], context=context)
                 if res:
                     raise orm.except_orm(_('Invoice Duplication'),
                         _('Invoice already posted!'))


Follow ups