Ashvin Rathod (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-812027-ara into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #812027 in OpenERP Addons: "Multicompany - recurring entries - generate 
entries"
  https://bugs.launchpad.net/openobject-addons/+bug/812027

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-812027-ara/+merge/69447

Hello,

Fix: Multicompany - recurring entries - generate entries

Thanks,
ara
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-812027-ara/+merge/69447
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-812027-ara.
=== modified file 'account/account.py'
--- account/account.py	2011-07-18 08:34:24 +0000
+++ account/account.py	2011-07-27 12:32:55 +0000
@@ -2107,6 +2107,7 @@
         account_move_obj = self.pool.get('account.move')
         account_move_line_obj = self.pool.get('account.move.line')
         pt_obj = self.pool.get('account.payment.term')
+        period_obj = self.pool.get('account.period')
 
         if context is None:
             context = {}
@@ -2114,12 +2115,11 @@
         if datas.get('date', False):
             context.update({'date': datas['date']})
 
-        period_id = self.pool.get('account.period').find(cr, uid, dt=context.get('date', False))
-        if not period_id:
-            raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
-        period_id = period_id[0]
-
         for model in self.browse(cr, uid, ids, context=context):
+            period_id = period_obj.search(cr, uid, [('date_start','<=',context.get('date', False)), ('date_stop','>=',context.get('date', False)), ('company_id', '=', model.company_id.id)])
+            if not period_id:
+                raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
+            period_id = period_id[0]
             entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%Y-%m')}
             move_id = account_move_obj.create(cr, uid, {
                 'ref': entry['name'],

=== modified file 'account/account_view.xml'
--- account/account_view.xml	2011-07-22 13:42:35 +0000
+++ account/account_view.xml	2011-07-27 12:32:55 +0000
@@ -1595,7 +1595,7 @@
                 <tree string="Journal Entry Model Line" editable="bottom">
                     <field name="sequence"/>
                     <field name="name"/>
-                    <field name="account_id"/>
+                    <field name="account_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation'), ('company_id', '=', parent.company_id)]"/>
                     <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
                     <field name="partner_id"/>
                     <field name="debit"/>
@@ -1614,7 +1614,7 @@
                 <form string="Journal Entry Model Line">
                     <field colspan="4" name="name" select="1"/>
                     <field name="sequence"/>
-                    <field name="account_id" domain="[('type','&lt;&gt;','view'),('type','&lt;&gt;','consolidation')]"/>
+                    <field name="account_id" domain="[('type','&lt;&gt;','view'), ('type','&lt;&gt;','consolidation'), ('company_id', '=', parent.company_id)]"/>
                     <field name="analytic_account_id" groups="analytic.group_analytic_accounting"/>
                     <field name="partner_id"/>
                     <field name="debit" select="1"/>

=== modified file 'account/wizard/account_use_model.py'
--- account/wizard/account_use_model.py	2011-01-27 06:32:26 +0000
+++ account/wizard/account_use_model.py	2011-07-27 12:32:55 +0000
@@ -52,6 +52,7 @@
         account_move_line_obj = self.pool.get('account.move.line')
         pt_obj = self.pool.get('account.payment.term')
         mod_obj = self.pool.get('ir.model.data')
+        period_obj = self.pool.get('account.period')
         if context is None:
             context = {}
         move_ids = []
@@ -64,7 +65,7 @@
             data_model = account_model_obj.browse(cr, uid, context['active_ids'], context=context)
         for model in data_model:
             entry['name'] = model.name%{'year':time.strftime('%Y'), 'month':time.strftime('%m'), 'date':time.strftime('%d')}
-            period_id = account_period_obj.find(cr, uid, context=context)
+            period_id = period_obj.search(cr, uid, [('company_id', '=', model.company_id.id)])
             if not period_id:
                 raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
             period_id = period_id[0]

_______________________________________________
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