Skip to content

Commit

Permalink
[MERGE] new v8 api by rco
Browse files Browse the repository at this point in the history
A squashed merge is required as the conversion of the apiculture branch from
bzr to git was not correctly done. The git history contains irrelevant blobs
and commits. This branch brings a lot of changes and fixes, too many to list
exhaustively.

- New orm api, objects are now used instead of ids
- Environements to encapsulates cr uid context while maintaining backward compatibility
- Field compute attribute is a new object oriented way to define function fields
- Shared browse record cache
- New onchange protocol
- Optional copy flag on fields
- Documentation update
- Dead code cleanup
- Lots of fixes
  • Loading branch information
rco-odoo authored and antonylesuisse committed Jul 6, 2014
1 parent d78192c commit cbe2dbb
Show file tree
Hide file tree
Showing 426 changed files with 14,969 additions and 12,632 deletions.
158 changes: 63 additions & 95 deletions addons/account/account.py

Large diffs are not rendered by default.

53 changes: 25 additions & 28 deletions addons/account/account_bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def _get_period(self, cr, uid, context=None):
return False

def _compute_default_statement_name(self, cr, uid, journal_id, context=None):
if context is None:
context = {}
context = dict(context or {})
obj_seq = self.pool.get('ir.sequence')
period = self.pool.get('account.period').browse(cr, uid, self._get_period(cr, uid, context=context), context=context)
context['fiscalyear_id'] = period.fiscalyear_id.id
Expand Down Expand Up @@ -114,8 +113,16 @@ def _all_lines_reconciled(self, cr, uid, ids, name, args, context=None):
_description = "Bank Statement"
_inherit = ['mail.thread']
_columns = {
'name': fields.char('Reference', states={'draft': [('readonly', False)]}, readonly=True, help='if you give the Name other then /, its created Accounting Entries Move will be with same name as statement name. This allows the statement entries to have the same references than the statement itself'), # readonly for account_cash_statement
'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}, select=True),
'name': fields.char(
'Reference', states={'draft': [('readonly', False)]},
readonly=True, # readonly for account_cash_statement
copy=False,
help='if you give the Name other then /, its created Accounting Entries Move '
'will be with same name as statement name. '
'This allows the statement entries to have the same references than the '
'statement itself'),
'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]},
select=True, copy=False),
'journal_id': fields.many2one('account.journal', 'Journal', required=True,
readonly=True, states={'draft':[('readonly',False)]}),
'period_id': fields.many2one('account.period', 'Period', required=True,
Expand All @@ -132,14 +139,15 @@ def _all_lines_reconciled(self, cr, uid, ids, name, args, context=None):
string="Computed Balance", help='Balance as calculated based on Opening Balance and transaction lines'),
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
'line_ids': fields.one2many('account.bank.statement.line',
'statement_id', 'Statement lines',
states={'confirm':[('readonly', True)]}),
'statement_id', 'Statement lines',
states={'confirm':[('readonly', True)]}, copy=True),
'move_line_ids': fields.one2many('account.move.line', 'statement_id',
'Entry lines', states={'confirm':[('readonly',True)]}),
'Entry lines', states={'confirm':[('readonly',True)]}),
'state': fields.selection([('draft', 'New'),
('open','Open'), # used by cash statements
('confirm', 'Closed')],
'Status', required=True, readonly="1",
copy=False,
help='When new statement is created the status will be \'Draft\'.\n'
'And after getting confirmation from the bank it will be in \'Confirmed\' status.'),
'currency': fields.function(_currency, string='Currency',
Expand Down Expand Up @@ -182,7 +190,7 @@ def onchange_date(self, cr, uid, ids, date, company_id, context=None):
pids = period_pool.find(cr, uid, dt=date, context=ctx)
if pids:
res.update({'period_id': pids[0]})
context.update({'period_id': pids[0]})
context = dict(context, period_id=pids[0])

return {
'value':res,
Expand Down Expand Up @@ -363,24 +371,13 @@ def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None):
return {'value': res}

def unlink(self, cr, uid, ids, context=None):
stat = self.read(cr, uid, ids, ['state'], context=context)
unlink_ids = []
for t in stat:
if t['state'] in ('draft'):
unlink_ids.append(t['id'])
else:
raise osv.except_osv(_('Invalid Action!'), _('In order to delete a bank statement, you must first cancel it to delete related journal items.'))
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
return True

def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
if context is None:
context = {}
default = default.copy()
default['move_line_ids'] = []
return super(account_bank_statement, self).copy(cr, uid, id, default, context=context)
for item in self.browse(cr, uid, ids, context=context):
if item.state != 'draft':
raise osv.except_osv(
_('Invalid Action!'),
_('In order to delete a bank statement, you must first cancel it to delete related journal items.')
)
return super(account_bank_statement, self).unlink(cr, uid, ids, context=context)

def button_journal_entries(self, cr, uid, ids, context=None):
ctx = (context or {}).copy()
Expand Down Expand Up @@ -806,8 +803,8 @@ def _needaction_domain_get(self, cr, uid, context=None):
_description = "Bank Statement Line"
_inherit = ['ir.needaction_mixin']
_columns = {
'name': fields.char('Description', required=True),
'date': fields.date('Date', required=True),
'name': fields.char('Description', required=True, copy=False),
'date': fields.date('Date', required=True, copy=False),
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
'partner_id': fields.many2one('res.partner', 'Partner'),
'bank_account_id': fields.many2one('res.partner.bank','Bank Account'),
Expand Down
4 changes: 2 additions & 2 deletions addons/account/account_cash_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def onchange_journal_id(self, cr, uid, ids, journal_id, context=None):
},
help="Total of cash transaction lines."),
'closing_date': fields.datetime("Closed On"),
'details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='CashBox Lines'),
'details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='CashBox Lines', copy=True),
'opening_details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='Opening Cashbox Lines'),
'closing_details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='Closing Cashbox Lines'),
'user_id': fields.many2one('res.users', 'Responsible', required=False),
Expand Down Expand Up @@ -337,7 +337,7 @@ def _default_cashbox_line_ids(self, cr, uid, context=None):
return result

_columns = {
'cashbox_line_ids' : fields.one2many('account.journal.cashbox.line', 'journal_id', 'CashBox'),
'cashbox_line_ids' : fields.one2many('account.journal.cashbox.line', 'journal_id', 'CashBox', copy=True),
}

_defaults = {
Expand Down
Loading

0 comments on commit cbe2dbb

Please sign in to comment.