← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/6.0-bug-724198-jma into lp:openobject-addons/6.0

 

JMA(Open ERP) has proposed merging lp:~openerp-dev/openobject-addons/6.0-bug-724198-jma into lp:openobject-addons/6.0.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #724198 in OpenERP Addons: "[6.0] Invoicing values from wizard are lost when creating purchase invoice from receptions"
  https://bugs.launchpad.net/openobject-addons/+bug/724198

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-bug-724198-jma/+merge/52835
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-bug-724198-jma/+merge/52835
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/6.0-bug-724198-jma.
=== modified file 'stock/wizard/stock_invoice_onshipping.py'
--- stock/wizard/stock_invoice_onshipping.py	2011-01-17 08:00:48 +0000
+++ stock/wizard/stock_invoice_onshipping.py	2011-03-10 12:49:19 +0000
@@ -34,41 +34,43 @@
             return []
 
         model_pool = self.pool.get(model)
-        acct_obj = self.pool.get('account.journal')
+        journal_obj = self.pool.get('account.journal')
         res_ids = context and context.get('active_ids', [])
-        vals=[]
-        pick_types = list(set(map(lambda x: x.type, model_pool.browse(cr, uid, res_ids, context=context))))
-        for type in pick_types:
-            if type == 'out':
-               value = acct_obj.search(cr, uid, [('type', 'in',('sale','purchase_refund') )])
-               for jr_type in acct_obj.browse(cr, uid, value, context=context):
-                   t1 = jr_type.id,jr_type.name
-                   vals.append(t1)
-
-            elif type == 'in':
-               value = acct_obj.search(cr, uid, [('type', 'in',('purchase','sale_refund') )])
-               for jr_type in acct_obj.browse(cr, uid, value, context=context):
-                   t1 = jr_type.id,jr_type.name
-                   vals.append(t1)
+        vals = []
+        browse_picking = model_pool.browse(cr, uid, res_ids, context=context)
+        
+        for pick in browse_picking:
+            src_usage = pick.move_lines[0].location_id.usage
+            dest_usage = pick.move_lines[0].location_dest_id.usage
+            type = pick.type
+            if type == 'out' and dest_usage == 'supplier':
+                journal_type = 'purchase_refund'
+            elif type == 'out' and dest_usage == 'customer':
+                journal_type = 'sale'
+            elif type == 'in' and src_usage == 'supplier':
+                journal_type = 'purchase'
+            elif type == 'in' and src_usage == 'customer':
+                journal_type = 'sale_refund'
             else:
-               value = acct_obj.search(cr, uid, [('type', 'in',('cash','bank','general','situation') )])
-               for jr_type in acct_obj.browse(cr, uid, value, context=context):
-                   t1 = jr_type.id,jr_type.name
-                   vals.append(t1)
+                journal_type = 'sale'
+                
+            value = journal_obj.search(cr, uid, [('type', '=',journal_type )])
+            for jr_type in journal_obj.browse(cr, uid, value, context=context):
+                t1 = jr_type.id,jr_type.name
+                if t1 not in vals:
+                    vals.append(t1)
         return vals
 
 
     _name = "stock.invoice.onshipping"
     _description = "Stock Invoice Onshipping"
 
-
     _columns = {
         'journal_id': fields.selection(_get_journal_id, 'Destination Journal',required=True),
         'group': fields.boolean("Group by partner"),
         'invoice_date': fields.date('Invoiced date'),
     }
 
-
     def view_init(self, cr, uid, fields_list, context=None):
         if context is None:
             context = {}


Follow ups