[IMP] account_statement_ext - add a sequence on bank profile and set the first of the company as default

This commit is contained in:
Yannick Vaucher
2013-06-28 16:59:51 +02:00
parent 99a643aed1
commit e22e4191e5

View File

@@ -48,9 +48,11 @@ class AccountStatementProfile(Model):
_inherit = ['mail.thread']
_description = "Statement Profile"
_order = 'sequence'
_columns = {
'name': fields.char('Name', required=True),
'sequence': fields.integer('Sequence', help="Gives a sequence in lists, the first profile will be used as default"),
'partner_id': fields.many2one(
'res.partner',
'Bank/Payment Office partner',
@@ -135,12 +137,24 @@ class AccountBankSatement(Model):
periods = period_obj.find(cr, uid, dt=context.get('date'), context=context)
return periods and periods[0] or False
def _default_profile(self, cr, uid, context=None):
"""
Statement default period
"""
if context is None:
context = {}
user_obj = self.pool.get('res.users')
profile_obj = self.pool.get('account.statement.profile')
user = user_obj.browse(cr, uid, uid, context=context)
profile_ids = profile_obj.search(cr, uid, [('company_id', '=', user.company_id.id)], context=context)
return profile_ids[0] if profile_ids else False
_columns = {
'profile_id': fields.many2one(
'account.statement.profile',
'Bank Account Profile',
required=True,
readonly=True,
states={'draft': [('readonly', False)]}),
'credit_partner_id': fields.related(
'profile_id',
@@ -175,6 +189,7 @@ class AccountBankSatement(Model):
_defaults = {
'period_id': _default_period,
'profile_id': _default_profile,
}
def create(self, cr, uid, vals, context=None):