~vauxoo/addons-vauxoo/addons-vauxoo-stock_picking_cancel_move-dev-julio

« back to all changes in this revision

Viewing changes to mrp_production_wizard/mrp.py

  • Committer: Julio Serna
  • Date: 2012-10-23 16:23:35 UTC
  • mfrom: (492.1.42 6.1)
  • Revision ID: julio@vauxoo.com-20121023162335-1buz3jm9fkclhld4
[MERGE] repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
###########################################################################
 
3
#    Module Writen to OpenERP, Open Source Management Solution
 
4
#
 
5
#    Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
 
6
#    All Rights Reserved.
 
7
#    info@vauxoo.com
 
8
############################################################################
 
9
#    Coded by: fernandoL (fernando_ld@vauxoo.com)
 
10
############################################################################
 
11
#
 
12
#    This program is free software: you can redistribute it and/or modify
 
13
#    it under the terms of the GNU Affero General Public License as
 
14
#    published by the Free Software Foundation, either version 3 of the
 
15
#    License, or (at your option) any later version.
 
16
#
 
17
#    This program is distributed in the hope that it will be useful,
 
18
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
#    GNU Affero General Public License for more details.
 
21
#
 
22
#    You should have received a copy of the GNU Affero General Public License
 
23
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
24
#
 
25
##############################################################################
 
26
 
 
27
import pooler
 
28
import wizard
 
29
import netsvc
 
30
from tools.translate import _
 
31
import tools
 
32
import os
 
33
from osv import osv, fields
 
34
import time
 
35
from tools import ustr
 
36
 
 
37
class mrp_production(osv.osv):
 
38
    _inherit = "mrp.production"
 
39
    
 
40
    """
 
41
    """
 
42
    def create_production_wizard(self, cr, uid, product, list_produce, context):
 
43
        """ creates the production order
 
44
        @param product id to create
 
45
        @return: True
 
46
        """
 
47
        default_location_dict = self.product_id_change(cr, uid, [], product.id, context)
 
48
        if (default_location_dict['value']['location_src_id'] & default_location_dict['value']['location_dest_id']):
 
49
            production_order_dict = {
 
50
                'name' : self.pool.get('ir.sequence').get(cr, uid, 'mrp.production'),
 
51
                'date_planned' : time.strftime('%Y-%m-%d %H:%M:%S'),
 
52
                'product_id' : product.id,
 
53
                'product_qty' : 1,
 
54
                'product_uom' : product.uom_id.id,
 
55
                'location_src_id': default_location_dict['value']['location_src_id'],
 
56
                'location_dest_id': default_location_dict['value']['location_dest_id'],
 
57
                'state' : 'draft'
 
58
            }
 
59
            new_id = self.create(cr, uid, production_order_dict)
 
60
            
 
61
            for line in list_produce:
 
62
                production_scheduled_dict = {
 
63
                    'name': line['name'],
 
64
                    'product_id': line['product_id'],
 
65
                    'product_qty': line['product_qty'],
 
66
                    'product_uom': line['product_uom'],
 
67
                    'production_id': new_id,
 
68
                }
 
69
                self.pool.get('mrp.production.product.line').create(cr, uid, production_scheduled_dict)
 
70
            
 
71
            mrp_pt_planifed_dict = {
 
72
                'product_id' : product.id,
 
73
                'quantity' : 1,
 
74
                'production_id' : new_id,
 
75
                'product_uom' : product.uom_id.id,
 
76
            }
 
77
            self.pool.get('mrp.pt.planified').create(cr, uid, mrp_pt_planifed_dict)
 
78
        else:
 
79
            raise osv.except_osv(_('Error'), _("The category of the product to produce has not predefined locations "))
 
80
        return new_id
 
81
    
 
82
mrp_production()
 
 
b'\\ No newline at end of file'