~camptocamp/c2c-rd-addons/7.0

« back to all changes in this revision

Viewing changes to c2c_sequence_fy/account_move.py

  • Committer: openerp@bazaar.camptocamp.net
  • Date: 2012-01-24 12:18:39 UTC
  • mfrom: (167.17.11 c2c-rd-addons)
  • Revision ID: openerp@bazaar.camptocamp.net-20120124121839-o5xm907w21i5hbbe
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
 
2
# -*- coding: utf-8 -*-
2
3
##############################################################################
3
4
#
4
5
#    OpenERP, Open Source Management Solution
28
29
    def post(self, cr, uid, ids, context=None):
29
30
        import sys
30
31
        print >> sys.stderr,'post move context',context 
31
 
 
32
32
        journal_id = context.get('journal_id')
 
33
        period_id = []
 
34
        if 'period_id' in context:
 
35
           period_id = [context.get('period_id')]
 
36
        print >> sys.stderr,'post move period_id', period_id
33
37
        invoice_obj = context.get('invoice')
34
38
        if not journal_id:
35
39
           journal_id = invoice_obj.journal_id.id
55
59
            if jour.create_sequence == 'create_fy' :  
56
60
                fy_seq_obj = self.pool.get('account.sequence.fiscalyear')
57
61
                period_obj = self.pool.get('account.period')
58
 
                period_ids = context.get('period_id')
59
 
                if not period_ids:
 
62
                if not period_id:
60
63
                   print >> sys.stderr,'per_id A'
61
64
                   period_id = invoice_obj.period_id.id 
62
65
                   print >> sys.stderr,'per_id B', period_id
66
69
                   print >> sys.stderr,'per_id D', period_id
67
70
                   
68
71
                for period in period_obj.browse(cr, uid, period_id):
69
 
                   fy_id = period.fiscalyear_id.id
70
 
                   fy_code =  period.fiscalyear_id.code
71
 
                   print >> sys.stderr,'fy_id', fy_id
 
72
                    print >> sys.stderr,'fy_id', period
 
73
                    fy_id = period.fiscalyear_id.id
 
74
                    fy_code =  period.fiscalyear_id.code
 
75
                    print >> sys.stderr,'fy_id a', fy_id
72
76
                fy_seq = fy_seq_obj.search(cr, uid, [('fiscalyear_id','=', fy_id),('sequence_main_id','=',main_seq_id)])
73
77
                print >> sys.stderr,'fy_seq_id', fy_seq
74
78
                if not fy_seq:
88
92
                          }   
89
93
                   print >> sys.stderr,'fy_rel',fy_rel, prefix
90
94
                   fy_seq_obj.create(cr, uid, fy_rel)
91
 
         
 
95
          #return True
 
96
        
92
97
        return super(account_move, self).post(cr, uid, ids, context)
93
 
        
94
 
 
95
 
    def post_gk(self, cr, uid, ids, context=None):
96
 
        if context is None : context = {}
97
 
        invoice = context.get('invoice', False)
98
 
        valid_move_ids = self.validate(cr, uid, ids, context)
99
 
        if not valid_move_ids:
100
 
            raise osv.except_osv \
101
 
                ( _('Integrity Error !')
102
 
                , _('You cannot validate a non-balanced entry!\nMake sure you have configured Payment Term properly !\nIt should contain at least one Payment Term Line with type "Balance" !')
103
 
                )
104
 
        seq_obj = self.pool.get('ir.sequence')
105
 
        jou_obj = self.pool.get('account.journal')
106
 
        for move in self.browse(cr, uid, valid_move_ids, context=context):
107
 
            if move.name == '/':
108
 
                new_name = False
109
 
                journal = move.journal_id
110
 
                if invoice and invoice.internal_number:
111
 
                    new_name = invoice.internal_number
112
 
                else:
113
 
                    if journal.sequence_id:
114
 
                        c = \
115
 
                            { 'fiscalyear_id' : move.period_id.fiscalyear_id.id
116
 
                            , 'journal_id'    : journal.id
117
 
                            }
118
 
                        new_name = seq_obj.next_by_id(cr, uid, journal.sequence_id.id, context=c)
119
 
                    else :
120
 
                        values = \
121
 
                            { 'name'           : move.journal_id.name
122
 
                            , 'prefix'         : "".join(w[0] for w in _(journal.name).split(' '))
123
 
                            , 'padding'        : 3
124
 
                            , 'implementation' : 'no_gap'
125
 
                            }
126
 
                        new_id   = seq_obj.create(cr, uid, values)
127
 
                        new_name = seq_obj._format(self, cr, uid, seq_obj.browse(cr, uid, new_id), context)
128
 
                        jou_obj.write(cr, uid, [journal_id.id], {'sequence_id' : new_id})
129
 
                self.write(cr, uid, [move.id], {'name' : new_name})
130
 
        self.write(cr, uid, valid_move_ids, {'state' : 'posted'})
131
 
        return True
132
 
    # end def post
133
98
 
134
99
account_move()