← Back to team overview

avanzosc team mailing list archive

[Merge] lp:~xclude/avanzosc/mrp-6.1-bug-1214827 into lp:avanzosc/mrp-6.1

 

Daniel Stenlöv (XCLUDE) has proposed merging lp:~xclude/avanzosc/mrp-6.1-bug-1214827 into lp:avanzosc/mrp-6.1.

Requested reviews:
  Avanzosc Manufacturing team (avanzosc-manufactuaring-team)
Related bugs:
  Bug #1214827 in Avanzosc developments: "mrp_analytics_control: Hardcoded company_id and currency_id."
  https://bugs.launchpad.net/avanzosc/+bug/1214827

For more details, see:
https://code.launchpad.net/~xclude/avanzosc/mrp-6.1-bug-1214827/+merge/185227

Fixes hardcoded values.
Language translation
Added comments about suggested changes.
-- 
https://code.launchpad.net/~xclude/avanzosc/mrp-6.1-bug-1214827/+merge/185227
Your team Avanzosc Manufacturing team is requested to review the proposed merge of lp:~xclude/avanzosc/mrp-6.1-bug-1214827 into lp:avanzosc/mrp-6.1.
=== modified file 'mrp_analytics_control/manufacturing_analitic_accounts.py'
--- mrp_analytics_control/manufacturing_analitic_accounts.py	2013-09-09 13:38:16 +0000
+++ mrp_analytics_control/manufacturing_analitic_accounts.py	2013-09-12 09:49:19 +0000
@@ -43,13 +43,12 @@
                 }
     
     def recalculate_result(self, cr, uid, acc_id):
-        analytic_obj = self.pool.get('account.analytic.account')
         if acc_id:
-            acc = analytic_obj.browse(cr, uid, acc_id)
+            acc = self.browse(cr, uid, acc_id)
             
             resu = float(acc.balance) + float(acc.total_estimated)
             
-            analytic_obj.write(cr, uid, acc_id,{'acc_result':resu})
+            self.write(cr, uid, acc_id,{'acc_result':resu})
             
             if not acc.acc_type == 'MF':            
                 self.recalculate_result(cr, uid, acc.parent_id.id)
@@ -57,9 +56,8 @@
     
     def calculate_estimated(self, cr, uid, parnt_id, amount, amount_puc, amount_standard):
         
-        analytic_obj = self.pool.get('account.analytic.account')
         if parnt_id:
-            acc = analytic_obj.browse(cr, uid, parnt_id)
+            acc = self.browse(cr, uid, parnt_id)
             
             total = acc.total_estimated
             total2 = acc.total_estimated_puc
@@ -74,7 +72,7 @@
             tot2 = total2 + amount_puc
             tot3 = total3 + amount_standard
             resu = acc.debit - tot
