2009-10-14 11:15:34 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2006-12-18 06:33:52 +00:00
|
|
|
##############################################################################
|
2010-06-23 11:24:15 +00:00
|
|
|
#
|
2009-05-05 11:00:23 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
2010-01-12 09:18:39 +00:00
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
2008-11-03 19:18:56 +00:00
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2009-10-14 11:15:34 +00:00
|
|
|
# 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.
|
2008-11-03 19:18:56 +00:00
|
|
|
#
|
|
|
|
# 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
|
2009-10-14 11:15:34 +00:00
|
|
|
# GNU Affero General Public License for more details.
|
2008-11-03 19:18:56 +00:00
|
|
|
#
|
2009-10-14 11:15:34 +00:00
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
2010-06-23 11:24:15 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-12-18 06:33:52 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import fields, osv
|
2013-07-18 08:57:56 +00:00
|
|
|
from openerp import netsvc
|
2006-12-18 08:53:45 +00:00
|
|
|
class stock_move(osv.osv):
|
2008-07-22 15:11:28 +00:00
|
|
|
_inherit = 'stock.move'
|
|
|
|
_columns = {
|
|
|
|
'purchase_line_id': fields.many2one('purchase.order.line',
|
|
|
|
'Purchase Order Line', ondelete='set null', select=True,
|
|
|
|
readonly=True),
|
|
|
|
}
|
2010-09-15 18:01:00 +00:00
|
|
|
|
2013-09-04 15:01:37 +00:00
|
|
|
def write(self, cr, uid, ids, vals, context=None):
|
|
|
|
if isinstance(ids, (int, long)):
|
|
|
|
ids = [ids]
|
|
|
|
res = super(stock_move, self).write(cr, uid, ids, vals, context=context)
|
2013-09-06 08:59:03 +00:00
|
|
|
from openerp import workflow
|
2013-07-19 11:55:33 +00:00
|
|
|
for id in ids:
|
2013-09-06 08:59:03 +00:00
|
|
|
workflow.trg_trigger(uid, 'stock.move', id, cr)
|
2013-07-19 11:55:33 +00:00
|
|
|
return res
|
2013-08-04 19:25:38 +00:00
|
|
|
|
2006-12-18 06:33:52 +00:00
|
|
|
#
|
|
|
|
# Inherit of picking to add the link to the PO
|
|
|
|
#
|
|
|
|
class stock_picking(osv.osv):
|
2008-07-22 15:11:28 +00:00
|
|
|
_inherit = 'stock.picking'
|
|
|
|
_columns = {
|
|
|
|
'purchase_id': fields.many2one('purchase.order', 'Purchase Order',
|
2010-08-25 19:07:01 +00:00
|
|
|
ondelete='set null', select=True),
|
2008-07-22 15:11:28 +00:00
|
|
|
}
|
2012-07-16 12:13:10 +00:00
|
|
|
|
2008-07-22 15:11:28 +00:00
|
|
|
_defaults = {
|
2010-11-27 20:16:16 +00:00
|
|
|
'purchase_id': False,
|
2008-07-22 15:11:28 +00:00
|
|
|
}
|
2009-05-05 11:00:23 +00:00
|
|
|
|
2013-08-04 19:25:38 +00:00
|
|
|
# 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
|