Priyesh (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.0-opw-5852-pso into 
lp:openobject-addons/6.0.

Requested reviews:
  qdp (OpenERP) (qdp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-5852-pso/+merge/66682

Hello,

Passed company in context during the Payment for Invoice the invoice in 
multi-company environment.
Improved find method of Period.

Thanks,
Priyesh
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-5852-pso/+merge/66682
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.0-opw-5852-pso.
=== modified file 'account/account.py'
--- account/account.py	2011-06-22 20:05:58 +0000
+++ account/account.py	2011-07-02 04:43:25 +0000
@@ -907,10 +907,14 @@
         return False
 
     def find(self, cr, uid, dt=None, context=None):
+        if context is None: context = {}
         if not dt:
             dt = time.strftime('%Y-%m-%d')
 #CHECKME: shouldn't we check the state of the period?
-        ids = self.search(cr, uid, [('date_start','<=',dt),('date_stop','>=',dt)])
+        args = [('date_start', '<=' ,dt), ('date_stop', '>=', dt)]
+        if context.get('company_id', False):
+            args.append(('company_id', '=', context['company_id']))
+        ids = self.search(cr, uid, args, context=context)
         if not ids:
             raise osv.except_osv(_('Error !'), _('No period defined for this date: %s !\nPlease create a fiscal year.')%dt)
         return ids

=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py	2011-05-20 10:29:05 +0000
+++ account_voucher/account_voucher.py	2011-07-02 04:43:25 +0000
@@ -39,7 +39,10 @@
         if context is None: context = {}
         if context.get('period_id', False):
             return context.get('period_id')
-        periods = self.pool.get('account.period').find(cr, uid)
+        if context.get('invoice_id', False):
+            company_id = self.pool.get('account.invoice').browse(cr, uid, context['invoice_id'], context=context).company_id.id
+            context.update({'company_id': company_id})
+        periods = self.pool.get('account.period').find(cr, uid, context=context)
         return periods and periods[0] or False
 
     def _get_journal(self, cr, uid, context=None):
@@ -535,7 +538,10 @@
         """
         period_pool = self.pool.get('account.period')
         res = self.onchange_partner_id(cr, uid, ids, partner_id, journal_id, price, currency_id, ttype, date, context=context)
-        pids = period_pool.search(cr, uid, [('date_start', '<=', date), ('date_stop', '>=', date)])
+        if context.get('invoice_id', False):
+            company_id = self.pool.get('account.invoice').browse(cr, uid, context['invoice_id'], context=context).company_id.id
+            context.update({'company_id':company_id})
+        pids = period_pool.find(cr, uid, date, context=context)
         if pids:
             if not 'value' in res:
                 res['value'] = {}

_______________________________________________
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