[MERGE] staging branch with misc fixes in accounting
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Tue, 4 Dec 2012 09:10:14 +0000 (10:10 +0100)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Tue, 4 Dec 2012 09:10:14 +0000 (10:10 +0100)
bzr revid: qdp-launchpad@openerp.com-20121204091014-89ck1ditngl1u12c

addons/account/account_invoice.py
addons/account/account_view.xml
addons/account_voucher/invoice.py
addons/analytic/analytic.py

index f89f782..5215980 100644 (file)
@@ -294,6 +294,18 @@ class account_invoice(osv.osv):
         ('number_uniq', 'unique(number, company_id, journal_id, type)', 'Invoice Number must be unique per Company!'),
     ]
 
+    def _find_partner(self, inv):
+        '''
+        Find the partner for which the accounting entries will be created
+        '''
+        #if the chosen partner is not a company and has a parent company, use the parent for the journal entries 
+        #because you want to invoice 'Agrolait, accounting department' but the journal items are for 'Agrolait'
+        part = inv.partner_id
+        if part.parent_id and not part.is_company:
+            part = part.parent_id
+        return part
+
+
     def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False):
         journal_obj = self.pool.get('account.journal')
         if context is None:
@@ -959,11 +971,7 @@ class account_invoice(osv.osv):
 
             date = inv.date_invoice or time.strftime('%Y-%m-%d')
 
-            #if the chosen partner is not a company and has a parent company, use the parent for the journal entries 
-            #because you want to invoice 'Agrolait, accounting department' but the journal items are for 'Agrolait'
-            part = inv.partner_id
-            if part.parent_id and not part.is_company:
-                part = part.parent_id
+            part = self._find_partner(inv)
 
             line = map(lambda x:(0,0,self.line_get_convert(cr, uid, x, part.id, date, context=ctx)),iml)
 
index e2c45af..6d3519c 100644 (file)
                     <field name="invoice" invisible="1"/>
                     <field name="amount_currency" readonly="True" invisible="not context.get('currency',False)"/>
                     <field name="currency_id" readonly="True" invisible="not context.get('currency',False)" />
-                    <field name="state" />
+                    <field name="state" invisible="1"/>
                     <field name="company_id" invisible="1"/>
                 </tree>
             </field>
             </field>
         </record>
         <menuitem
-             name="Journal Items to Reconcile"
-             action="action_account_manual_reconcile"
-             id="menu_manual_reconcile_bank"
-             sequence="20"
-             parent="account.menu_finance_bank_and_cash"/>
-        <menuitem
              name="Manual Reconciliation"
              action="action_account_manual_reconcile"
              id="menu_manual_reconcile"
             context="{'search_default_journal_id': active_id, 'default_journal_id': active_id}"
             res_model="account.move.line"
             src_model="account.move"/>
+
         <act_window
             domain="[('reconcile_id', '=', active_id)]"
             id="act_account_acount_move_line_reconcile_open"
index 91ba438..426027f 100644 (file)
@@ -40,7 +40,7 @@ class invoice(osv.osv):
             'target': 'new',
             'domain': '[]',
             'context': {
-                'default_partner_id': inv.partner_id.id,
+                'default_partner_id': self._find_partner(inv),
                 'default_amount': inv.type in ('out_refund', 'in_refund') and -inv.residual or inv.residual,
                 'default_number':inv.name,
                 'close_after_process': True,
index 542acb1..782fbc4 100644 (file)
@@ -120,7 +120,7 @@ class account_analytic_account(osv.osv):
     def _get_one_full_name(self, elmt, level=6):
         if level<=0:
             return '...'
-        if elmt.parent_id:
+        if elmt.parent_id and not elmt.type == 'template':
             parent_path = self._get_one_full_name(elmt.parent_id, level-1) + "/"
         else:
             parent_path = ''