[IMP] Improved code as per the suggestions on the Merge proposal.
bzr revid: psa@tinyerp.com-20131230072452-zew8ys6lqomzxcsm
This commit is contained in:
parent
0bcd78116f
commit
7980ac78ae
|
@ -451,18 +451,18 @@ class account_bank_statement(osv.osv):
|
|||
def _compute_balance_end_real(self, cr, uid, journal_id, context=None):
|
||||
res = False
|
||||
journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context)
|
||||
if journal.with_last_closing_balance:
|
||||
cr.execute('SELECT balance_end_real \
|
||||
FROM account_bank_statement \
|
||||
WHERE journal_id = %s AND NOT state = %s \
|
||||
ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft'))
|
||||
res = cr.fetchone()
|
||||
if journal_id:
|
||||
if journal.with_last_closing_balance:
|
||||
cr.execute('SELECT balance_end_real \
|
||||
FROM account_bank_statement \
|
||||
WHERE journal_id = %s AND NOT state = %s \
|
||||
ORDER BY date DESC,id DESC LIMIT 1', (journal_id, 'draft'))
|
||||
res = cr.fetchone()
|
||||
return res and res[0] or 0.0
|
||||
|
||||
def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None):
|
||||
if not journal_id:
|
||||
return {}
|
||||
res = {}
|
||||
balance_start = self._compute_balance_end_real(cr, uid, journal_id, context=context)
|
||||
journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context)
|
||||
currency = journal.currency or journal.company_id.currency_id
|
||||
|
|
|
@ -220,9 +220,9 @@ class account_cash_statement(osv.osv):
|
|||
return details_ids
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
journal_id = vals.get('journal_id',False)
|
||||
if journal_id:
|
||||
vals['opening_details_ids'] = vals.get('opening_details_ids',False) or self._get_cash_open_box_lines(cr, uid, journal_id, context)
|
||||
journal_id = vals.get('journal_id')
|
||||
if journal_id and not vals.get('opening_details_ids'):
|
||||
vals['opening_details_ids'] = vals.get('opening_details_ids') or self._get_cash_open_box_lines(cr, uid, journal_id, context)
|
||||
res_id = super(account_cash_statement, self).create(cr, uid, vals, context=context)
|
||||
self._update_balances(cr, uid, [res_id], context)
|
||||
return res_id
|
||||
|
@ -241,10 +241,10 @@ class account_cash_statement(osv.osv):
|
|||
@return: True on success, False otherwise
|
||||
"""
|
||||
|
||||
cashbox_pool = self.pool.get('account.cashbox.line')
|
||||
cashbox_line_obj = self.pool.get('account.cashbox.line')
|
||||
if vals.get('journal_id', False):
|
||||
cashbox_ids = cashbox_pool.search(cr, uid, [('bank_statement_id', 'in', ids)], context=context)
|
||||
cashbox_pool.unlink(cr, uid, cashbox_ids, context)
|
||||
cashbox_ids = cashbox_line_obj.search(cr, uid, [('bank_statement_id', 'in', ids)], context=context)
|
||||
cashbox_line_obj.unlink(cr, uid, cashbox_ids, context)
|
||||
res = super(account_cash_statement, self).write(cr, uid, ids, vals, context=context)
|
||||
self._update_balances(cr, uid, ids, context)
|
||||
return res
|
||||
|
|
|
@ -2355,7 +2355,6 @@
|
|||
<group class="oe_subtotal_footer oe_right" attrs="{'invisible': [('state', '=', 'draft')]}">
|
||||
<label for="balance_end_real" class="oe_subtotal_footer_separator oe_real_closing_balance" string="Real Closing Balance" style="padding-right: 23px !important; padding-top: 6px !important;"/>
|
||||
<field name="balance_end_real" attrs="{'readonly' : ['|', ('cash_control', '=', True), ('state', '=', 'confirm')]}" nolabel="1" 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/>
|
||||
|
|
|
@ -46,16 +46,15 @@ class pos_config(osv.osv):
|
|||
]
|
||||
|
||||
def _get_currency(self, cr, uid, ids, fieldnames, args, context=None):
|
||||
result = {}
|
||||
currency_id = False
|
||||
user = self.pool.get('res.users')
|
||||
for pos_config in self.browse(cr, uid, ids, context=context):
|
||||
if pos_config.journal_id:
|
||||
currency_id = pos_config.journal_id.currency.id or pos_config.journal_id.company_id.currency_id.id
|
||||
else:
|
||||
currency_id = user.browse(cr, uid, pos_config.id, context=context).company_id.currency_id.id
|
||||
result[pos_config.id] = currency_id
|
||||
return result
|
||||
result = dict.fromkeys(ids, False)
|
||||
user = self.pool.get('res.users')
|
||||
for pos_config in self.browse(cr, uid, ids, context=context):
|
||||
if pos_config.journal_id:
|
||||
currency_id = pos_config.journal_id.currency.id or pos_config.journal_id.company_id.currency_id.id
|
||||
else:
|
||||
currency_id = user.browse(cr, uid, uid, context=context).company_id.currency_id.id
|
||||
result[pos_config.id] = currency_id
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'name' : fields.char('Point of Sale Name', size=32, select=1,
|
||||
|
|
Loading…
Reference in New Issue