Hardik Ansodariya (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-usability-create_invoice_from_picking-han
 into lp:~openerp-dev/openobject-addons/trunk-usability.

Requested reviews:
  Amit (Open ERP) (apa-tiny)
  Hardik Ansodariya (OpenERP) (han-tinyerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-usability-create_invoice_from_picking-han/+merge/74415
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-usability-create_invoice_from_picking-han/+merge/74415
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-usability.
=== modified file 'stock/wizard/stock_invoice_onshipping.py'
--- stock/wizard/stock_invoice_onshipping.py	2011-05-02 18:46:43 +0000
+++ stock/wizard/stock_invoice_onshipping.py	2011-09-07 12:40:23 +0000
@@ -25,6 +25,24 @@
 
 class stock_invoice_onshipping(osv.osv_memory):
 
+    def _get_journal(self, cr, uid, context=None):
+        if context is None:
+            context = {}
+        stock =  self.pool.get('stock.picking')
+        stock_browse = stock.browse(cr, uid, context.get('active_id'))
+        if stock_browse.type == 'out':
+            type_inv = 'out'
+        elif stock_browse.type == 'in':
+            type_inv = 'in'
+        user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
+        company_id = context.get('company_id', user.company_id.id)
+        type2journal = {'out': 'sale', 'in': 'purchase'}
+        journal_obj = self.pool.get('account.journal')
+        res = journal_obj.search(cr, uid, [('type', '=', type2journal.get(type_inv)),
+                                            ('company_id', '=', company_id)],
+                                                limit=1)
+        return res and res[0] or False
+    
     def _get_journal_id(self, cr, uid, context=None):
         if context is None:
             context = {}
@@ -61,7 +79,6 @@
                     vals.append(t1)
         return vals
 
-
     _name = "stock.invoice.onshipping"
     _description = "Stock Invoice Onshipping"
 
@@ -70,7 +87,11 @@
         'group': fields.boolean("Group by partner"),
         'invoice_date': fields.date('Invoiced date'),
     }
-
+    
+    _defaults = {
+        'journal_id' : _get_journal,
+    }
+    
     def view_init(self, cr, uid, fields_list, context=None):
         if context is None:
             context = {}

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to