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

Requested reviews:
  Purnendu Singh (OpenERP) (psi-tinyerp)
  qdp (OpenERP) (qdp)
  Mustufa Rangwala (Open ERP) (mra-tinyerp)
  Ashvin Rathod (OpenERP) (ara-tinyerp)
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-11-14 10:39:45 +0000
+++ account/account.py	2011-11-16 07:13:28 +0000
@@ -2186,6 +2186,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 = {}
@@ -2193,14 +2194,12 @@
         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]
-
         move_date = context.get('date', time.strftime('%Y-%m-%d'))
         move_date = datetime.strptime(move_date,"%Y-%m-%d")
         for model in self.browse(cr, uid, ids, context=context):
+            context.update({'company_id': model.company_id.id})
+            period_ids = period_obj.find(cr, uid, dt=context.get('date', False), context=context)
+            period_id = period_ids and period_ids[0] or False
             try:
                 entry['name'] = model.name%{'year': move_date.strftime('%Y'), 'month': move_date.strftime('%m'), 'date': move_date.strftime('%Y-%m')}
             except:

=== modified file 'account/account_view.xml'
--- account/account_view.xml	2011-11-14 11:34:05 +0000
+++ account/account_view.xml	2011-11-16 07:13:28 +0000
@@ -1626,7 +1626,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"/>
@@ -1645,12 +1645,12 @@
                 <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"/>
                     <field name="credit" select="1"/>
-                     <field name="quantity"/>
+                    <field name="quantity"/>
                     <field name="date_maturity"/>
                 </form>
             </field>

=== 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-11-16 07:13:28 +0000
@@ -64,10 +64,9 @@
             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)
-            if not period_id:
-                raise osv.except_osv(_('No period found !'), _('Unable to find a valid period !'))
-            period_id = period_id[0]
+            context.update({'company_id': model.company_id.id})
+            period_ids = account_period_obj.find(cr, uid, context=context)
+            period_id = period_ids and period_ids[0] or False
             move_id = account_move_obj.create(cr, uid, {
                 'ref': entry['name'],
                 'period_id': period_id,

_______________________________________________
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