Skip to content

Commit

Permalink
Merge pull request #287 from apertoso/8.0_fix-sequence-context
Browse files Browse the repository at this point in the history
[FIX] pass proper context to ir_sequence.next_by_id()
  • Loading branch information
pedrobaeza committed Apr 7, 2016
2 parents c21008b + 875dd1a commit 6494c9f
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions sale_payment_method/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,15 @@ def _add_payment(self, journal, amount, date, description=None):

@api.model
def _get_payment_move_name(self, journal, period):
sequence = journal.sequence_id
sequence = journal.sequence_id.with_context(
fiscalyear_id=period.fiscalyear_id.id)
if not sequence:
raise exceptions.Warning(_('Please define a sequence on the '
'journal %s.') % journal.name)
if not sequence.active:
raise exceptions.Warning(_('Please activate the sequence of the '
'journal %s.') % journal.name)

sequence = sequence.with_context(fiscalyear_id=period.fiscalyear_id.id)
# next_by_id not compatible with new api
sequence_model = self.pool['ir.sequence']
name = sequence_model.next_by_id(self.env.cr, self.env.uid,
sequence.id,
context=self.env.context)
return name
return sequence.next_by_id(sequence.id)

@api.multi
def _prepare_payment_move(self, move_name, journal, period, date):
Expand Down

0 comments on commit 6494c9f

Please sign in to comment.