58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
##############################################################################
|
|
#
|
|
# OpenERP, Open Source Management Solution
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
# License, or (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
##############################################################################
|
|
|
|
from openerp.osv import fields, osv
|
|
from openerp import netsvc
|
|
class stock_move(osv.osv):
|
|
_inherit = 'stock.move'
|
|
_columns = {
|
|
'purchase_line_id': fields.many2one('purchase.order.line',
|
|
'Purchase Order Line', ondelete='set null', select=True,
|
|
readonly=True),
|
|
}
|
|
|
|
def action_done(self, cr ,uid, ids, context=None):
|
|
res = super(stock_move, self).action_done(cr, uid, ids, context)
|
|
wf_service = netsvc.LocalService('workflow')
|
|
for id in ids:
|
|
wf_service.trg_trigger(uid, 'stock.move', id, cr)
|
|
return res
|
|
|
|
#
|
|
# Inherit of picking to add the link to the PO
|
|
#
|
|
class stock_picking(osv.osv):
|
|
_inherit = 'stock.picking'
|
|
_columns = {
|
|
'purchase_id': fields.many2one('purchase.order', 'Purchase Order',
|
|
ondelete='set null', select=True),
|
|
'warehouse_id': fields.related('purchase_id', 'warehouse_id', type='many2one', relation='stock.warehouse', string='Destination Warehouse'),
|
|
}
|
|
|
|
_defaults = {
|
|
'purchase_id': False,
|
|
}
|
|
|
|
# TODO: Invoice based on receptions
|
|
# Here is how it should work:
|
|
# On a draft invoice, allows to select purchase_orders (many2many_tags)
|
|
# This fills in automatically PO lines or from related receptions if any
|