[FIX]: Open invoice view directly from incomming shipment wizard
bzr revid: atp@tinyerp.com-20121107113316-9gl01qojb32bmex6
This commit is contained in:
parent
3e26548929
commit
04cdfb2cd5
|
@ -127,6 +127,54 @@ class stock_partial_picking(osv.osv_memory):
|
|||
'currency': move.picking_id.purchase_id.pricelist_id.currency_id.id}
|
||||
return super(stock_partial_picking, self)._product_cost_for_average_update(cr, uid, move)
|
||||
|
||||
|
||||
def create_invoice(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
picking_pool = self.pool.get('stock.picking')
|
||||
active_ids = context.get('active_ids', [])
|
||||
active_picking = picking_pool.browse(cr, uid, context.get('active_id',False), context=context)
|
||||
inv_type = picking_pool._get_invoice_type(active_picking)
|
||||
context['inv_type'] = inv_type
|
||||
res = picking_pool.action_invoice_create(cr, uid, active_ids,
|
||||
type = inv_type,
|
||||
context=context)
|
||||
return res
|
||||
|
||||
def open_invoice(self, cr, uid, ids, context=None):
|
||||
"""Launch Create invoice wizard.
|
||||
"""
|
||||
if context is None: context = {}
|
||||
data_pool = self.pool.get('ir.model.data')
|
||||
result = self.do_partial(cr, uid, ids, context=context)
|
||||
partial = self.browse(cr, uid, ids[0], context=context)
|
||||
context.update(active_model='stock.picking',
|
||||
active_ids=[partial.picking_id.id])
|
||||
if partial.picking_id.invoice_state == '2binvoiced':
|
||||
invoice_ids = []
|
||||
res = self.create_invoice(cr, uid, ids, context=context)
|
||||
invoice_ids += res.values()
|
||||
inv_type = context.get('inv_type', False)
|
||||
action_model = False
|
||||
action = {}
|
||||
if not invoice_ids:
|
||||
raise osv.except_osv(_('Error!'), _('Please create Invoices.'))
|
||||
if inv_type == "out_invoice":
|
||||
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree1")
|
||||
elif inv_type == "in_invoice":
|
||||
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree2")
|
||||
elif inv_type == "out_refund":
|
||||
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree3")
|
||||
elif inv_type == "in_refund":
|
||||
action_model,action_id = data_pool.get_object_reference(cr, uid, 'account', "action_invoice_tree4")
|
||||
if action_model:
|
||||
action_pool = self.pool.get(action_model)
|
||||
action = action_pool.read(cr, uid, action_id, context=context)
|
||||
action['domain'] = "[('id','in', ["+','.join(map(str,invoice_ids))+"])]"
|
||||
return action
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
|
||||
# Redefinition of the new field in order to update the model stock.picking.in in the orm
|
||||
# FIXME: this is a temporary workaround because of a framework bug (ref: lp996816). It should be removed as soon as
|
||||
# the bug is fixed
|
||||
|
|
|
@ -37,6 +37,18 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<!-- inherit view of stock.partial.picking wizard -->
|
||||
<record id="stock_partial_picking_form_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.partial.picking.form.inherit</field>
|
||||
<field name="model">stock.partial.picking</field>
|
||||
<field name="inherit_id" ref="stock.stock_partial_picking_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='do_partial']" position="after">
|
||||
<button name="open_invoice" string="Receive & Control Invoice" type="object" class="oe_highlight" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- is it need ? we have another method "Receive Products"-->
|
||||
<record id="purchase_order_2_stock_picking" model="ir.ui.view">
|
||||
<field name="name">Purchase Picking Inherited</field>
|
||||
|
|
|
@ -154,26 +154,6 @@ class stock_partial_picking(osv.osv_memory):
|
|||
partial_move.update(update_cost=True, **self._product_cost_for_average_update(cr, uid, move))
|
||||
return partial_move
|
||||
|
||||
def view_invoice(self, cr, uid, ids, context=None):
|
||||
"""Launch Create invoice wizard.
|
||||
"""
|
||||
if context is None: context = {}
|
||||
result = self.do_partial(cr, uid, ids, context=context)
|
||||
partial = self.browse(cr, uid, ids[0], context=context)
|
||||
context.update(active_model='stock.picking',
|
||||
active_ids=[partial.picking_id.id])
|
||||
if partial.picking_id.invoice_state == '2binvoiced':
|
||||
return {
|
||||
'name': 'Create Invoice',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'stock.invoice.onshipping',
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'new',
|
||||
'context': context
|
||||
}
|
||||
return {'type': 'ir.actions.act_window_close'}
|
||||
|
||||
def do_partial(self, cr, uid, ids, context=None):
|
||||
assert len(ids) == 1, 'Partial picking processing may only be done one at a time.'
|
||||
stock_picking = self.pool.get('stock.picking')
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
</field>
|
||||
<footer>
|
||||
<button name="do_partial" string="_Transfer" type="object" class="oe_highlight"/>
|
||||
<button name="view_invoice" string="Receive & Control Invoice" type="object" class="oe_highlight"/>
|
||||
or
|
||||
<button string="Cancel" class="oe_link" special="cancel" />
|
||||
</footer>
|
||||
|
|
Loading…
Reference in New Issue