diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 6adb726b97a..b2127cf4214 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -817,4 +817,20 @@ class procurement_order(osv.osv): procurement_order() +class stock_invoice_onshipping(osv.osv_memory): + _inherit = "stock.invoice.onshipping" + + def create_invoice(self, cr, uid, ids, context=None): + if context is None: + context = {} + purchase_obj = self.pool.get('purchase.order') + picking_obj = self.pool.get('stock.picking') + res = super(stock_invoice_onshipping,self).create_invoice(cr, uid, ids, context=context) + purchase_id = picking_obj.browse(cr, uid, res.keys()[0]).purchase_id.id + purchase_obj.write(cr, uid, [purchase_id], { + 'invoice_ids': [(4, res.values()[0])]}, context=context) + return res + +stock_invoice_onshipping() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 359810fb306..7fffad4e5c5 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -12,10 +12,10 @@ groups="group_purchase_manager" parent="base.menu_purchase_root" sequence="100"/> - - + @@ -29,22 +29,22 @@ parent="menu_purchase_config_pricelist" sequence="2" groups="base.group_extended"/> - - + - - - + - + @@ -113,10 +113,10 @@ - + - + @@ -292,7 +292,7 @@ You can create a request for quotation when you want to buy products to a supplier but the purchase is not confirmed yet. Use also this menu to review requests for quotation created automatically based on your logistic rules (minimum stock, MTO, etc). You can convert the request for quotation into a purchase order once the order is confirmed. If you use the extended interface (from user's preferences), you can select the way to control your supplier invoices: based on the order, based on the receptions or manual encoding. - @@ -458,7 +458,7 @@ Purchase Lines Not Invoiced ir.actions.act_window purchase.order.line - [('state','in',('confirmed','done')), ('invoiced', '=', False)] + [('order_id.invoice_method','<>','picking'), ('state','in',('confirmed','done')), ('invoiced', '=', False)] form tree,form diff --git a/addons/stock/wizard/stock_invoice_onshipping.py b/addons/stock/wizard/stock_invoice_onshipping.py index 091049b5689..c7eab1eef4d 100644 --- a/addons/stock/wizard/stock_invoice_onshipping.py +++ b/addons/stock/wizard/stock_invoice_onshipping.py @@ -85,34 +85,18 @@ class stock_invoice_onshipping(osv.osv_memory): raise osv.except_osv(_('Warning !'), _('None of these picking lists require invoicing.')) return res - - - def create_invoice(self, cr, uid, ids, context=None): + def open_invoice(self, cr, uid, ids, context=None): if context is None: context = {} - picking_pool = self.pool.get('stock.picking') - data_pool = self.pool.get('ir.model.data') - onshipdata_obj = self.read(cr, uid, ids[0], ['journal_id', 'group', 'invoice_date']) - if context.get('new_picking', False): - onshipdata_obj['id'] = onshipdata_obj.new_picking - onshipdata_obj[ids] = onshipdata_obj.new_picking - - context['date_inv'] = onshipdata_obj['invoice_date'] invoice_ids = [] - 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) - - res = picking_pool.action_invoice_create(cr, uid, active_ids, - journal_id = onshipdata_obj['journal_id'], - group = onshipdata_obj['group'], - type = None, - context=context) + data_pool = self.pool.get('ir.model.data') + res = self.create_invoice(cr, uid, ids, context=context) invoice_ids += res.values() - if not invoice_ids: - raise osv.except_osv(_('Error'), _('No Invoices were created')) + inv_type = context.get('inv_type', False) action_model = False action = {} + if not invoice_ids: + raise osv.except_osv(_('Error'), _('No Invoices were created')) 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": @@ -127,6 +111,26 @@ class stock_invoice_onshipping(osv.osv_memory): action['domain'] = "[('id','in', ["+','.join(map(str,invoice_ids))+"])]" return action + def create_invoice(self, cr, uid, ids, context=None): + if context is None: + context = {} + picking_pool = self.pool.get('stock.picking') + onshipdata_obj = self.read(cr, uid, ids, ['journal_id', 'group', 'invoice_date']) + if context.get('new_picking', False): + onshipdata_obj['id'] = onshipdata_obj.new_picking + onshipdata_obj[ids] = onshipdata_obj.new_picking + context['date_inv'] = onshipdata_obj[0]['invoice_date'] + 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, + journal_id = onshipdata_obj[0]['journal_id'], + group = onshipdata_obj[0]['group'], + type = None, + context=context) + return res + stock_invoice_onshipping() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/stock/wizard/stock_invoice_onshipping_view.xml b/addons/stock/wizard/stock_invoice_onshipping_view.xml index 6a4cfec5fca..06d93f49ea1 100644 --- a/addons/stock/wizard/stock_invoice_onshipping_view.xml +++ b/addons/stock/wizard/stock_invoice_onshipping_view.xml @@ -15,7 +15,7 @@