[IMP] sale: Added buttons to see invoice and delivery order on sale order from
bzr revid: psi@tinyerp.com-20120306050847-bbrjq8qrcxehom99
This commit is contained in:
parent
16bfaa6fce
commit
876cac5546
|
@ -513,6 +513,65 @@ class sale_order(osv.osv):
|
|||
'res_id': inv_ids and inv_ids[0] or False,
|
||||
}
|
||||
|
||||
def action_view_invoice(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
inv_ids = []
|
||||
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,
|
||||
}
|
||||
|
||||
def action_view_delivery(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
pick_ids = []
|
||||
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_search')
|
||||
res_id = res and res[1] or False,
|
||||
return {
|
||||
'name': _('Delivery Order'),
|
||||
'view_type': 'search',
|
||||
'view_mode': 'search',
|
||||
'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:
|
||||
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,
|
||||
}
|
||||
|
||||
def action_invoice_create(self, cr, uid, ids, grouped=False, states=['confirmed', 'done', 'exception'], date_inv = False, context=None):
|
||||
res = False
|
||||
invoices = {}
|
||||
|
@ -675,11 +734,8 @@ class sale_order(osv.osv):
|
|||
template_id = self.pool.get('email.template').search(cr, uid, [('model_id', '=', 'sale.order')], context=context)
|
||||
model_data_ids = mod_obj.search(cr, uid, [('model','=','ir.ui.view'),('name','=','email_compose_message_wizard_form')], context=context)
|
||||
resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
||||
#EDI EXport data
|
||||
# if not self.browse(cr, uid, id, context).partner_id.opt_out:
|
||||
# order.edi_export_and_email(template_ext_id='sale.email_template_edi_sale', context=context)
|
||||
ctx = context.copy()
|
||||
ctx.update({'active_model': 'sale.order', 'active_id': id[0], 'mail.compose.template_id': template_id})
|
||||
ctx.update({'active_model': 'sale.order', 'active_id': ids[0], 'mail.compose.template_id': template_id})
|
||||
return {
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
|
|
|
@ -210,6 +210,8 @@
|
|||
<button name="action_cancel_draft" states="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"/><!-- attrs="{'invisible': ['|', ('order_policy','!=','prepaid'), '|', ('state','!=', 'manual'), ('invoiced','!=',True) ]}"/-->
|
||||
<button name="action_view_delivery" string="Open Delivery Order" icon="gtk-go-forward" type="object"/><!-- attrs="{'invisible': ['|', ('invoiced','=',True), ('state','!=', 'progress')]}"/-->
|
||||
<button name="cancel" states="draft,sent" string="Cancel Order" icon="gtk-cancel"/>
|
||||
<button name="action_cancel" states="manual,progress" string="Cancel Order" type="object" icon="gtk-cancel"/>
|
||||
<button name="ship_cancel" states="shipping_except" string="Cancel Order" icon="gtk-cancel"/>
|
||||
|
|
Loading…
Reference in New Issue