~serpent-consulting-services/openerp-usa/shipping_api_6-1

« back to all changes in this revision

Viewing changes to assembly_bom/procurement.py

  • Committer: npgllc
  • Date: 2012-08-02 17:13:27 UTC
  • Revision ID: npgllc-20120802171327-2xgyyjjb5d1kx26y
Removed all the 6.0 compatible modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- ecoding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
#    OpenERP, Open Source Management Solution
5
 
#    Copyright (C) 2011 NovaPoint Group LLC (<http://www.novapointgroup.com>)
6
 
#    Copyright (C) 2004-2010 OpenERP SA (<http://www.openerp.com>)
7
 
#
8
 
#    This program is free software: you can redistribute it and/or modify
9
 
#    it under the terms of the GNU General Public License as published by
10
 
#    the Free Software Foundation, either version 3 of the License, or
11
 
#    (at your option) any later version.
12
 
#
13
 
#    This program is distributed in the hope that it will be useful,
14
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
#    GNU General Public License for more details.
17
 
#
18
 
#    You should have received a copy of the GNU General Public License
19
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 
#
21
 
##############################################################################
22
 
 
23
 
from osv import osv
24
 
 
25
 
class procurement(osv.osv):
26
 
    _inherit="procurement.order"
27
 
 
28
 
    def action_produce_assign_product(self, cr, uid, ids, context=None):
29
 
        """ 
30
 
        Blocks the procurement being run for products with assembly bom
31
 
        @param self: The object pointer.
32
 
        @param ids: ids of the procurement order document
33
 
        @param context: standard dictionary
34
 
        @comment: Blocks the procurement to be run for products with assembly bom
35
 
        @return: returns either the Manufacturing order id or 0
36
 
        """
37
 
        procurement_obj = self.pool.get('procurement.order')
38
 
        bom_obj = self.pool.get('mrp.bom')
39
 
        sale_line_obj = self.pool.get('sale.order.line')
40
 
        res = []
41
 
        for procure_record in procurement_obj.browse(cr, uid, ids, context=context):
42
 
            sale_line_ids = sale_line_obj.search(cr, uid, [('procurement_id', '=', procure_record.id)], context=context)
43
 
            sale_line_id = sale_line_ids and sale_line_ids[0] or False
44
 
            if sale_line_id:
45
 
                line = sale_line_obj.browse(cr, uid, sale_line_id, context=context)
46
 
                if line.product_id:
47
 
                    bom_ids = bom_obj.search(cr, uid, [('product_id', '=', line.product_id.id), ('type', '=', 'assembly')], context=context)
48
 
                    bom_id = bom_ids and bom_ids[0] or False
49
 
                    if bom_id:
50
 
                        return 0
51
 
            return super(procurement, self).action_produce_assign_product(cr, uid, [procure_record.id], context=context)
52
 
 
53
 
procurement()
54
 
 
55
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 
 
b'\\ No newline at end of file'