~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to account_override/account_bank_statement.py

  • Committer: Olivier DOSSMANN
  • Date: 2014-03-31 09:31:46 UTC
  • mto: This revision was merged to the branch mainline in revision 2086.
  • Revision ID: od@tempo-consulting.fr-20140331093146-tgvxnly1kc1hbv1s
UF-2171 [ADD] Analytic distribution reset button for recurring models

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from osv import osv
25
25
from osv import fields
 
26
from tools.translate import _
26
27
 
27
28
class account_bank_statement(osv.osv):
28
29
    _name = 'account.bank.statement'
29
30
    _inherit = 'account.bank.statement'
30
31
 
31
32
    _columns = {
32
 
        'prev_reg_id': fields.many2one('account.bank.statement', string="Previous register", required=False, readonly=True, 
 
33
        'prev_reg_id': fields.many2one('account.bank.statement', string="Previous register", required=False, readonly=True,
33
34
            help="This fields give the previous register from which this one is linked."),
34
 
        'next_reg_id': fields.one2many('account.bank.statement', 'prev_reg_id', string="Next register", readonly=True, 
 
35
        'next_reg_id': fields.one2many('account.bank.statement', 'prev_reg_id', string="Next register", readonly=True,
35
36
            help="This fields give the next register if exists."),
36
37
    }
37
38
 
38
39
account_bank_statement()
 
40
 
 
41
class account_bank_statement_line(osv.osv):
 
42
    _name = 'account.bank.statement.line'
 
43
    _inherit = 'account.bank.statement.line'
 
44
 
 
45
    def create(self, cr, uid, vals, context=None):
 
46
        """
 
47
        UTP-317: Check if partner is inactive or not. If inactive, raise an execption to the user.
 
48
        """
 
49
        # Some verification
 
50
        if not context:
 
51
            context = {}
 
52
        res = super(account_bank_statement_line, self).create(cr, uid, vals, context)
 
53
        # UTP-317: Check partner (if active or not)
 
54
        if res:
 
55
            absl = self.browse(cr, uid, [res], context)
 
56
            # UF-2300: for the case of sync, the line can also be created if the partner is inactive
 
57
            if not context.get('sync_update_execution', False) and absl and absl[0] and absl[0].partner_id and not absl[0].partner_id.active:
 
58
                raise osv.except_osv(_('Warning'), _("Partner '%s' is not active.") % (absl[0].partner_id.name or '',))
 
59
        return res
 
60
 
 
61
    _columns = {
 
62
        'ref': fields.char('Reference', size=50), # UF-1613 - add reference field from 32 to 50 chars
 
63
        'invoice_id': fields.many2one('account.invoice', "Invoice", required=False),
 
64
    }
 
65
 
 
66
account_bank_statement_line()
39
67
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: