[FIX] Fix some code length, fill description, change module name

This commit is contained in:
Florian da Costa
2013-12-12 22:38:08 +01:00
parent f622212dbe
commit ac625c78e9
2 changed files with 33 additions and 14 deletions

View File

@@ -21,19 +21,24 @@
############################################################################### ###############################################################################
{ {
'name': 'account_statement_one_move', 'name': 'Bank statement one move',
'version': '0.1', 'version': '0.1',
'category': 'Generic Modules/Others', 'category': 'Generic Modules/Others',
'license': 'AGPL-3', 'license': 'AGPL-3',
'description': """empty""", 'description': """
This module allow to groupe all lines of a bank statement in only one move. This feature is optional
and can be activated with a checkbox in the bank statement's profile. This is very useful for credit card deposit for example,
you won't have a move for each line.
""",
'author': 'Akretion', 'author': 'Akretion',
'website': 'http://www.akretion.com/', 'website': 'http://www.akretion.com/',
'depends': ['account_statement_ext'], 'depends': ['account_statement_ext'],
'init_xml': [], 'data': [
'update_xml': [
'statement_view.xml' 'statement_view.xml'
], ],
'demo_xml': [], 'demo': [],
'installable': True, 'installable': True,
'auto_install': False,
'active': False, 'active': False,
} }

View File

@@ -37,8 +37,10 @@ class account_bank_statement(orm.Model):
_inherit = "account.bank.statement" _inherit = "account.bank.statement"
def _prepare_move_line_vals(self, cr, uid, st_line, *args, **kwargs): def _prepare_move_line_vals(self, cr, uid, st_line, *args, **kwargs):
res = super(account_bank_statement, self)._prepare_move_line_vals(cr, uid, st_line, *args, **kwargs) res = super(account_bank_statement, self)._prepare_move_line_vals(cr, uid, st_line,
period_id = self._get_period(cr, uid, st_line.statement_id.date, context=kwargs.get('context')) *args, **kwargs)
period_id = self._get_period(cr, uid, st_line.statement_id.date,
context=kwargs.get('context'))
if st_line.statement_id.profile_id.one_move: if st_line.statement_id.profile_id.one_move:
res.update({ res.update({
'period_id': period_id, 'period_id': period_id,
@@ -60,22 +62,32 @@ class account_bank_statement(orm.Model):
}) })
return res return res
def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id, st_line_number, context): def create_move_from_st_line(self, cr, uid, st_line_id, company_currency_id,
st_line_number, context=None):
if context is None:
context = {}
account_move_obj = self.pool.get('account.move') account_move_obj = self.pool.get('account.move')
account_bank_statement_line_obj = self.pool.get('account.bank.statement.line') account_bank_statement_line_obj = self.pool.get('account.bank.statement.line')
st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id, context=context) st_line = account_bank_statement_line_obj.browse(cr, uid, st_line_id,
context=context)
st = st_line.statement_id st = st_line.statement_id
if st.profile_id.one_move: if st.profile_id.one_move:
if not context.get('move_id'): if not context.get('move_id'):
move_vals = self._prepare_move(cr, uid, st_line, st_line_number, context=context) move_vals = self._prepare_move(cr, uid, st_line, st_line_number, context=context)
context['move_id'] = account_move_obj.create(cr, uid, move_vals, context=context) context['move_id'] = account_move_obj.create(cr, uid, move_vals, context=context)
self.create_move_line_from_st_line(cr, uid, context['move_id'], st_line_id, company_currency_id, context=context) self.create_move_line_from_st_line(cr, uid, context['move_id'],
st_line_id, company_currency_id,
context=context)
return context['move_id'] return context['move_id']
else: else:
return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line_id, company_currency_id, st_line_number, context=context) return super(account_bank_statement, self).create_move_from_st_line(cr, uid, st_line_id,
company_currency_id,
st_line_number,
context=context)
def create_move_line_from_st_line(self, cr, uid, move_id, st_line_id, company_currency_id, context): def create_move_line_from_st_line(self, cr, uid, move_id, st_line_id,
company_currency_id, context=None):
"""Create the account move line from the statement line. """Create the account move line from the statement line.
:param int/long move_id: ID of the account.move :param int/long move_id: ID of the account.move
@@ -115,7 +127,8 @@ class account_bank_statement(orm.Model):
if context is None: if context is None:
context = {} context = {}
for st in self.browse(cr, uid, ids, context=context): for st in self.browse(cr, uid, ids, context=context):
super(account_bank_statement, self).button_confirm_bank(cr, uid, ids, context=context) super(account_bank_statement, self).button_confirm_bank(cr, uid, ids,
context=context)
if st.profile_id.one_move: if st.profile_id.one_move:
move_id = context['move_id'] move_id = context['move_id']
self._valid_move(cr, uid, move_id, context=context) self._valid_move(cr, uid, move_id, context=context)
@@ -135,7 +148,8 @@ class account_bank_statement(orm.Model):
move.unlink(context=context) move.unlink(context=context)
st.write({'state':'draft'}, context=context) st.write({'state':'draft'}, context=context)
else: else:
super(account_bank_statement, self).button_cancel(cr, uid, ids, context=context) super(account_bank_statement, self).button_cancel(cr, uid, ids,
context=context)
return True return True