Antony Lesuisse (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-ir-sequence-vmt into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-ir-sequence-vmt/+merge/77756

ir sequence new api
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-ir-sequence-vmt/+merge/77756
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-ir-sequence-vmt.
=== modified file 'account/account.py'
--- account/account.py	2011-09-27 16:52:19 +0000
+++ account/account.py	2011-09-30 21:06:25 +0000
@@ -1214,7 +1214,7 @@
                 else:
                     if journal.sequence_id:
                         c = {'fiscalyear_id': move.period_id.fiscalyear_id.id}
-                        new_name = obj_sequence.get_id(cr, uid, journal.sequence_id.id, context=c)
+                        new_name = obj_sequence.next_by_id(cr, uid, journal.sequence_id.id, c)
                     else:
                         raise osv.except_osv(_('Error'), _('No sequence defined on the journal !'))
 

=== modified file 'account/account_bank_statement.py'
--- account/account_bank_statement.py	2011-09-25 21:54:57 +0000
+++ account/account_bank_statement.py	2011-09-30 21:06:25 +0000
@@ -340,9 +340,9 @@
             else:
                 if st.journal_id.sequence_id:
                     c = {'fiscalyear_id': st.period_id.fiscalyear_id.id}
-                    st_number = obj_seq.get_id(cr, uid, st.journal_id.sequence_id.id, context=c)
+                    st_number = obj_seq.next_by_id(cr, uid, st.journal_id.sequence_id.id, context=c)
                 else:
-                    st_number = obj_seq.get(cr, uid, 'account.bank.statement')
+                    st_number = obj_seq.next_by_code(cr, uid, 'account.bank.statement')
 
             for line in st.move_line_ids:
                 if line.state <> 'valid':

=== modified file 'account/account_cash_statement.py'
--- account/account_cash_statement.py	2011-09-25 22:24:45 +0000
+++ account/account_cash_statement.py	2011-09-30 21:06:25 +0000
@@ -294,9 +294,9 @@
             if statement.name and statement.name == '/':
                 if statement.journal_id.sequence_id:
                     c = {'fiscalyear_id': statement.period_id.fiscalyear_id.id}
-                    st_number = obj_seq.get_id(cr, uid, statement.journal_id.sequence_id.id, context=c)
+                    st_number = obj_seq.next_by_id(cr, uid, statement.journal_id.sequence_id.id, context=c)
                 else:
-                    st_number = obj_seq.get(cr, uid, 'account.cash.statement')
+                    st_number = obj_seq.next_by_code(cr, uid, 'account.cash.statement')
                 vals.update({
                     'name': st_number
                 })

=== modified file 'account/account_move_line.py'
--- account/account_move_line.py	2011-09-27 16:52:19 +0000
+++ account/account_move_line.py	2011-09-30 21:06:25 +0000
@@ -1221,7 +1221,7 @@
                     vals['move_id'] = res[0]
             if not vals.get('move_id', False):
                 if journal.sequence_id:
-                    #name = self.pool.get('ir.sequence').get_id(cr, uid, journal.sequence_id.id)
+                    #name = self.pool.get('ir.sequence').next_by_id(cr, uid, journal.sequence_id.id)
                     v = {
                         'date': vals.get('date', time.strftime('%Y-%m-%d')),
                         'period_id': context['period_id'],

=== modified file 'account/sequence.py'
--- account/sequence.py	2011-01-14 00:11:01 +0000
+++ account/sequence.py	2011-09-30 21:06:25 +0000
@@ -46,23 +46,20 @@
         'fiscal_ids': fields.one2many('account.sequence.fiscalyear',
             'sequence_main_id', 'Sequences')
     }
-    def get_id(self, cr, uid, sequence_id, test='id', context=None):
-        if context is None:
-            context = {}
-        cr.execute('select id from ir_sequence where '
-                   + test + '=%s and active=%s', (sequence_id, True,))
-        res = cr.dictfetchone()
-        if res:
-            for line in self.browse(cr, uid, res['id'],
-                                    context=context).fiscal_ids:
-                if line.fiscalyear_id.id == context.get('fiscalyear_id', False):
-                    return super(ir_sequence, self).get_id(cr, uid,
-                                                           line.sequence_id.id,
-                                                           test="id",
-                                                           context=context)
-        return super(ir_sequence, self).get_id(cr, uid, sequence_id, test,
-                                               context=context)
+
+    def _select_by_code_or_id(self, cr, uid, sequence_code_or_id, code_or_id,
+            for_update_no_wait, context=None):
+        res = super(ir_sequence, self)._select_by_code_or_id(cr, uid,
+            sequence_code_or_id, code_or_id, False, context)
+        if not res:
+            return
+        for line in self.browse(cr, uid, res['id'], context).fiscal_ids:
+            if line.fiscalyear_id.id == context.get('fiscalyear_id'):
+                return super(ir_sequence, self)._select_by_code_or_id(cr, uid,
+                    line.sequence_id.id, 'id', False, context)
+        return super(ir_sequence, self)._select_by_code_or_id(cr, uid,
+            res['id'], 'id', False, context)
 
 ir_sequence()
 
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'account_sequence/account_sequence.py'
--- account_sequence/account_sequence.py	2011-01-14 00:11:01 +0000
+++ account_sequence/account_sequence.py	2011-09-30 21:06:25 +0000
@@ -35,7 +35,7 @@
         seq_no = False
         for move in self.browse(cr, uid, ids, context=context):
             if move.journal_id.internal_sequence_id:
-                seq_no = obj_sequence.get_id(cr, uid, move.journal_id.internal_sequence_id.id, context=context)
+                seq_no = obj_sequence.next_by_id(cr, uid, move.journal_id.internal_sequence_id.id, context=context)
             if seq_no:
                 self.write(cr, uid, [move.id], {'internal_sequence_number': seq_no})
         return res

=== modified file 'account_voucher/account_voucher.py'
--- account_voucher/account_voucher.py	2011-09-27 13:34:13 +0000
+++ account_voucher/account_voucher.py	2011-09-30 21:06:25 +0000
@@ -674,7 +674,7 @@
             if inv.number:
                 name = inv.number
             elif inv.journal_id.sequence_id:
-                name = seq_obj.get_id(cr, uid, inv.journal_id.sequence_id.id)
+                name = seq_obj.next_by_id(cr, uid, inv.journal_id.sequence_id.id)
             else:
                 raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !'))
             if not inv.reference:

=== modified file 'point_of_sale/wizard/pos_open_statement.py'
--- point_of_sale/wizard/pos_open_statement.py	2011-09-25 21:00:20 +0000
+++ point_of_sale/wizard/pos_open_statement.py	2011-09-30 21:06:25 +0000
@@ -53,9 +53,9 @@
                 continue
 
             if journal.sequence_id:
-                number = sequence_obj.get_id(cr, uid, journal.sequence_id.id)
+                number = sequence_obj.next_by_id(cr, uid, journal.sequence_id.id)
             else:
-                number = sequence_obj.get(cr, uid, 'account.cash.statement')
+                number = sequence_obj.next_by_code(cr, uid, 'account.cash.statement')
 
             data.update({
                 'journal_id': journal.id,

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to