@@ -35,14 +35,12 @@ def _onchange_invoice(self):
35
35
# self.journal_type = journal_type
36
36
37
37
point_of_sale = self .invoice_id .journal_id .point_of_sale_id
38
- print 'point_of_sale' , point_of_sale
39
38
if point_of_sale :
40
39
journal = self .env ['account.journal' ].search (
41
40
[('type' , '=' , journal_type ),
42
41
('company_id' , '=' , self .invoice_id .company_id .id ),
43
42
('point_of_sale_id' , '=' , point_of_sale .id ),
44
43
], limit = 1 )
45
- print 'journal' , journal
46
44
if not journal and journals :
47
45
journal = journals [0 ]
48
46
if journal :
@@ -65,23 +63,30 @@ def compute_refund(self, cr, uid, ids, data_refund, context=None):
65
63
invoice_ids = context .get ('active_ids' , [])
66
64
if not invoice_ids :
67
65
return res
68
- sale_order_ids = self .pool ['sale.order' ].search (
69
- cr , uid , [('invoice_ids' , 'in' , invoice_ids )])
70
66
invoice_obj = self .pool ['account.invoice' ]
71
67
refund_invoice_ids = invoice_obj .search (cr , uid , domain )
72
68
origin = ', ' .join ([x .number for x in invoice_obj .browse (
73
69
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 ]
74
73
invoice_obj .write (cr , uid , refund_invoice_ids , {
75
74
'origin' : origin ,
75
+ 'afip_service_start' : invoice .afip_service_start ,
76
+ 'afip_service_end' : invoice .afip_service_end ,
76
77
})
77
78
if not self .browse (cr , uid , ids , context = context )[0 ].period :
78
79
invoice_obj .write (cr , uid , refund_invoice_ids , {
79
80
'period_id' : invoice_obj .browse (
80
81
cr , uid , invoice_ids )[0 ].period_id .id
81
82
})
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 )]})
85
90
return res
86
91
87
92
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0 commit comments