diff --git a/addons/account_sequence/account_sequence.py b/addons/account_sequence/account_sequence.py index 82d416e84ca..642521f4688 100644 --- a/addons/account_sequence/account_sequence.py +++ b/addons/account_sequence/account_sequence.py @@ -46,7 +46,7 @@ class account_journal(osv.osv): _inherit = "account.journal" _columns = { - 'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence', help="This sequence will be used to maintain the internal number for the journal entries related to this journal."), + 'internal_sequence_id': fields.many2one('ir.sequence', 'Internal Sequence', help="This sequence will be used to maintain the internal number for the journal entries related to this journal."), } account_journal() @@ -60,4 +60,4 @@ class account_move_line(osv.osv): account_move_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_sequence/account_sequence.xml b/addons/account_sequence/account_sequence.xml index dd9c1a36cd4..6b9e2c94402 100644 --- a/addons/account_sequence/account_sequence.xml +++ b/addons/account_sequence/account_sequence.xml @@ -21,7 +21,7 @@ - + diff --git a/addons/account_sequence/account_sequence_installer.py b/addons/account_sequence/account_sequence_installer.py index 5375ee6fae3..fb0f5840566 100644 --- a/addons/account_sequence/account_sequence_installer.py +++ b/addons/account_sequence/account_sequence_installer.py @@ -26,33 +26,57 @@ class account_sequence_installer(osv.osv_memory): _inherit = 'res.config.installer' _columns = { - 'internal_sequence': fields.many2one('ir.sequence', 'Internal Sequence', help="This sequence will be used on Journals to maintain internal number for accounting entries."), + 'name': fields.char('Name',size=64, required=True), + 'prefix': fields.char('Prefix',size=64, help="Prefix value of the record for the sequence"), + 'suffix': fields.char('Suffix',size=64, help="Suffix value of the record for the sequence"), + 'number_next': fields.integer('Next Number', required=True, help="Next number of this sequence"), + 'number_increment': fields.integer('Increment Number', required=True, help="The next number of the sequence will be incremented by this number"), + 'padding' : fields.integer('Number padding', required=True, help="OpenERP will automatically adds some '0' on the left of the 'Next Number' to get the required padding size."), + 'company_id': fields.many2one('res.company', 'Company'), + } + _defaults = { + 'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'ir.sequence', context=c), + 'number_increment': 1, + 'number_next': 1, + 'padding' : 0, + 'name': 'Internal Sequence Journal', } - - def _get_internal_sequence(self, cr, uid, context=None): - result = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_sequence', 'internal_sequence_journal') - return result and result[1] or False def execute(self, cr, uid, ids, context=None): if context is None: context = {} jou_obj = self.pool.get('account.journal') obj_sequence = self.pool.get('ir.sequence') - record = self.browse(cr, uid, ids)[0] + record = self.browse(cr, uid, ids, context)[0] j_ids = [] + if record.company_id: + company_id = record.company_id.id, + search_criteria = [('company_id', '=', company_id)] + else: + company_id = False + search_criteria = [] + vals = { + 'id': 'internal_sequence_journal', + 'code': 'account.journal', + 'name': record.name, + 'prefix': record.prefix, + 'suffix': record.suffix, + 'number_next': record.number_next, + 'number_increment': record.number_increment, + 'padding' : record.padding, + 'company_id': company_id, + } + + ir_seq = obj_sequence.create(cr, uid, vals, context) res = super(account_sequence_installer, self).execute(cr, uid, ids, context=context) - journal_ids = jou_obj.search(cr, uid, [], context=context) - for journal in jou_obj.browse(cr, uid, journal_ids): - if not journal.internal_sequence: + journal_ids = jou_obj.search(cr, uid, search_criteria, context=context) + for journal in jou_obj.browse(cr, uid, journal_ids, context): + if not journal.internal_sequence_id: j_ids.append(journal.id) if j_ids: - jou_obj.write(cr, uid, j_ids, {'internal_sequence': record.internal_sequence.id}) + jou_obj.write(cr, uid, j_ids, {'internal_sequence_id': ir_seq}) return res - _defaults = { - 'internal_sequence': _get_internal_sequence - } - account_sequence_installer() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_sequence/account_sequence_installer_view.xml b/addons/account_sequence/account_sequence_installer_view.xml index a4808a2c858..1051b133045 100644 --- a/addons/account_sequence/account_sequence_installer_view.xml +++ b/addons/account_sequence/account_sequence_installer_view.xml @@ -22,7 +22,13 @@ You can enhance the Account Sequence Application by installing . - + + + + + + + Configure @@ -44,7 +50,7 @@ 3 - always + onskip