Cambio de numeración borrador a numeración del diario
This commit is contained in:
parent
ecf654360c
commit
a099c04459
1 changed files with 39 additions and 0 deletions
39
account.py
39
account.py
|
@ -41,6 +41,45 @@ class Move(metaclass=PoolMeta):
|
||||||
cls.validate_move(moves)
|
cls.validate_move(moves)
|
||||||
return moves
|
return moves
|
||||||
|
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
@ModelView.button
|
||||||
|
def post(cls, moves):
|
||||||
|
pool = Pool()
|
||||||
|
Date = pool.get('ir.date')
|
||||||
|
Line = pool.get('account.move.line')
|
||||||
|
|
||||||
|
for move in moves:
|
||||||
|
amount = Decimal('0.0')
|
||||||
|
if not move.lines:
|
||||||
|
raise PostError(
|
||||||
|
gettext('account.msg_post_empty_move', move=move.rec_name))
|
||||||
|
company = None
|
||||||
|
for line in move.lines:
|
||||||
|
amount += line.debit - line.credit
|
||||||
|
if not company:
|
||||||
|
company = line.account.company
|
||||||
|
if not company.currency.is_zero(amount):
|
||||||
|
raise PostError(
|
||||||
|
gettext('account.msg_post_unbalanced_move',
|
||||||
|
move=move.rec_name))
|
||||||
|
for move in moves:
|
||||||
|
move.state = 'posted'
|
||||||
|
move.number = Sequence.get_id(move.journal.sequence.id)
|
||||||
|
if not move.post_number:
|
||||||
|
move.post_date = Date.today()
|
||||||
|
move.post_number = move.period.post_move_sequence_used.get()
|
||||||
|
|
||||||
|
def keyfunc(l):
|
||||||
|
return l.party, l.account
|
||||||
|
to_reconcile = [l for l in move.lines
|
||||||
|
if ((l.debit == l.credit == Decimal('0'))
|
||||||
|
and l.account.reconcile)]
|
||||||
|
to_reconcile = sorted(to_reconcile, key=keyfunc)
|
||||||
|
for _, zero_lines in groupby(to_reconcile, keyfunc):
|
||||||
|
Line.reconcile(list(zero_lines))
|
||||||
|
cls.save(moves)
|
||||||
|
|
||||||
|
|
||||||
class Line(metaclass=PoolMeta):
|
class Line(metaclass=PoolMeta):
|
||||||
__name__ = 'account.move.line'
|
__name__ = 'account.move.line'
|
||||||
|
|
Loading…
Reference in a new issue