[FIX] l10n_ch : Invoices were not being referenced properly when using Import BVR...
[odoo/odoo.git] / addons / l10n_ch / wizard / bvr_import.py
index 4c3a6e0..c2476bb 100644 (file)
@@ -167,6 +167,7 @@ def _import(self, cursor, user, data, context=None):
 #                    line2reconcile = line.id
                     account_id = line.account_id.id
                     break
+        context.update({'move_line_ids': line_ids})
         result = voucher_obj.onchange_partner_id(cursor, user, [], partner_id, journal_id=statement.journal_id.id, price=abs(record['amount']), currency_id= statement.currency.id, ttype='receipt', date=statement.date ,context=context)
         voucher_res = { 'type': 'receipt' ,
 
@@ -181,18 +182,16 @@ def _import(self, cursor, user, data, context=None):
             'period_id': statement.period_id.id
              }
         voucher_id = voucher_obj.create(cursor, user, voucher_res, context=context)
-        ctx = context.copy()
-        ctx.update({'move_line_ids': line_ids})
         values['voucher_id'] = voucher_id
         voucher_line_dict =  False
         if result['value']['line_ids']:
              for line_dict in result['value']['line_ids']:
-                 move_line = move_line_obj.browse(cursor, user, line_dict['move_line_id'], context=ctx)
+                 move_line = move_line_obj.browse(cursor, user, line_dict['move_line_id'], context)
                  if move_id == move_line.move_id.id:
                      voucher_line_dict = line_dict
         if voucher_line_dict:
              voucher_line_dict.update({'voucher_id':voucher_id})
-             voucher_line_obj.create(cursor, user, voucher_line_dict, context=ctx)                
+             voucher_line_obj.create(cursor, user, voucher_line_dict, context=context)                
              
         if not account_id:
             if record['amount'] >= 0:
@@ -225,7 +224,7 @@ def _import(self, cursor, user, data, context=None):
                 _('The properties account payable account receivable are not set'))
         values['account_id'] = account_id
         values['partner_id'] = partner_id
-        statement_line_obj.create(cursor, user, values, context=ctx)
+        statement_line_obj.create(cursor, user, values, context=context)
     attachment_obj.create(cursor, user, {
         'name': 'BVR',
         'datas': file,