[IMP] if 'cash control' if false in the journal, no need to have the opening and...
authorParamjit Singh Sahota <psa@tinyerp.com>
Wed, 18 Sep 2013 09:10:41 +0000 (14:40 +0530)
committerParamjit Singh Sahota <psa@tinyerp.com>
Wed, 18 Sep 2013 09:10:41 +0000 (14:40 +0530)
bzr revid: psa@tinyerp.com-20130918091041-c5zponkbu5uwgb94

addons/account/account_bank_statement.py
addons/account/account_cash_statement.py
addons/account/account_view.xml

index a573077..d927dcf 100644 (file)
@@ -128,6 +128,7 @@ class account_bank_statement(osv.osv):
         'currency': fields.function(_currency, string='Currency',
             type='many2one', relation='res.currency'),
         'account_id': fields.related('journal_id', 'default_debit_account_id', type='many2one', relation='account.account', string='Account used in this journal', readonly=True, help='used in statement reconciliation domain, but shouldn\'t be used elswhere.'),
+        'cash_control': fields.related('journal_id', 'cash_control' , type='boolean', relation='account.journal',string='Cash control'),
     }
 
     _defaults = {
@@ -460,12 +461,12 @@ class account_bank_statement(osv.osv):
     def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None):
         if not journal_id:
             return {}
+        if context is None:
+           context = {}
         balance_start = self._compute_balance_end_real(cr, uid, journal_id, context=context)
-
-        journal_data = self.pool.get('account.journal').read(cr, uid, journal_id, ['company_id', 'currency'], context=context)
-        company_id = journal_data['company_id']
-        currency_id = journal_data['currency'] or self.pool.get('res.company').browse(cr, uid, company_id[0], context=context).currency_id.id
-        return {'value': {'balance_start': balance_start, 'company_id': company_id, 'currency': currency_id}}
+        journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context)
+        currency = journal.currency or journal.company_id.currency_id
+        return {'value': {'balance_start': balance_start, 'company_id': journal.company_id.id, 'currency': currency.id, 'cash_control': journal.cash_control}}
 
     def unlink(self, cr, uid, ids, context=None):
         stat = self.read(cr, uid, ids, ['state'], context=context)
index 8fe8600..731c521 100644 (file)
@@ -225,10 +225,6 @@ class account_cash_statement(osv.osv):
                 string="Starting Balance",
                 help="Total of opening cash control lines.",
                 readonly=True),
-        'cash_register_total_entry_encoding' : fields.related('cash_register_id', 'total_entry_encoding',
-                string='Total Cash Transaction',
-                readonly=True,
-                help="Total of all paid sale orders"),
         'cash_register_balance_end' : fields.related('cash_register_id', 'balance_end',
                 type='float',
                 digits_compute=dp.get_precision('Account'),
index 4a57559..96eb2d2 100644 (file)
                             <field name="closing_date" readonly="1"/>
                             <field name="period_id" class="oe_inline"/>
                             <field name="currency" invisible="1"/>
+                            <field name="cash_control" invisible="1"/>
                         </group>
                     </group>
                     <notebook>
-                        <page string="Cash Control">
+                        <page string="Cash Control" attrs="{'invisible' : [('cash_control', '=', False)]}">
                             <group col="2" expand="1">
                                 <group string="Opening Cash Control" attrs="{'invisible' : [('state', '!=', 'draft')]}">
                                     <field name="opening_details_ids" colspan="2" nolabel="1">
                         </page>
                     </notebook>
                     <group>
-                        <group class="oe_subtotal_footer oe_right">
+                        <group class="oe_subtotal_footer oe_right" attrs="{'invisible' : [('cash_control', '=', False)]}">
                             <field name="balance_start" readonly="1" string="Opening Balance" class="oe_subtotal_footer_separator oe_open_balance" widget="monetary" options="{'currency_field': 'currency'}" help="Total of opening cash control lines"/>
                             <label for="total_entry_encoding" string="+ Transactions" class="oe_force_bold oe_mini_subtotal_footer_separator"/>
                             <field name="total_entry_encoding" nolabel="1" class="oe_bold oe_account_total" widget="monetary" options="{'currency_field': 'currency'}"/>
                             <field name="balance_end" nolabel="1" class="oe_bold oe_account_total" widget="monetary" options="{'currency_field': 'currency'}"/>
                         </group>
                         <div>
-                            <group class="oe_subtotal_footer oe_right" attrs="{'invisible' : [('state', '=', 'draft')]}">
+                            <group class="oe_subtotal_footer oe_right" attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', '=', 'draft')]}">
                                 <field name="balance_end_real" readonly="1" string="Real Closing Balance" class="oe_subtotal_footer_separator oe_real_closing_balance" widget="monetary" options="{'currency_field': 'currency'}" help="Total of closing cash control lines."/>
                             </group>
                             <group/>
                             <group/>
-                            <group class="oe_subtotal_footer oe_right" attrs="{'invisible' : [('state', '=', 'draft')]}">
+                            <group class="oe_subtotal_footer oe_right" attrs="{'invisible': ['|', ('cash_control', '=', False), ('state', '=', 'draft')]}">
                                 <field name="difference" class="oe_subtotal_footer_separator oe_difference" widget="monetary" options="{'currency_field': 'currency'}"/>
                             </group>
                         </div>