[IMP] sale: improve the logic of open invoice and open delivery oder so they will work for multiple invoices and delivery orders, added set to draft button in sent state
bzr revid: psi@tinyerp.com-20120319052715-n7nga0ky12mwwtya
This commit is contained in:
parent
b16de17c74
commit
c55193994d
|
@ -516,60 +516,65 @@ class sale_order(osv.osv):
|
|||
def action_view_invoice(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
inv_ids = []
|
||||
result = {}
|
||||
for so in self.browse(cr, uid, ids, context=context):
|
||||
inv_ids+= [invoice.id for invoice in so.invoice_ids]
|
||||
|
||||
res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
|
||||
res_id = res and res[1] or False
|
||||
|
||||
return {
|
||||
'name': _('Customer Invoices'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'view_id': [res_id],
|
||||
'res_model': 'account.invoice',
|
||||
'context': "{'type':'out_invoice', 'journal_type': 'sale'}",
|
||||
'type': 'ir.actions.act_window',
|
||||
'nodestroy': True,
|
||||
'target': 'current',
|
||||
'res_id': inv_ids and inv_ids[0] or False,
|
||||
}
|
||||
if len(inv_ids)>1:
|
||||
res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_tree')
|
||||
result.update({
|
||||
'view_mode': 'tree,form',
|
||||
'res_id': inv_ids or False
|
||||
})
|
||||
else:
|
||||
res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_form')
|
||||
result.update({
|
||||
'view_mode': 'form',
|
||||
'res_id': inv_ids and inv_ids[0] or False,
|
||||
})
|
||||
res_id = res and res[1] or False,
|
||||
result.update({
|
||||
'name': _('Cutomer Invoice'),
|
||||
'view_type': 'form',
|
||||
'view_id': [res_id],
|
||||
'res_model': 'account.invoice',
|
||||
'context': "{'type':'out_invoice', 'journal_type': 'sale'}",
|
||||
'type': 'ir.actions.act_window',
|
||||
'nodestroy': True,
|
||||
'target': 'current',
|
||||
})
|
||||
return result
|
||||
|
||||
|
||||
def action_view_delivery(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
pick_ids = []
|
||||
result = {}
|
||||
for so in self.browse(cr, uid, ids, context=context):
|
||||
pick_ids += [picking.id for picking in so.picking_ids]
|
||||
if len(pick_ids) > 1:
|
||||
res = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_out_tree')
|
||||
res_id = res and res[1] or False,
|
||||
return {
|
||||
'name': _('Delivery Order'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree',
|
||||
'view_id': res_id,
|
||||
'res_model': 'stock.picking',
|
||||
'context': "{'type':'out'}",
|
||||
'type': 'ir.actions.act_window',
|
||||
'nodestroy': True,
|
||||
'target': 'current',
|
||||
'res_id': pick_ids or False,
|
||||
}
|
||||
else:
|
||||
result.update({
|
||||
'view_mode': 'tree,form',
|
||||
'res_id': pick_ids or False
|
||||
})
|
||||
else:
|
||||
res = mod_obj.get_object_reference(cr, uid, 'stock', 'view_picking_out_form')
|
||||
res_id = res and res[1] or False,
|
||||
return {
|
||||
'name': _('Delivery Order'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'view_id': res_id,
|
||||
'res_model': 'stock.picking',
|
||||
'context': "{'type':'out'}",
|
||||
'type': 'ir.actions.act_window',
|
||||
'nodestroy': True,
|
||||
'target': 'current',
|
||||
'res_id': pick_ids and pick_ids[0] or False,
|
||||
}
|
||||
result.update({
|
||||
'view_mode': 'form',
|
||||
'res_id': pick_ids and pick_ids[0] or False,
|
||||
})
|
||||
res_id = res and res[1] or False,
|
||||
result.update({
|
||||
'name': _('Delivery Order'),
|
||||
'view_type': 'form',
|
||||
'view_id': res_id,
|
||||
'res_model': 'stock.picking',
|
||||
'context': "{'type':'out'}",
|
||||
'type': 'ir.actions.act_window',
|
||||
'nodestroy': True,
|
||||
'target': 'current',
|
||||
})
|
||||
return result
|
||||
|
||||
def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
|
||||
res = False
|
||||
|
|
|
@ -203,11 +203,11 @@
|
|||
<field name="state" widget="statusbar" statusbar_visible="draft,sent,progress,invoiced,done" statusbar_colors='{"shipping_except":"red","invoice_except":"red","waiting_date":"blue"}'/>
|
||||
<button name="invoice_recreate" states="invoice_except" string="Recreate Invoice" icon="gtk-go-forward"/>
|
||||
<button name="invoice_corrected" states="invoice_except" string="Ignore Exception" icon="gtk-apply"/>
|
||||
<button name="ship_recreate" states="shipping_except" string="Recreate Packing" icon="gtk-ok"/>
|
||||
<button name="ship_recreate" states="shipping_except" string="Recreate Delivery Order" icon="gtk-ok"/>
|
||||
<button name="ship_corrected" states="shipping_except" string="Ignore Exception" icon="gtk-apply"/>
|
||||
<button name="action_quotation_sent" string="Send" type="object" icon="terp-mail-message-new" states="draft"/>
|
||||
<button name="manual_invoice" states="manual" string="Create Final Invoice" icon="gtk-go-forward" type="object"/>
|
||||
<button name="action_cancel_draft" states="cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
|
||||
<button name="action_cancel_draft" states="sent,cancel" string="Set to Draft" type="object" icon="gtk-convert"/>
|
||||
<button name="print_quotation" string="Print Quotation" type="object" icon="gtk-print" states="draft"/>
|
||||
<button name="order_confirm" states="draft,sent" string="Confirm Order" icon="gtk-apply"/>
|
||||
<button name="action_view_invoice" string="Open Invoice" icon="gtk-go-forward" type="object"
|
||||
|
|
Loading…
Reference in New Issue