@@ -244,6 +244,21 @@ def _calculate_debts(self, from_date, to_date, groupby=None):
244
244
245
245
return deuda
246
246
247
+ def _search_last_journal_for_partner (self , partner , debt ):
248
+ journal = self .env ['account.move' ].with_context (
249
+ internal_type = 'debit_note' ,
250
+ default_move_type = 'out_invoice'
251
+ ).new ({
252
+ 'partner_id' : partner .id ,
253
+ 'move_type' : 'out_invoice' ,
254
+ 'company_id' :self .company_id .id
255
+ }).journal_id
256
+
257
+ if self .receivable_account_ids != journal .default_account_id :
258
+ journal = self .env ['account.journal' ].search ([('default_account_id' ,'in' ,self .receivable_account_ids .ids )], limit = 1 ) or journal
259
+
260
+ return journal
261
+
247
262
def create_invoices (self , from_date , to_date ):
248
263
"""
249
264
Crea facturas de intereses a cada partner basadas en los cálculos de deuda.
@@ -261,6 +276,7 @@ def create_invoices(self, from_date, to_date):
261
276
# Calcular deudas e intereses
262
277
deuda = self ._calculate_debts (from_date , to_date )
263
278
279
+ < << << << HEAD
264
280
journal = self .env ["account.journal" ].search (
265
281
[("type" , "=" , "sale" ), ("company_id" , "=" , self .company_id .id )], limit = 1
266
282
)
@@ -278,11 +294,20 @@ def create_invoices(self, from_date, to_date):
278
294
if self .domain :
279
295
move_line_domain += safe_eval (self .domain )
280
296
297
+ | | | | | | | parent of 6 b679d21 (temp )
298
+ journal = self .env ['account.journal' ].search ([
299
+ ('type' , '=' , 'sale' ),
300
+ ('company_id' , '=' , self .company_id .id )], limit = 1 )
301
+
302
+ == == == =
303
+ >> >> >> > 6 b679d21 (temp )
281
304
total_items = len (deuda )
282
305
_logger .info ("%s interest invoices will be generated" , total_items )
283
306
284
307
# Crear facturas
285
308
for idx , partner in enumerate (deuda ):
309
+ journal = self ._search_last_journal_for_partner (partner ,deuda [partner ])
310
+
286
311
move_vals = self ._prepare_interest_invoice (partner , deuda [partner ], to_date , journal )
287
312
if not move_vals :
288
313
continue
0 commit comments