Improve default date for reversal: D+1 instead of today

This commit is contained in:
Alexis de Lattre
2018-05-09 18:43:47 +02:00
parent 020ca72188
commit 23bd22a009
2 changed files with 25 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
# -*- encoding: utf-8 -*-
from . import account_invoice_mark_sent
from . import account_move_reversal

View File

@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models
from dateutil.relativedelta import relativedelta
class AccountMoveReversal(models.TransientModel):
_inherit = 'account.move.reversal'
@api.model
def _default_date(self):
date = None
if (
self._context.get('active_model') == 'account.move' and
self._context.get('active_id')):
move = self.env['account.move'].browse(self._context['active_id'])
date_dt = fields.Date.from_string(move.date) +\
relativedelta(days=1)
date = fields.Date.to_string(date_dt)
return date
date = fields.Date(default=_default_date)