Skip to content

Commit cbe2dbb

Browse files
rco-odooantonylesuisse
authored andcommitted
[MERGE] new v8 api by rco
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
1 parent d78192c commit cbe2dbb

File tree

426 files changed

+14969
-12632
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

426 files changed

+14969
-12632
lines changed

addons/account/account.py

+63-95
Large diffs are not rendered by default.

addons/account/account_bank_statement.py

+25-28
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ def _get_period(self, cr, uid, context=None):
6969
return False
7070

7171
def _compute_default_statement_name(self, cr, uid, journal_id, context=None):
72-
if context is None:
73-
context = {}
72+
context = dict(context or {})
7473
obj_seq = self.pool.get('ir.sequence')
7574
period = self.pool.get('account.period').browse(cr, uid, self._get_period(cr, uid, context=context), context=context)
7675
context['fiscalyear_id'] = period.fiscalyear_id.id
@@ -114,8 +113,16 @@ def _all_lines_reconciled(self, cr, uid, ids, name, args, context=None):
114113
_description = "Bank Statement"
115114
_inherit = ['mail.thread']
116115
_columns = {
117-
'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
118-
'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]}, select=True),
116+
'name': fields.char(
117+
'Reference', states={'draft': [('readonly', False)]},
118+
readonly=True, # readonly for account_cash_statement
119+
copy=False,
120+
help='if you give the Name other then /, its created Accounting Entries Move '
121+
'will be with same name as statement name. '
122+
'This allows the statement entries to have the same references than the '
123+
'statement itself'),
124+
'date': fields.date('Date', required=True, states={'confirm': [('readonly', True)]},
125+
select=True, copy=False),
119126
'journal_id': fields.many2one('account.journal', 'Journal', required=True,
120127
readonly=True, states={'draft':[('readonly',False)]}),
121128
'period_id': fields.many2one('account.period', 'Period', required=True,
@@ -132,14 +139,15 @@ def _all_lines_reconciled(self, cr, uid, ids, name, args, context=None):
132139
string="Computed Balance", help='Balance as calculated based on Opening Balance and transaction lines'),
133140
'company_id': fields.related('journal_id', 'company_id', type='many2one', relation='res.company', string='Company', store=True, readonly=True),
134141
'line_ids': fields.one2many('account.bank.statement.line',
135-
'statement_id', 'Statement lines',
136-
states={'confirm':[('readonly', True)]}),
142+
'statement_id', 'Statement lines',
143+
states={'confirm':[('readonly', True)]}, copy=True),
137144
'move_line_ids': fields.one2many('account.move.line', 'statement_id',
138-
'Entry lines', states={'confirm':[('readonly',True)]}),
145+
'Entry lines', states={'confirm':[('readonly',True)]}),
139146
'state': fields.selection([('draft', 'New'),
140147
('open','Open'), # used by cash statements
141148
('confirm', 'Closed')],
142149
'Status', required=True, readonly="1",
150+
copy=False,
143151
help='When new statement is created the status will be \'Draft\'.\n'
144152
'And after getting confirmation from the bank it will be in \'Confirmed\' status.'),
145153
'currency': fields.function(_currency, string='Currency',
@@ -182,7 +190,7 @@ def onchange_date(self, cr, uid, ids, date, company_id, context=None):
182190
pids = period_pool.find(cr, uid, dt=date, context=ctx)
183191
if pids:
184192
res.update({'period_id': pids[0]})
185-
context.update({'period_id': pids[0]})
193+
context = dict(context, period_id=pids[0])
186194

187195
return {
188196
'value':res,
@@ -363,24 +371,13 @@ def onchange_journal_id(self, cr, uid, statement_id, journal_id, context=None):
363371
return {'value': res}
364372

365373
def unlink(self, cr, uid, ids, context=None):
366-
stat = self.read(cr, uid, ids, ['state'], context=context)
367-
unlink_ids = []
368-
for t in stat:
369-
if t['state'] in ('draft'):
370-
unlink_ids.append(t['id'])
371-
else:
372-
raise osv.except_osv(_('Invalid Action!'), _('In order to delete a bank statement, you must first cancel it to delete related journal items.'))
373-
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
374-
return True
375-
376-
def copy(self, cr, uid, id, default=None, context=None):
377-
if default is None:
378-
default = {}
379-
if context is None:
380-
context = {}
381-
default = default.copy()
382-
default['move_line_ids'] = []
383-
return super(account_bank_statement, self).copy(cr, uid, id, default, context=context)
374+
for item in self.browse(cr, uid, ids, context=context):
375+
if item.state != 'draft':
376+
raise osv.except_osv(
377+
_('Invalid Action!'),
378+
_('In order to delete a bank statement, you must first cancel it to delete related journal items.')
379+
)
380+
return super(account_bank_statement, self).unlink(cr, uid, ids, context=context)
384381

385382
def button_journal_entries(self, cr, uid, ids, context=None):
386383
ctx = (context or {}).copy()
@@ -806,8 +803,8 @@ def _needaction_domain_get(self, cr, uid, context=None):
806803
_description = "Bank Statement Line"
807804
_inherit = ['ir.needaction_mixin']
808805
_columns = {
809-
'name': fields.char('Description', required=True),
810-
'date': fields.date('Date', required=True),
806+
'name': fields.char('Description', required=True, copy=False),
807+
'date': fields.date('Date', required=True, copy=False),
811808
'amount': fields.float('Amount', digits_compute=dp.get_precision('Account')),
812809
'partner_id': fields.many2one('res.partner', 'Partner'),
813810
'bank_account_id': fields.many2one('res.partner.bank','Bank Account'),

addons/account/account_cash_statement.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def onchange_journal_id(self, cr, uid, ids, journal_id, context=None):
179179
},
180180
help="Total of cash transaction lines."),
181181
'closing_date': fields.datetime("Closed On"),
182-
'details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='CashBox Lines'),
182+
'details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='CashBox Lines', copy=True),
183183
'opening_details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='Opening Cashbox Lines'),
184184
'closing_details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='Closing Cashbox Lines'),
185185
'user_id': fields.many2one('res.users', 'Responsible', required=False),
@@ -337,7 +337,7 @@ def _default_cashbox_line_ids(self, cr, uid, context=None):
337337
return result
338338

339339
_columns = {
340-
'cashbox_line_ids' : fields.one2many('account.journal.cashbox.line', 'journal_id', 'CashBox'),
340+
'cashbox_line_ids' : fields.one2many('account.journal.cashbox.line', 'journal_id', 'CashBox', copy=True),
341341
}
342342

343343
_defaults = {

0 commit comments

Comments
 (0)