Skip to content

Commit bba327c

Browse files
committed
ADD dates to refund
1 parent 5c29395 commit bba327c

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

l10n_ar_invoice/wizard/account_invoice_refund.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ def _onchange_invoice(self):
3535
# self.journal_type = journal_type
3636

3737
point_of_sale = self.invoice_id.journal_id.point_of_sale_id
38-
print 'point_of_sale', point_of_sale
3938
if point_of_sale:
4039
journal = self.env['account.journal'].search(
4140
[('type', '=', journal_type),
4241
('company_id', '=', self.invoice_id.company_id.id),
4342
('point_of_sale_id', '=', point_of_sale.id),
4443
], limit=1)
45-
print 'journal', journal
4644
if not journal and journals:
4745
journal = journals[0]
4846
if journal:
@@ -65,23 +63,30 @@ def compute_refund(self, cr, uid, ids, data_refund, context=None):
6563
invoice_ids = context.get('active_ids', [])
6664
if not invoice_ids:
6765
return res
68-
sale_order_ids = self.pool['sale.order'].search(
69-
cr, uid, [('invoice_ids', 'in', invoice_ids)])
7066
invoice_obj = self.pool['account.invoice']
7167
refund_invoice_ids = invoice_obj.search(cr, uid, domain)
7268
origin = ', '.join([x.number for x in invoice_obj.browse(
7369
cr, uid, invoice_ids) if x.number])
70+
# add origin date from and date to
71+
# get first invoice
72+
invoice = invoice_obj.browse(cr, uid, invoice_ids, context=context)[0]
7473
invoice_obj.write(cr, uid, refund_invoice_ids, {
7574
'origin': origin,
75+
'afip_service_start': invoice.afip_service_start,
76+
'afip_service_end': invoice.afip_service_end,
7677
})
7778
if not self.browse(cr, uid, ids, context=context)[0].period:
7879
invoice_obj.write(cr, uid, refund_invoice_ids, {
7980
'period_id': invoice_obj.browse(
8081
cr, uid, invoice_ids)[0].period_id.id
8182
})
82-
for invoice_id in refund_invoice_ids:
83-
self.pool['sale.order'].write(
84-
cr, uid, sale_order_ids, {'invoice_ids': [(4, invoice_id)]})
83+
if self.pool.get('sale.order'):
84+
sale_order_ids = self.pool['sale.order'].search(
85+
cr, uid, [('invoice_ids', 'in', invoice_ids)])
86+
for invoice_id in refund_invoice_ids:
87+
self.pool['sale.order'].write(
88+
cr, uid, sale_order_ids,
89+
{'invoice_ids': [(4, invoice_id)]})
8590
return res
8691

8792
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

0 commit comments

Comments
 (0)