[ADD] add receuce abd control invoice button.
bzr revid: nco@tinyerp.com-20121025125826-uodc9s0g3ihpm7qb
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
from tools.translate import _
|
||||
|
||||
class stock_move(osv.osv):
|
||||
_inherit = 'stock.move'
|
||||
@@ -136,4 +137,35 @@ class stock_picking_in(osv.osv):
|
||||
ondelete='set null', select=True),
|
||||
'warehouse_id': fields.related('purchase_id', 'warehouse_id', type='many2one', relation='stock.warehouse', string='Destination Warehouse'),
|
||||
}
|
||||
def create_draft_invoice(self, cr, uid, ids, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
pur_obj = self.pool.get('purchase.order')
|
||||
wizard_obj = self.pool.get('purchase.order.line_invoice')
|
||||
#compute the number of invoices to display
|
||||
inv_ids = []
|
||||
pur_id = self.browse(cr, uid, ids[0], context=context).purchase_id.id
|
||||
pur_ids = [pur_id]
|
||||
for po in pur_obj.browse(cr, uid, pur_ids, context=context):
|
||||
if po.invoice_method == 'picking':
|
||||
if not po.invoice_ids:
|
||||
context.update({'active_ids' : [line.id for line in po.order_line]})
|
||||
wizard_obj.makeInvoices(cr, uid, [], context=context)
|
||||
|
||||
for po in pur_obj.browse(cr, uid, pur_ids, context=context):
|
||||
inv_ids+= [invoice.id for invoice in po.invoice_ids]
|
||||
res = mod_obj.get_object_reference(cr, uid, 'account', 'invoice_supplier_form')
|
||||
res_id = res and res[1] or False
|
||||
|
||||
return {
|
||||
'name': _('Supplier Invoices'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'view_id': [res_id],
|
||||
'res_model': 'account.invoice',
|
||||
'context': "{'type':'in_invoice', 'journal_type': 'purchase'}",
|
||||
'type': 'ir.actions.act_window',
|
||||
'nodestroy': True,
|
||||
'target': 'current',
|
||||
'res_id': inv_ids and inv_ids[0] or False,
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -37,6 +37,17 @@
|
||||
</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="//button[@name='action_process']" position="after">
|
||||
<button name="create_draft_invoice" states="assigned" 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>
|
||||
|
||||
Reference in New Issue
Block a user