[FIX] account: onboarding fiscal year step various issues

Design: remove empty space in the dialog form.
Opening date:
-fix move line not created introduced by c4b9c51abf. This prevented saving the opening date;
-set default date to start of current year.
Add a validation on fiscal year last day:
-the automatic calculation was removed in 90cdc91638 but no validation was set;
-the help message became irrelevant;
-the fiscal year end date was set as readonly in 52a8ed3c0c and not fixed in 3f4f77fd9d.
This commit is contained in:
eco-odoo
2018-10-26 13:36:26 +00:00
parent 40c6bc3ad2
commit b2a14dda03
3 changed files with 32 additions and 9 deletions
+23
View File
@@ -89,6 +89,22 @@ Best Regards,'''))
account_invoice_onboarding_state = fields.Selection([('not_done', "Not done"), ('just_done', "Just done"), ('done', "Done"), ('closed', "Closed")], string="State of the account invoice onboarding panel", default='not_done')
account_dashboard_onboarding_state = fields.Selection([('not_done', "Not done"), ('just_done', "Just done"), ('done', "Done"), ('closed', "Closed")], string="State of the account dashboard onboarding panel", default='not_done')
@api.constrains('account_opening_date', 'fiscalyear_last_day', 'fiscalyear_last_month')
def _check_fiscalyear_last_day(self):
# if the user explicitly chooses the 29th of February we allow it:
# there is no "fiscalyear_last_year" so we do not know his intentions.
if self.fiscalyear_last_day == 29 and self.fiscalyear_last_month == 2:
return
if self.account_opening_date:
year = self.account_opening_date.year
else:
year = datetime.now().year
max_day = calendar.monthrange(year, self.fiscalyear_last_month)[1]
if self.fiscalyear_last_day > max_day:
raise ValidationError(_("Invalid fiscal year last day"))
def get_and_update_account_invoice_onboarding_state(self):
""" This method is called on the controller rendering method and ensures that the animations
are displayed only one time. """
@@ -285,6 +301,7 @@ Best Regards,'''))
def setting_init_fiscal_year_action(self):
""" Called by the 'Fiscal Year Opening' button of the setup bar."""
company = self.env.user.company_id
company.create_op_move_if_non_existant()
new_wizard = self.env['account.financial.year.op'].create({'company_id': company.id})
view_id = self.env.ref('account.setup_financial_year_opening_form').id
@@ -339,10 +356,16 @@ Best Regards,'''))
if not default_journal:
raise UserError(_("Please install a chart of accounts or create a miscellaneous journal before proceeding."))
today = datetime.today().date()
opening_date = today.replace(month=self.fiscalyear_last_month, day=self.fiscalyear_last_day) + timedelta(days=1)
if opening_date > today:
opening_date = opening_date + relativedelta(years=-1)
self.account_opening_move_id = self.env['account.move'].create({
'name': _('Opening Journal Entry'),
'company_id': self.id,
'journal_id': default_journal.id,
'date': opening_date,
})
def opening_move_posted(self):
+4 -4
View File
@@ -11,23 +11,23 @@ class FinancialYearOpeningWizard(models.TransientModel):
company_id = fields.Many2one(comodel_name='res.company', required=True)
opening_move_posted = fields.Boolean(string='Opening Move Posted', compute='_compute_opening_move_posted')
opening_date = fields.Date(string='Opening Date', required=True, related='company_id.account_opening_date', help="Date from which the accounting is managed in Odoo. It is the date of the opening entry.", readonly=False)
fiscalyear_last_day = fields.Integer(related="company_id.fiscalyear_last_day", required=True,
help="The last day of the month will be taken if the chosen day doesn't exist.")
fiscalyear_last_day = fields.Integer(related="company_id.fiscalyear_last_day", required=True, readonly=False,
help="Fiscal year last day.")
fiscalyear_last_month = fields.Selection(selection=[(1, 'January'), (2, 'February'), (3, 'March'), (4, 'April'), (5, 'May'), (6, 'June'), (7, 'July'), (8, 'August'), (9, 'September'), (10, 'October'), (11, 'November'), (12, 'December')],
related="company_id.fiscalyear_last_month", readonly=False,
required=True,
help="The last day of the month will be taken if the chosen day doesn't exist.")
help="Fiscal year last month.")
@api.depends('company_id.account_opening_move_id')
def _compute_opening_move_posted(self):
for record in self:
record.opening_move_posted = record.company_id.opening_move_posted()
@api.multi
def action_save_onboarding_fiscal_year(self):
self.env.user.company_id.set_onboarding_step_done('account_setup_fy_data_state')
class SetupBarBankConfigWizard(models.TransientModel):
_inherits = {'res.partner.bank': 'res_partner_bank_id'}
_name = 'account.setup.bank.manual.config'
+5 -5
View File
@@ -8,23 +8,23 @@
<field name="arch" type="xml">
<form>
<div class="row">
<div class="col-4">
<div class="col-2">
<label for="opening_date"/>
</div>
<div class="col-8">
<div class="col-3">
<field name="opening_move_posted" invisible="1"/>
<field name="opening_date" attrs="{'readonly': [('opening_move_posted', '=', True)]}"/>
</div>
</div>
<div class="row">
<div class="col-4">
<div class="col-2">
<strong>Fiscal Year End</strong>
</div>
<div class="col-4">
<div class="col-1">
<field name="fiscalyear_last_day"/>
</div>
<div class="col-4">
<div class="col-2">
<field name="fiscalyear_last_month"/>
</div>
</div>