1
# -*- encoding: utf-8 -*-
2
###########################################################################
3
# Module Writen to OpenERP, Open Source Management Solution
5
# Copyright (c) 2012 Vauxoo - http://www.vauxoo.com
8
############################################################################
9
# Coded by: fernandoL (fernando_ld@vauxoo.com)
10
############################################################################
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.
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.
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/>.
25
##############################################################################
30
from tools.translate import _
33
from osv import osv, fields
35
from tools import ustr
37
class mrp_production(osv.osv):
38
_inherit = "mrp.production"
42
def create_production_wizard(self, cr, uid, product, list_produce, context):
43
""" creates the production order
44
@param product id to create
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,
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'],
59
new_id = self.create(cr, uid, production_order_dict)
61
for line in list_produce:
62
production_scheduled_dict = {
64
'product_id': line['product_id'],
65
'product_qty': line['product_qty'],
66
'product_uom': line['product_uom'],
67
'production_id': new_id,
69
self.pool.get('mrp.production.product.line').create(cr, uid, production_scheduled_dict)
71
mrp_pt_planifed_dict = {
72
'product_id' : product.id,
74
'production_id' : new_id,
75
'product_uom' : product.uom_id.id,
77
self.pool.get('mrp.pt.planified').create(cr, uid, mrp_pt_planifed_dict)
79
raise osv.except_osv(_('Error'), _("The category of the product to produce has not predefined locations "))
b'\\ No newline at end of file'