~vauxoo/addons-vauxoo/8.0-import_tax_tariff-dev-yani-rev-2

« back to all changes in this revision

Viewing changes to mrp_production_wizard/wizard/wizard.py

  • Committer: jose at vauxoo
  • Date: 2012-10-30 22:29:46 UTC
  • mfrom: (501.1.58 6.1)
  • Revision ID: jose@vauxoo.com-20121030222946-gjtl9xw24t27xrrw
  
[MERGE] Merge to 6.1 branch to added new features 

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
import time
 
27
from osv import osv, fields
 
28
import decimal_precision as dp
 
29
from tools.translate import _
 
30
 
 
31
class mrp_production_wizard(osv.osv_memory):
 
32
    _name='mrp.production.wizard'
 
33
    _columns={
 
34
        'product_id': fields.many2one('product.product', 'Product', required=True, ),
 
35
        'wiz_data': fields.one2many('wizard.data', 'mrp_production_wiz', 'Prod lines'),
 
36
    }
 
37
    
 
38
    def pass_products_to_parent(self,cr,uid,ids,context={}):
 
39
        if not context:
 
40
            context={}
 
41
        wizard_data_data = self.browse(cr, uid, ids, context=context)
 
42
        list_product_lines = []
 
43
        dict_line = {}
 
44
        for line in wizard_data_data:
 
45
            product = line.product_id
 
46
            for move in line.wiz_data:
 
47
                dict_line = {
 
48
                    'name' : move.name,
 
49
                    'product_id' : move.product_id_consume.id,
 
50
                    'product_qty' : move.product_qty,
 
51
                    'product_uom' : move.product_uom.id}
 
52
                list_product_lines.append(dict_line)
 
53
        mrp_production_id = self.pool.get('mrp.production').create_production_wizard(cr, uid, product, list_product_lines, context=context)
 
54
        
 
55
        mod_obj = self.pool.get('ir.model.data')
 
56
        res = mod_obj.get_object_reference(cr, uid, 'mrp', 'mrp_production_form_view')
 
57
        res_id = res and res[1] or False,
 
58
        return {
 
59
            'name': _('Manufacturing orders'),
 
60
            'view_type': 'form',
 
61
            'view_mode': 'form,tree',
 
62
            'view_id': [res_id],
 
63
            'res_model': 'mrp.production',
 
64
            'context': "",
 
65
            'type': 'ir.actions.act_window',
 
66
            'nodestroy': False,
 
67
            'target': 'current',
 
68
            'res_id': mrp_production_id or False,
 
69
        }
 
70
    
 
71
mrp_production_wizard()
 
72
 
 
73
class wizard_data(osv.osv_memory):
 
74
    _name='wizard.data'
 
75
    
 
76
    _columns={
 
77
        'mrp_production_wiz': fields.many2one('mrp.production.wizard', 'Padre'),
 
78
        'name': fields.char('Name', size=64, required=True),
 
79
        'product_id_consume': fields.many2one('product.product', 'Product', required=True),
 
80
        'product_qty': fields.float('Product Qty', required=True),
 
81
        'product_uom': fields.many2one('product.uom', 'Product UOM', required=True),
 
82
    }
 
83
    
 
84
    def onchange_production_wizard_product_name(self, cr, uid, ids, product_id):
 
85
        if product_id:
 
86
            new_product_id = [product_id]
 
87
            product_product_obj = self.pool.get('product.product')
 
88
            product_product_data = product_product_obj.browse(cr, uid, new_product_id, context=None)
 
89
            if product_product_data:
 
90
                for line in product_product_data:
 
91
                    val = {
 
92
                        'name' : line.name, 
 
93
                        'product_uom' : line.uom_id.id,
 
94
                        'product_qty' : line.qty_available,
 
95
                    }
 
96
                    domain_uom = {'product_uom':[('category_id', '=', line.uom_id.category_id.id)]}
 
97
                    return {'value': val, 'domain': domain_uom}
 
98
        return {}
 
99
 
 
100
wizard_data()
 
 
b'\\ No newline at end of file'