2
# -*- coding: utf-8 -*-
3
##############################################################################
5
# OpenERP, Open Source Management Solution
6
# Copyright (C) 2011 TeMPO Consulting, MSF. All Rights Reserved
7
# Developer: Olivier DOSSMANN
9
# This program is free software: you can redistribute it and/or modify
10
# it under the terms of the GNU Affero General Public License as
11
# published by the Free Software Foundation, either version 3 of the
12
# License, or (at your option) any later version.
14
# This program is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU Affero General Public License for more details.
19
# You should have received a copy of the GNU Affero General Public License
20
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
##############################################################################
26
class stock_picking(osv.osv):
27
_name = 'stock.picking'
28
_inherit = 'stock.picking'
30
def _invoice_line_hook(self, cr, uid, move_line, invoice_line_id):
32
Create a link between invoice_line and purchase_order_line. This piece of information is available on move_line.order_line_id
34
if invoice_line_id and move_line:
35
self.pool.get('account.invoice.line').write(cr, uid, [invoice_line_id],
36
{'order_line_id': move_line.purchase_line_id and move_line.purchase_line_id.id or False})
37
return super(stock_picking, self)._invoice_line_hook(cr, uid, move_line, invoice_line_id)
39
def _invoice_hook(self, cr, uid, picking, invoice_id):
41
Create a link between invoice and purchase_order.
42
Copy analytic distribution from purchase order to invoice (or from commitment voucher if exists)
44
if invoice_id and picking:
45
po_id = picking.purchase_id and picking.purchase_id.id or False
47
self.pool.get('purchase.order').write(cr, uid, [po_id], {'invoice_ids': [(4, invoice_id)]})
48
# Copy analytic distribution from purchase order or commitment voucher (if exists)
49
self.pool.get('account.invoice').fetch_analytic_distribution(cr, uid, [invoice_id])
50
return super(stock_picking, self)._invoice_hook(cr, uid, picking, invoice_id)
53
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: