[FIX] sale: another way to fix the batch invoicing of sale.order that currently create invoices in double
bzr revid: qdp-launchpad@openerp.com-20130320104853-odqz2m966igg5ept
This commit is contained in:
parent
d4c87342fb
commit
d90170fae5
|
@ -20,7 +20,6 @@
|
|||
|
||||
from openerp.osv import fields, osv
|
||||
from openerp.tools.translate import _
|
||||
from openerp import netsvc
|
||||
|
||||
class sale_make_invoice(osv.osv_memory):
|
||||
_name = "sale.make.invoice"
|
||||
|
@ -40,7 +39,7 @@ class sale_make_invoice(osv.osv_memory):
|
|||
record_id = context and context.get('active_id', False)
|
||||
order = self.pool.get('sale.order').browse(cr, uid, record_id, context=context)
|
||||
if order.state == 'draft':
|
||||
raise osv.except_osv(_('Warning!'),'You cannot create invoice when sales order is not confirmed.')
|
||||
raise osv.except_osv(_('Warning!'), 'You cannot create invoice when sales order is not confirmed.')
|
||||
return False
|
||||
|
||||
def make_invoices(self, cr, uid, ids, context=None):
|
||||
|
@ -51,9 +50,11 @@ class sale_make_invoice(osv.osv_memory):
|
|||
if context is None:
|
||||
context = {}
|
||||
data = self.read(cr, uid, ids)[0]
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for id in context.get(('active_ids'), []):
|
||||
wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr)
|
||||
for sale_order in context.get(('active_ids'), []):
|
||||
if sale_order.state != 'manual':
|
||||
raise osv.except_osv(_('Warning!'), "You shouldn't manually invoice the following sale order %s" % (sale_order.name))
|
||||
|
||||
order_obj.action_invoice_create(cr, uid, context.get(('active_ids'), []), data['grouped'], date_invoice=data['invoice_date'])
|
||||
|
||||
for o in order_obj.browse(cr, uid, context.get(('active_ids'), []), context=context):
|
||||
for i in o.invoice_ids:
|
||||
|
@ -62,7 +63,7 @@ class sale_make_invoice(osv.osv_memory):
|
|||
result = mod_obj.get_object_reference(cr, uid, 'account', 'action_invoice_tree1')
|
||||
id = result and result[1] or False
|
||||
result = act_obj.read(cr, uid, [id], context=context)[0]
|
||||
result['domain'] = "[('id','in', ["+','.join(map(str,newinv))+"])]"
|
||||
result['domain'] = "[('id','in', [" + ','.join(map(str, newinv)) + "])]"
|
||||
|
||||
return result
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<form string="Create invoices" version="7.0">
|
||||
<separator colspan="4" string="Do you really want to create the invoice(s)?" />
|
||||
<group>
|
||||
<field name="grouped"/>
|
||||
<field name="invoice_date"/>
|
||||
</group>
|
||||
<footer>
|
||||
|
|
Loading…
Reference in New Issue