-            analytic_obj.write(cr,uid,parnt_id,{'total_estimated':tot,
+            self.write(cr,uid,parnt_id,{'total_estimated':tot,
                                                 'total_estimated_puc':tot2,
                                                 'total_estimated_standard': tot3,
                                                 'acc_result':resu})

=== modified file 'mrp_analytics_control/production.py'
--- mrp_analytics_control/production.py	2013-09-09 13:38:16 +0000
+++ mrp_analytics_control/production.py	2013-09-12 09:49:19 +0000
@@ -41,6 +41,7 @@
 #            return {'value':{'created':True}}
 
     def unlink(self, cr, uid, ids, context=None):
+        # TODO: FIX delete? Spanish in context...
         if 'borrar' in context:
             super(mrp_fixed_cost, self).unlink(cr, uid, ids, context=context)    
         else:
@@ -61,23 +62,24 @@
                 if fix_acc_search:
                     line_search = account_analytic_line_obj.search(cr, uid, [('name','=',cost.name),('account_id','=',fix_acc_search[0])])
                     if line_search:
-                        account_analytic_line_obj.write(cr, uid, line_search[0],{'amount':(cost.amount*(-1))})                                                 
+                        account_analytic_line_obj.write(cr, uid, line_search[0],{'amount': (cost.amount*(-1))})                                                 
                         account_analytic_obj.recalculate_result(cr, uid, fix_acc_search[0])
                     else:
-                        print 'fallo de programacion al leer la linea de cuenta analitica'
+                        raise osv.except_osv(_('Programming error'), _('Error in reading the analytic account line'))
                 else:
-                        print 'Analitica no creada o fallo de programacion al leer la cuenta analitica' 
+                    raise osv.except_osv(_('Programming error'), _('Failure in reading or creating analytic account'))
         return res
     
     def create(self, cr, uid, vals, context=None):
         fix_created = super(mrp_fixed_cost, self).create(cr, uid, vals, context=context)        
         account_analytic_obj = self.pool.get('account.analytic.account')
         account_analytic_jour_obj = self.pool.get('account.analytic.journal')
-        acc_search = account_analytic_obj.search(cr, uid,[('code','=','OF'+str(vals['production_id']))])
+        acc_search = account_analytic_obj.search(cr, uid,[('code','=','OF' + str(vals['production_id']))])
         acc_id = False
         if acc_search:
             acc_id = acc_search[0]
-        
+        # TODO: Change this to use code instead for translational option
+        # man_journal_search = account_analytic_jour_obj.search(cr, uid,[('code', '=', 'MRP')])
         man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', 'Manufacturing')])        
         
         if acc_id:
@@ -87,46 +89,47 @@
            prod_maq_name_acc_code = False
             
            man_fix_account = account_analytic_obj.search(cr, uid,[('code','=','OF'+str(vals['production_id'])+'FIX') ] )[0]
+           aux_prod = self.pool.get('mrp.production')
+           production_id = aux_prod.search(cr, uid,[('mrp_manu_op', '=', vals['production_id'] )], limit=1)         
+           prod = aux_prod.browse(cr , uid, production_id[0])
            
            if not man_fix_account:         
                     #Crear cuenta analitica de costes fijos                   
-               
-                   
-         
+                    
                op_acc_code = 'OF' + str(acc_id)
                prod_maq_name_acc_code = op_acc_code + 'FIX'
                         
                est = 0
                                                 
                values={
-                    'name':prod_maq_name_acc_code + " " + 'Fijos ' ,
-                    'code':prod_maq_name_acc_code ,
-                    'currency_id':1,
-                    'company_id':1,
-                    'state':'open',
-                    'parent_id':acc_id,
-                    'total_estimated':est,
+                    'name': prod_maq_name_acc_code + " " + _('Fixed'),
+                    'code': prod_maq_name_acc_code,
+                    'currency_id': prod.company_id.currency_id.id,
+                    'company_id': prod.company_id.id,
+                    'state': 'open',
+                    'parent_id': acc_id,
+                    'total_estimated': est,
                     'total_estimated_puc': 0,
                     'total_estimated_standard' : 0,
-                    'acc_type':'FIX'
+                    'acc_type': 'FIX'
                   }
                             
                             
                man_fix_account = account_analytic_obj.create(cr, uid, values)
                account_analytic_obj.recalculate_result(cr, uid, man_fix_account) 
                             
-          
+           
                             #añadir costes reales de costes fijos                        
                                 
            values = {
-               'amount':vals['amount']*(-1),
-               'name':vals['name'],
-               'date':datetime.today(),
-               'company_in':1,
+               'amount': vals['amount']*(-1),
+               'name': vals['name'],
+               'date': datetime.today(),
+               'company_in': prod.company_id.id,
                'account_id': man_fix_account,
-               'general_account_id':950,
-               'journal_id':man_journal_search[0],
-                 }
+               'general_account_id': prod.company_id.material_account.id, 
+               'journal_id': man_journal_search[0],
+               }
            new_id = account_analytic_line_obj.create(cr, uid, values)          
            account_analytic_obj.recalculate_result(cr, uid, man_fix_account)        
                     

=== modified file 'mrp_analytics_control/wizard/mrp_analytic_schema_wizard.py'
--- mrp_analytics_control/wizard/mrp_analytic_schema_wizard.py	2013-09-09 13:38:16 +0000
+++ mrp_analytics_control/wizard/mrp_analytic_schema_wizard.py	2013-09-12 09:49:19 +0000
@@ -37,6 +37,8 @@
         
     
     def get_default_account(self, cr, uid, context=None):
+        # TODO: Change this to use code instead for translational option
+        # man_journal_search = account_analytic_jour_obj.search(cr, uid,[('code', '=', 'MRP')])
         analytic_account = self.pool.get('account.analytic.account').search(cr, uid,[('name', '=', 'Manufacturing')])
         if analytic_account:
             return analytic_account[0]
@@ -55,8 +57,7 @@
         return values
     
     def mats_final_cost(self, cr, uid, op, company_id):
-        company_obj = self.pool.get('res.company')
-        company = company_obj.browse(cr, uid, company_id)
+        company = self.pool.get('res.company').browse(cr, uid, company_id)
         if not company.material_account:
             raise osv.except_osv(_('End Operation Error'), _('You must define one account for material cost'))  
         if not company.workcenter_account:
@@ -74,8 +75,11 @@
         
         #Cuenta analitica de materiales
                     
-        prod_mat_name_acc_code = 'OF'+ str(production.id) + 'OP' + str(man_op.id) + 'MAT'   
+        prod_mat_name_acc_code = 'OF'+ str(production.id) + 'OP' + str(man_op.id) + 'MAT'
+        # TODO: Change this to use code instead for translational option
+        # man_journal_search = account_analytic_jour_obj.search(cr, uid,[('code', '=', 'MRP')])   
         man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', 'Manufacturing')])
+        man_journal = account_analytic_jour_obj.browse(cr, uid, man_journal_search[0])
         
         #Cuenta analitica de materiales
                     
@@ -93,7 +97,7 @@
                       'company_id': company.id,
                       'account_id': acc_id,
                       'general_account_id': company.material_account.id,
-                      'journal_id': man_journal_search[0],
+                      'journal_id': man_journal.id,
                       'ref': production.name,
                       'unit_amount': 1,
                       'product_id': aux.product_id.id
@@ -112,8 +116,7 @@
             ope_account_id = aux_var
         if not ope_account_id:
             raise osv.except_osv(_('End Operation Error'), _('Analytic account: %s NOT FOUND')%(ope_acc_code))                       
-        man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', 'Manufacturing')])        
-        man_journal = account_analytic_jour_obj.browse(cr, uid, man_journal_search[0])
+             
         w_amount = real.delay * real.workcenter_id.costs_hour
         w_amount = w_amount * (-1)
         if not real.workcenter_id.product_id:
@@ -125,7 +128,7 @@
                   'company_id': company.id,
                   'account_id': ope_account_id,
                   'general_account_id': company.workcenter_account.id,
-                  'journal_id':man_journal.id,
+                  'journal_id': man_journal.id,
                   'ref': production.name,
                   'unit_amount': 1,
                   'product_id': real.workcenter_id.product_id.id
@@ -145,7 +148,8 @@
             wizard_config = wizard_config[0]
         else:
             return {'type': 'ir.actions.act_window_close'} 
-        
+        # TODO: Add translational option
+        # parent_op_acc_name = _('Manufacturing')
         parent_op_acc_name = 'Manufacturing'
         mrp_production_obj = self.pool.get('mrp.production')  
         prod_brow = mrp_production_obj.browse(cr, uid,context['active_ids']) 
@@ -165,11 +169,14 @@
         
         #Comprobación y asignación del diario analitico
         
-        man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', parent_op_acc_name)])        
+        # TODO: Change this to use code instead for translational option
+        # man_journal_search = account_analytic_jour_obj.search(cr, uid,[('code', '=', 'MRP')])   
+        man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', 'Manufacturing')])        
         if not man_journal_search:               
             values={
                  'name': parent_op_acc_name,
-                 'type':'general',
+                 'code': 'MRP',
+                 'type': 'general',
                  'company_id': wizard_config.company_id.id,
                  }
             man_journal_id = account_analytic_jour_obj.create(cr, uid, values)
@@ -190,13 +197,13 @@
                 parent_op_acc = account_analytic_obj.browse(cr, uid, parent_acc_search[0])
             else:
                 values = {
-                     'name':parent_op_acc_name,
-                     'code':parent_op_acc_name,
+                     'name': parent_op_acc_name,
+                     'code': parent_op_acc_name,
                      'currency_id': wizard_config.company_id.currency_id.id,
                      'company_id': wizard_config.company_id.id,
-                     'state':'open',
-                     'acc_type':'MF',
-                     'total_estimated':0.0,
+                     'state': 'open',
+                     'acc_type': 'MF',
+                     'total_estimated': 0.0,
                      'total_estimated_puc': 0.0,
                      'total_estimated_standard': 0.0,
                           }
@@ -217,16 +224,16 @@
                    raise osv.except_osv(_('Unable to perform action'), _('Analytic account for this Manufacturing order already exists.'))             
             else:  
                 values={
-                 'name':op_acc_code + " " +prod.name +" -> "+prod.product_id.name,
-                 'code':op_acc_code,
+                 'name': op_acc_code + " " +prod.name +" -> "+prod.product_id.name,
+                 'code': op_acc_code,
                  'currency_id': wizard_config.company_id.currency_id.id,
                  'company_id': wizard_config.company_id.id,
-                 'state':'open',
-                 'parent_id':parent_op_acc.id,
-                 'total_estimated':0.0,
+                 'state': 'open',
+                 'parent_id': parent_op_acc.id,
+                 'total_estimated': 0.0,
                  'total_estimated_puc': 0.0,
                  'total_estimated_standard': 0.0,
-                 'acc_type':'OF'
+                 'acc_type': 'OF'
                 }
                 man_account = account_analytic_obj.create(cr, uid, values)
                 values['name'] = '|            '+values['name']                
@@ -242,14 +249,14 @@
                 for fin in cost_fixed:
                     est += fin.estimated   
                 values={
-                    'name':prod_maq_name_acc_code + " " + _('Fixed') ,
-                    'code':prod_maq_name_acc_code ,
+                    'name': prod_maq_name_acc_code + " " + _('Fixed') ,
+                    'code': prod_maq_name_acc_code ,
                     'currency_id': wizard_config.company_id.currency_id.id,
                     'company_id': wizard_config.company_id.id,
-                    'state':'open',
-                    'parent_id':man_account,
-                    'total_estimated':est,
-                    'acc_type':'FIX',
+                    'state': 'open',
+                    'parent_id': man_account,
+                    'total_estimated': est,
+                    'acc_type': 'FIX',
                 }   
                 man_fix_account = account_analytic_obj.create(cr, uid, values)
                 values['name'] = '|                                              '+values['name']
@@ -262,9 +269,9 @@
                 
                 for fin in cost_fixed:     
                     values = {
-                        'amount':fin.amount*(-1),
-                        'name':fin.name,
-                        'date':datetime.today(),
+                        'amount': fin.amount*(-1),
+                        'name': fin.name,
+                        'date': datetime.today(),
                         'company_in': wizard_config.company_id.id,
                         'account_id': man_fix_account,
                         'general_account_id': wizard_config.company_id.material_account.id,
@@ -278,16 +285,16 @@
                 for prod_op in operations:
                     prod_op_name_acc_code = op_acc_code + 'OP' + str(prod_op.id) 
                     values = {
-                        'name':prod_op_name_acc_code + " " + prod_op.name,
-                        'code':prod_op_name_acc_code,
+                        'name': prod_op_name_acc_code + " " + prod_op.name,
+                        'code': prod_op_name_acc_code,
                         'currency_id': wizard_config.company_id.currency_id.id,
                         'company_id': wizard_config.company_id.id,
-                        'state':'open',
-                        'parent_id':man_account,
-                        'total_estimated':0.0,
+                        'state': 'open',
+                        'parent_id': man_account,
+                        'total_estimated': 0.0,
                         'total_estimated_puc': 0.0,
                         'total_estimated_standard': 0.0,
-                        'acc_type':'OP'
+                        'acc_type': 'OP'
                         }
                     man_op_account = account_analytic_obj.create(cr, uid, values)
                     values['name'] = '|                        '+values['name']
@@ -304,14 +311,14 @@
                     aux_product = self.pool.get('product.product').browse(cr , uid, maq.product_id.id) 
                     total_estimated = prod_op.hour * aux_product.standard_price
                     values = {
-                        'name':prod_maq_name_acc_code + " " + _('Machine') + " " + prod_op.workcenter_id.name,
-                        'code':prod_maq_name_acc_code ,
+                        'name': prod_maq_name_acc_code + " " + _('Machine') + " " + prod_op.workcenter_id.name,
+                        'code': prod_maq_name_acc_code ,
                         'currency_id': wizard_config.company_id.currency_id.id,
                         'company_id': wizard_config.company_id.id,
-                        'state':'open',
-                        'parent_id':man_op_account,
-                        'total_estimated':total_estimated,
-                        'acc_type':'MA'
+                        'state': 'open',
+                        'parent_id': man_op_account,
+                        'total_estimated': total_estimated,
+                        'acc_type': 'MA'
                     }
                     account_analytic_obj.calculate_estimated(cr, uid, man_op_account, total_estimated, 0, 0)
                     man_maq_account = account_analytic_obj.create(cr, uid, values)
@@ -327,14 +334,14 @@
                     for aux_mat in prod_op.components_used_ids:
                         total_estimated += aux_mat.product_id.standard_price * aux_mat.product_qty 
                     values = {
-                        'name':prod_mat_name_acc_code + " " + _('Materials') ,
-                        'code':prod_mat_name_acc_code ,
+                        'name': prod_mat_name_acc_code + " " + _('Materials') ,
+                        'code': prod_mat_name_acc_code ,
                         'currency_id': wizard_config.company_id.currency_id.id,
                         'company_id': wizard_config.company_id.id,
-                        'state':'open',
-                        'parent_id':man_op_account,
-                        'total_estimated':total_estimated,
-                        'acc_type':'MT'
+                        'state': 'open',
+                        'parent_id': man_op_account,
+                        'total_estimated': total_estimated,
+                        'acc_type': 'MT'
                     }
                     account_analytic_obj.calculate_estimated(cr, uid, man_op_account, total_estimated, 0, 0)
                     man_mat_account = account_analytic_obj.create(cr, uid, values)
@@ -379,14 +386,14 @@
                                 else:
                                     nombre  = manufact_worker.name.name
                                     values={
-                                        'name':prod_wrk_name_acc_code + " " + _('Worker')+ " " + str(nombre).encode('ascii', 'replace'),
-                                        'code':prod_wrk_name_acc_code ,
+                                        'name': prod_wrk_name_acc_code + " " + _('Worker')+ " " + str(nombre).encode('ascii', 'replace'),
+                                        'code': prod_wrk_name_acc_code ,
                                         'currency_id': wizard_config.company_id.currency_id.id,
                                         'company_id': wizard_config.company_id.id,
-                                        'state':'open',
-                                        'parent_id':man_op_account,
-                                        'total_estimated':total_estimated,
-                                        'acc_type':'WK'
+                                        'state': 'open',
+                                        'parent_id': man_op_account,
+                                        'total_estimated': total_estimated,
+                                        'acc_type': 'WK'
                                     }
                                     account_analytic_obj.calculate_estimated(cr, uid, man_op_account, total_estimated, 0, 0)
                                     man_wrk_account = account_analytic_obj.create(cr, uid, values)
@@ -409,16 +416,16 @@
                             
                             if not prod_wrk_acc:
                                 values = {
-                                    'name':prod_wrk_name_acc_code + " " + _('Operator') + " " + str(nombre).encode('ascii', 'replace'),
-                                    'code':prod_wrk_name_acc_code ,
+                                    'name': prod_wrk_name_acc_code + " " + _('Operator') + " " + str(nombre).encode('ascii', 'replace'),
+                                    'code': prod_wrk_name_acc_code ,
                                     'currency_id': wizard_config.company_id.currency_id.id,
                                     'company_id': wizard_config.company_id.id,
                                     'state':'open',
-                                    'parent_id':man_op_account,
-                                    'total_estimated':0,
+                                    'parent_id': man_op_account,
+                                    'total_estimated': 0,
                                     'total_estimated_puc': 0,
                                     'total_estimated_standard': 0,
-                                    'acc_type':'WK'
+                                    'acc_type': 'WK'
                                 }
                                 account_analytic_obj.calculate_estimated(cr, uid, man_op_account, total_estimated, 0, 0)
                                 man_wrk_account = account_analytic_obj.create(cr, uid, values)
@@ -446,15 +453,17 @@
             if not wc_account_id:
                 raise osv.except_osv(_('Programing Error'), _('The analytic account of the machine is not created. Code:' + " " + wc_acc_code))
             
+            # TODO: Change this to use code instead for translational option
+            # man_journal_search = account_analytic_jour_obj.search(cr, uid,[('code', '=', 'MRP')]) 
             man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', 'Manufacturing')])
             values = {
-                      'amount':wc_cost_amount*(-1),
-                      'name':wc_cost.descript,
-                      'date':wc_cost.date,
+                      'amount': wc_cost_amount*(-1),
+                      'name': wc_cost.descript,
+                      'date': wc_cost.date,
                       'company_in': wizard_config.company_id.id,
                       'account_id': wc_account_id,
                       'general_account_id': wizard_config.company_id.workcenter_account.id,
-                      'journal_id':man_journal_search[0],
+                      'journal_id': man_journal_search[0],
             }
             new_id = account_analytic_line_obj.create(cr, uid, values)          
             account_analytic_obj.recalculate_result(cr, uid, wc_account_id)
@@ -477,7 +486,9 @@
                     ope_account_id =  aux_result['parent_id']
             if not ope_account_id:
                 raise osv.except_osv(_('Programing Error'), _('The analytic account of the operator is not created. Code:' + " " + ope_acc_code))
-         
+            
+            # TODO: Change this to use code instead for translational option
+            # man_journal_search = account_analytic_jour_obj.search(cr, uid,[('code', '=', 'MRP')]) 
             man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', 'Manufacturing')])
             values = {
                       'amount':op_cost_amount*(-1),

=== modified file 'mrp_analytics_control/wizard/users.py'
--- mrp_analytics_control/wizard/users.py	2013-09-09 13:38:16 +0000
+++ mrp_analytics_control/wizard/users.py	2013-09-12 09:49:19 +0000
@@ -85,7 +85,8 @@
                 prod_op_acc = account_analytic_obj.search(cr, uid, [('code','=', prod__acc_code)])
                 if prod_op_acc:
                             
-                            
+                            # TODO: Change this to use code instead for translational option
+                            # man_journal_search = account_analytic_jour_obj.search(cr, uid,[('code', '=', 'MRP')])
                             man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', 'Manufacturing')])      
                             man_jounal = account_analytic_jour_obj.browse(cr, uid, man_journal_search[0])                            
                                
@@ -119,13 +120,13 @@
                                 user = self.pool.get('res.users').browse(cr,uid,usr)
                                 nombre  = user.name         
                                 values={
-                                    'name':prod_wrk_name_acc_code + " " + 'Operario '+ str(nombre),
-                                    'code':prod_wrk_name_acc_code ,
-                                    'currency_id':1,
-                                    'company_id':1,
-                                    'state':'open',
-                                    'parent_id':prod_op_acc[0],
-                                    'total_estimated':total_estimated,
+                                    'name': prod_wrk_name_acc_code + " " + 'Operario '+ str(nombre),
+                                    'code': prod_wrk_name_acc_code ,
+                                    'currency_id': user.company_id.currency_id.id,
+                                    'company_id': user.company_id.id,
+                                    'state': 'open',
+                                    'parent_id': prod_op_acc[0],
+                                    'total_estimated': total_estimated,
                                     }
                                 
                                 
@@ -160,13 +161,13 @@
             prod_wrk_name_acc_code = 'OF'+ str(prod_in) + 'OP' + str(op_in) + 'WK'+ str(user_in) 
                             
             values={
-            'name':prod_wrk_name_acc_code + " " + 'Operario '+ str(nombre),
-            'code':prod_wrk_name_acc_code ,
-            'currency_id':1,
-            'company_id':1,
-            'state':'open',
-            'parent_id':parent_account,
-            'acc_type':'OP'
+                'name': prod_wrk_name_acc_code + " " + _('Operator') + " " + str(nombre),
+                'code': prod_wrk_name_acc_code ,
+                'currency_id': usr.company_id.currency_id.id,
+                'company_id': usr.company_id.id,
+                'state': 'open',
+                'parent_id': parent_account,
+                'acc_type': 'OP'
                 }
                             
                             
@@ -212,7 +213,8 @@
             if not ope_account_id:
                 ope_account_id=self.create_new_analityc_operator_account(cr, uid, in_user, in_op, in_prod)                            
             
-            
+            # TODO: Change this to use code instead for translational option
+            # man_journal_search = account_analytic_jour_obj.search(cr, uid,[('code', '=', 'MRP')])
             man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', 'Manufacturing')])        
             man_journal = account_analytic_jour_obj.browse(cr, uid, man_journal_search[0])
             
@@ -220,10 +222,10 @@
             values = {'amount': op_cost_amount*(-1),
                       'name': str(usr.name) + ' worker imputation2',
                       'date': in_date,
-                      'company_id':1,
+                      'company_id': usr.company_id.id,
                       'account_id': ope_account_id,
                       'general_account_id': operator_account,
-                      'journal_id':man_journal.id,
+                      'journal_id': man_journal.id,
                       'ref': production.name,
                       'unit_amount': 1,
                       'product_id': usr.product_id.id
@@ -279,12 +281,12 @@
         
         values = {
           'wuser': us,
-          'user':context['wuser'],
-          'operation':op.id,
+          'user': context['wuser'],
+          'operation': op.id,
           'time': context['wtime'],
-          'date':context['work_date'],
-          'descript':context['descript'],
-          'production':prod.id,
+          'date': context['work_date'],
+          'descript': context['descript'],
+          'production': prod.id,
           'real_op' : real_id.id
             }
         
@@ -373,13 +375,13 @@
         
         values = {
           'wuser': us,
-          'user':context['wuser'],
-          'operation':op.id,
+          'user': context['wuser'],
+          'operation': op.id,
           'time': context['wtime'],
-          'date':context['work_date'],
-          'descript':context['descript'],
-          'production':prod.id,
-          'real_op' : real_id.id
+          'date': context['work_date'],
+          'descript': context['descript'],
+          'production': prod.id,
+          'real_op': real_id.id
             }
         
         res = ops_us_obj.create(cr, uid, values)
@@ -431,9 +433,9 @@
             us = us_search[len(us_search)-1]
         else:
             values = {
-                'user' :in_wuser,
-                'production_id':op.production_id.id,
-                'op':op.id,                
+                'user': in_wuser,
+                'production_id': op.production_id.id,
+                'op': op.id,                
                    }
             res = us_obj.create(cr, uid, values)
             us_search = us_obj.search(cr, uid,[('user', '=', in_wuser ),('op','=',op.id)])
@@ -449,13 +451,13 @@
         
         values = {
           'wuser': us,
-          'user':in_wuser,
-          'operation':op.id,
+          'user': in_wuser,
+          'operation': op.id,
           'time': in_wtime,
           'date': in_date,
-          'descript':in_desc,
-          'production':prod.id,
-          'real_op' : real_id.id
+          'descript': in_desc,
+          'production': prod.id,
+          'real_op': real_id.id
             }
         
         res = ops_us_obj.create(cr, uid, values)
@@ -536,10 +538,10 @@
                 
                      values = {
                                     'name': usr,
-                                    'op':check,
-                                    'prod':production,
-                                    'percent':percent,
-                                    'est_time':est_time
+                                    'op': check,
+                                    'prod': production,
+                                    'percent': percent,
+                                    'est_time': est_time
                                     }   
                      res = objs2.create(cr, uid, values)
                 
@@ -555,7 +557,8 @@
                      
                      if prod_op_acc:
                             
-                            
+                            # TODO: Change this to use code instead for translational option
+                            # man_journal_search = account_analytic_jour_obj.search(cr, uid,[('code', '=', 'MRP')])
                             man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', 'Manufacturing')])      
                             man_jounal = account_analytic_jour_obj.browse(cr, uid, man_journal_search[0])                            
                                
@@ -587,15 +590,15 @@
                             else:
                                 
                                 user = self.pool.get('res.users').browse(cr,uid,usr)
-                                nombre  = user.name         
+                                
                                 values={
-                                    'name':prod_wrk_name_acc_code + " " + 'Operario '+ str(nombre),
-                                    'code':prod_wrk_name_acc_code ,
-                                    'currency_id':1,
-                                    'company_id':1,
-                                    'state':'open',
-                                    'parent_id':prod_op_acc[0],
-                                    'total_estimated':total_estimated,
+                                    'name': prod_wrk_name_acc_code + " " + _('Operator') + " " + str(user.name),
+                                    'code': prod_wrk_name_acc_code ,
+                                    'currency_id': user.company_id.currency_id.id,
+                                    'company_id': user.company_id.id,
+                                    'state': 'open',
+                                    'parent_id': prod_op_acc[0],
+                                    'total_estimated': total_estimated,
                                     }
                                 
                                 
@@ -618,9 +621,9 @@
         account_analytic_obj = self.pool.get('account.analytic.account')
         acc_code = 'OF'+str(user.prod.id)+'OP'+str(user.op.id)+'WK'+ str(user.name.id)
         acc_id = account_analytic_obj.search(cr, uid,[('code','=',acc_code)])
-        account_analytic_obj.write(cr, uid,acc_id,{'total_estimated':0,
-                                                   'total_estimated_puc':0,
-                                                   'total_estimated_standard':0} )
+        account_analytic_obj.write(cr, uid,acc_id,{'total_estimated': 0,
+                                                   'total_estimated_puc': 0,
+                                                   'total_estimated_standard': 0} )
         self.unlink(cr, uid,ids, context=context)
         return False
-mrp_production_users()
\ No newline at end of file
+mrp_production_users()

=== modified file 'mrp_analytics_control/wizard/wc.py'
--- mrp_analytics_control/wizard/wc.py	2013-09-05 07:08:33 +0000
+++ mrp_analytics_control/wizard/wc.py	2013-09-12 09:49:19 +0000
@@ -38,9 +38,9 @@
         #Crear cuenta analitica de operadores
                         
             account_analityc_obj = self.pool.get('account.analytic.account')              
-                                                                             
-            usr_object = self.pool.get('res.users')
-            usr = usr_object.browse(cr,uid,user_in)
+            
+            usr = self.pool.get('res.users').browse(cr,uid,user_in)
+            company = self.pool.get('res.company').browse(cr, uid, user.company_id.id)
             nombre  = usr.name      
             
             parent_code = 'OF'+ str(prod_in) + 'OP' + str(op_in)
@@ -51,13 +51,13 @@
             prod_wrk_name_acc_code = 'OF'+ str(prod_in) + 'OP' + str(op_in) + 'WK'+ str(user_in) 
                             
             values={
-            'name':prod_wrk_name_acc_code + " " + 'Operario '+ str(nombre),
-            'code':prod_wrk_name_acc_code ,
-            'currency_id':1,
-            'company_id':1,
-            'state':'open',
-            'parent_id':parent_account,
-            'acc_type':'MA'
+                'name': prod_wrk_name_acc_code + " " + _('Operator') + " " + str(nombre),
+                'code': prod_wrk_name_acc_code ,
+                'currency_id': company.currency_id.id,
+                'company_id': company.id, 
+                'state': 'open',
+                'parent_id': parent_account,
+                'acc_type': 'MA'
                 }
                             
                             
@@ -95,18 +95,19 @@
             for aux_var in account_search:
                 ope_account_id = aux_var
             
-            
+            # TODO: Change this to use code instead for translational option
+            # man_journal_search = account_analytic_jour_obj.search(cr, uid,[('code', '=', 'MRP')])
             man_journal_search = account_analytic_jour_obj.search(cr, uid,[('name', '=', 'Manufacturing')])        
             man_journal = account_analytic_jour_obj.browse(cr, uid, man_journal_search[0])
             
             values = {
-                      'amount':op_cost_amount*(-1),
-                      'name':in_description,
-                      'date':in_date,
-                      'company_id':1,
+                      'amount': op_cost_amount*(-1),
+                      'name': in_description,
+                      'date': in_date,
+                      'company_id': wc.factory_id.company_id.id,
                       'account_id': ope_account_id,
-                      'general_account_id':1185,
-                      'journal_id':man_journal.id,
+                      'general_account_id': wc.factory_id.company_id.workcenter_account.id,
+                      'journal_id': man_journal.id,
                       }
             new_id = account_analytic_line_obj.create(cr, uid, values)          
             account_analytic_obj.recalculate_result(cr, uid, ope_account_id)   
@@ -138,11 +139,11 @@
         
         values = {
           'wc': context['wc'],
-          'operation':context['operation'],
+          'operation': context['operation'],
           'time': context['wtime'],
-          'date':context['work_date'],
-          'descript':context['descript'],
-          'production':prod.id,
+          'date': context['work_date'],
+          'descript': context['descript'],
+          'production': prod.id,
           'real_op' : real_id.id
             }
         
@@ -210,4 +211,4 @@
 
         
         return {'type': 'ir.actions.act_window_close'}
-new_input_time_wc()
\ No newline at end of file
+new_input_time_wc()


Follow ups