mirror of
https://github.com/OCA/account-reconcile.git
synced 2025-01-20 12:27:39 +02:00
never include serializable fields during batch update
This commit is contained in:
@@ -226,19 +226,20 @@ class AccountStatementLine(Model):
|
|||||||
"""
|
"""
|
||||||
_inherit = "account.bank.statement.line"
|
_inherit = "account.bank.statement.line"
|
||||||
|
|
||||||
def _get_available_columns(self, statement_store):
|
def _get_available_columns(self, statement_store, include_serializable=False):
|
||||||
"""Return writeable by SQL columns"""
|
"""Return writeable by SQL columns"""
|
||||||
statement_line_obj = self.pool['account.bank.statement.line']
|
statement_line_obj = self.pool['account.bank.statement.line']
|
||||||
model_cols = statement_line_obj._columns
|
model_cols = statement_line_obj._columns
|
||||||
avail = [k for k, col in model_cols.iteritems() if not hasattr(col, '_fnct')]
|
avail = [k for k, col in model_cols.iteritems() if not hasattr(col, '_fnct')]
|
||||||
keys = [k for k in statement_store[0].keys() if k in avail]
|
keys = [k for k in statement_store[0].keys() if k in avail]
|
||||||
# add sparse fields..
|
# add sparse fields..
|
||||||
for k, col in model_cols.iteritems():
|
if include_serializable:
|
||||||
if k in statement_store[0].keys() and \
|
for k, col in model_cols.iteritems():
|
||||||
isinstance(col, fields.sparse) and \
|
if k in statement_store[0].keys() and \
|
||||||
col.serialization_field not in keys and \
|
isinstance(col, fields.sparse) and \
|
||||||
col._type == 'char':
|
col.serialization_field not in keys and \
|
||||||
keys.append(col.serialization_field)
|
col._type == 'char':
|
||||||
|
keys.append(col.serialization_field)
|
||||||
keys.sort()
|
keys.sort()
|
||||||
return keys
|
return keys
|
||||||
|
|
||||||
@@ -267,7 +268,7 @@ class AccountStatementLine(Model):
|
|||||||
statement_line_obj = self.pool['account.bank.statement.line']
|
statement_line_obj = self.pool['account.bank.statement.line']
|
||||||
statement_line_obj.check_access_rule(cr, uid, [], 'create')
|
statement_line_obj.check_access_rule(cr, uid, [], 'create')
|
||||||
statement_line_obj.check_access_rights(cr, uid, 'create', raise_exception=True)
|
statement_line_obj.check_access_rights(cr, uid, 'create', raise_exception=True)
|
||||||
cols = self._get_available_columns(statement_store)
|
cols = self._get_available_columns(statement_store, include_serializable=True)
|
||||||
tmp_vals = (', '.join(cols), ', '.join(['%%(%s)s' % i for i in cols]))
|
tmp_vals = (', '.join(cols), ', '.join(['%%(%s)s' % i for i in cols]))
|
||||||
sql = "INSERT INTO account_bank_statement_line (%s) VALUES (%s);" % tmp_vals
|
sql = "INSERT INTO account_bank_statement_line (%s) VALUES (%s);" % tmp_vals
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user