[IMP] move receive and control invoice to incoming shipment wizard.
bzr revid: nco@tinyerp.com-20121106124210-dw7iqpjuwwbk7h5j
This commit is contained in:
parent
19268332b1
commit
096b52f984
|
@ -135,30 +135,7 @@ class stock_picking_in(osv.osv):
|
|||
_columns = {
|
||||
'purchase_id': fields.many2one('purchase.order', 'Purchase Order',
|
||||
ondelete='set null', select=True),
|
||||
'purchase_invoice_method': fields.related('purchase_id', 'invoice_method', type='selection', selection=[('manual','Based on Purchase Order lines'),('order','Based on generated draft invoice'),('picking','Based on incoming shipments')], string='Purchase Invoice Method'),
|
||||
'warehouse_id': fields.related('purchase_id', 'warehouse_id', type='many2one', relation='stock.warehouse', string='Destination Warehouse'),
|
||||
}
|
||||
def view_invoice(self, cr, uid, ids, context=None):
|
||||
pur_obj = self.pool.get('purchase.order')
|
||||
models_data = self.pool.get('ir.model.data')
|
||||
pur_ids = []
|
||||
inv_ids = []
|
||||
for pur_id in self.browse(cr, uid, ids, context=context):
|
||||
pur_ids.append(pur_id.purchase_id.id)
|
||||
for po in pur_obj.browse(cr, uid, pur_ids, context=context):
|
||||
inv_ids+= [invoice.id for invoice in po.invoice_ids]
|
||||
form_view = models_data.get_object_reference(cr, uid, 'stock', 'view_stock_invoice_onshipping')
|
||||
if inv_ids:
|
||||
return pur_obj.view_invoice(cr, uid, pur_ids, context=context)
|
||||
else:
|
||||
return {
|
||||
'name': _('Create Supplier Invoice'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'stock.invoice.onshipping',
|
||||
'view_id': False,
|
||||
'views': [(form_view and form_view[1] or False, 'form')],
|
||||
'target': 'new',
|
||||
'type': 'ir.actions.act_window',
|
||||
}
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -37,20 +37,6 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_picking_in_form_picking_inherit" model="ir.ui.view">
|
||||
<field name="name">stock.picking.in.form.inherit</field>
|
||||
<field name="model">stock.picking.in</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_in_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='move_lines']" position="after">
|
||||
<field name="purchase_invoice_method" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//button[@name='action_process']" position="after">
|
||||
<button name="view_invoice" string="Receive & Control Invoice" attrs="{'invisible':['|', ('invoice_state','=','invoiced'),('purchase_invoice_method', '!=', 'picking')]}" 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,6 +154,26 @@ 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,6 +32,7 @@
|
|||
</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