|
@ -9,6 +9,8 @@ from odoo import api, fields, models, _ |
|
|
from odoo.tools.safe_eval import safe_eval |
|
|
from odoo.tools.safe_eval import safe_eval |
|
|
from odoo.exceptions import ValidationError |
|
|
from odoo.exceptions import ValidationError |
|
|
|
|
|
|
|
|
|
|
|
import time |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GeneralLedgerReportWizard(models.TransientModel): |
|
|
class GeneralLedgerReportWizard(models.TransientModel): |
|
|
"""General ledger report wizard.""" |
|
|
"""General ledger report wizard.""" |
|
@ -26,8 +28,10 @@ class GeneralLedgerReportWizard(models.TransientModel): |
|
|
comodel_name='date.range', |
|
|
comodel_name='date.range', |
|
|
string='Date range' |
|
|
string='Date range' |
|
|
) |
|
|
) |
|
|
date_from = fields.Date(required=True) |
|
|
|
|
|
date_to = fields.Date(required=True) |
|
|
|
|
|
|
|
|
date_from = fields.Date(required=True, |
|
|
|
|
|
default=lambda self: self._init_date_from()) |
|
|
|
|
|
date_to = fields.Date(required=True, |
|
|
|
|
|
default=fields.Date.context_today) |
|
|
fy_start_date = fields.Date(compute='_compute_fy_start_date') |
|
|
fy_start_date = fields.Date(compute='_compute_fy_start_date') |
|
|
target_move = fields.Selection([('posted', 'All Posted Entries'), |
|
|
target_move = fields.Selection([('posted', 'All Posted Entries'), |
|
|
('all', 'All Entries')], |
|
|
('all', 'All Entries')], |
|
@ -100,6 +104,18 @@ class GeneralLedgerReportWizard(models.TransientModel): |
|
|
|
|
|
|
|
|
return list(partner_ids) |
|
|
return list(partner_ids) |
|
|
|
|
|
|
|
|
|
|
|
def _init_date_from(self): |
|
|
|
|
|
"""set start date to begin of current year if fiscal year running""" |
|
|
|
|
|
today = fields.Date.context_today(self) |
|
|
|
|
|
cur_month = int(fields.Date.from_string(today).strftime('%m')) |
|
|
|
|
|
cur_day = int(fields.Date.from_string(today).strftime('%d')) |
|
|
|
|
|
last_fsc_month = self.env.user.company_id.fiscalyear_last_month |
|
|
|
|
|
last_fsc_day = self.env.user.company_id.fiscalyear_last_day |
|
|
|
|
|
|
|
|
|
|
|
if cur_month < last_fsc_month \ |
|
|
|
|
|
or cur_month == last_fsc_month and cur_day <= last_fsc_day: |
|
|
|
|
|
return time.strftime('%Y-01-01') |
|
|
|
|
|
|
|
|
@api.depends('date_from') |
|
|
@api.depends('date_from') |
|
|
def _compute_fy_start_date(self): |
|
|
def _compute_fy_start_date(self): |
|
|
for wiz in self.filtered('date_from'): |
|
|
for wiz in self.filtered('date_from'): |
|
@ -164,6 +180,7 @@ class GeneralLedgerReportWizard(models.TransientModel): |
|
|
@api.onchange('date_range_id') |
|
|
@api.onchange('date_range_id') |
|
|
def onchange_date_range_id(self): |
|
|
def onchange_date_range_id(self): |
|
|
"""Handle date range change.""" |
|
|
"""Handle date range change.""" |
|
|
|
|
|
if self.date_range_id: |
|
|
self.date_from = self.date_range_id.date_start |
|
|
self.date_from = self.date_range_id.date_start |
|
|
self.date_to = self.date_range_id.date_end |
|
|
self.date_to = self.date_range_id.date_end |
|
|
|
|
|
|
|
|