[REF] account_id is not anymore mandatory for creating a bank statement line. Still mandatory for the validation

This commit is contained in:
Sébastien Beau
2014-04-25 14:59:58 +02:00
committed by Guewen Baconnier
3 changed files with 50 additions and 7 deletions

View File

@@ -344,6 +344,24 @@ class AccountStatementCompletionRule(orm.Model):
res.update(st_vals)
return res
class AccountStatement(orm.Model):
_inherit = "account.bank.statement"
def button_confirm_bank(self, cr, uid, ids, context=None):
line_obj = self.pool['account.bank.statement.line']
for stat_id in ids:
line_without_account = line_obj.search(cr, uid, [
['statement_id', '=', stat_id],
['account_id', '=', False],
], context=context)
if line_without_account:
stat = self.browse(cr, uid, stat_id, context=context)
raise orm.except_orm(_('User error'),
_('You should fill all account on the line of the'
' statement %s')%stat.name)
return super(AccountStatement, self).button_confirm_bank(
cr, uid, ids, context=context)
class AccountStatementLine(orm.Model):
"""
@@ -355,6 +373,7 @@ class AccountStatementLine(orm.Model):
module to see how we've done it.
"""
_inherit = "account.bank.statement.line"
_order = "already_completed desc, date asc"
_columns = {
'additionnal_bank_fields': fields.serialized(

View File

@@ -99,7 +99,7 @@ class AccountStatementProfil(Model):
statement_id, context):
"""
Hook to build the values of a line from the parser returned values. At
least it fullfill the statement_id and account_id. Override it to add your
least it fullfill the statement_id. Overide it to add your
own completion if needed.
:param dict of vals from parser for account.bank.statement.line (called by
@@ -113,12 +113,6 @@ class AccountStatementProfil(Model):
statement_line_obj = self.pool['account.bank.statement.line']
values = parser_vals
values['statement_id'] = statement_id
values['account_id'] = statement_obj.get_account_for_counterpart(cr,
uid,
parser_vals['amount'],
account_receivable,
account_payable)
date = values.get('date')
period_memoizer = context.get('period_memoizer')
if not period_memoizer:
@@ -239,3 +233,16 @@ class AccountStatementProfil(Model):
raise osv.except_osv(_("Statement import error"),
_("The statement cannot be created: %s") % st)
return statement_id
class AccountBankStatementLine(Model):
_inherit = "account.bank.statement.line"
_columns = {
'account_id': fields.many2one('account.account','Account'),
}
_defaults = {
'account_id': False,
}

View File

@@ -26,5 +26,22 @@
</field>
</record>
<record id="bank_statement_view_form" model="ir.ui.view">
<field name="name">account_bank_statement.bank_statement.view_form</field>
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account_statement_base_completion.bank_statement_view_form" />
<field name="type">form</field>
<field eval="20" name="priority"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='line_ids']/form//field[@name='account_id']" position="attributes">
<attribute name="attrs">{'required': [('already_completed','=', True)]}</attribute>
</xpath>
<xpath expr="//field[@name='line_ids']/tree//field[@name='account_id']" position="attributes">
<attribute name="attrs">{'required': [('already_completed','=', True)]}</attribute>
</xpath>
</field>
</record>
</data>
</openerp>