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

This commit is contained in:
Sebastien Beau
2013-12-04 14:53:03 +01:00
parent e33044d520
commit 33dc39874b
3 changed files with 44 additions and 6 deletions

View File

@@ -382,6 +382,23 @@ 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 osv.except_osv(_('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):
"""
@@ -393,6 +410,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

@@ -103,12 +103,6 @@ class AccountStatementProfil(Model):
statement_obj = self.pool.get('account.bank.statement')
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:
@@ -214,3 +208,12 @@ class AccountStatementProfil(Model):
raise osv.except_osv(_("Statement import error"),
_("The statement cannot be created: %s") % st)
return statement_id
class AccountBankStatementLine(orm.Model):
_inherit = "account.bank.statement.line"
_columns = {
'account_id': fields.many2one('account.account','Account'),
}

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="/form/sheet/notebook/page/field[@name='line_ids']/form/group/field[@name='account_id']" position="attributes">
<attribute name="attrs">{'required': [('already_completed','=', True)]}</attribute>
</xpath>
<xpath expr="/form/sheet/notebook/page/field[@name='line_ids']/tree/field[@name='account_id']" position="attributes">
<attribute name="attrs">{'required': [('already_completed','=', True)]}</attribute>
</xpath>
</field>
</record>
</data>
</openerp>