diff options
| author | Robot Odoo <xmo+roboto@odoo.com> | 2018-10-27 00:12:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-10-27 00:12:37 +0200 |
| commit | 88a9ebdb004e3f0942d0a1de1db3f12f4d071382 (patch) | |
| tree | 02dc35f48c25f8c5d73deee64adc40cc6cdc993c | |
| parent | 40c6bc3ad21233465a72c08fff3f7951840cd47e (diff) | |
| parent | 4eeaf6c0e2a6fb4a102e6f1c99e266b6a3809139 (diff) | |
[FIX] account: fix onboarding issues
* fix in the accounting config bar ('add a bank' and 'fiscal year' steps)
* better display names and icons for vendor bills uploaded manually (moved some code that was previsouly only done in document_account for vendor bills created through the DMS)
closes odoo/odoo#27882
| -rw-r--r-- | addons/account/models/account_invoice.py | 11 | ||||
| -rw-r--r-- | addons/account/models/company.py | 23 | ||||
| -rw-r--r-- | addons/account/wizard/setup_wizards.py | 10 | ||||
| -rw-r--r-- | addons/account/wizard/setup_wizards_view.xml | 12 |
4 files changed, 41 insertions, 15 deletions
diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index 25cfa07eb1c..6b1778cec76 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -381,10 +381,15 @@ class AccountInvoice(models.Model): def _get_vendor_display_info(self): for invoice in self: vendor_display_name = invoice.partner_id.name - if not vendor_display_name and invoice.source_email: - vendor_display_name = _('From: ') + invoice.source_email + invoice.invoice_icon = '' + if not vendor_display_name: + if invoice.source_email: + vendor_display_name = _('From: ') + invoice.source_email + invoice.invoice_icon = '@' + else: + vendor_display_name = ('Created by: ') + invoice.create_uid.name + invoice.invoice_icon = '#' invoice.vendor_display_name = vendor_display_name - invoice.invoice_icon = invoice.source_email and '@' or '' @api.multi def _get_computed_reference(self): diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 223c37eea7f..5ea0db1cd95 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -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): diff --git a/addons/account/wizard/setup_wizards.py b/addons/account/wizard/setup_wizards.py index 75ee6d7c4fc..096604b13d7 100644 --- a/addons/account/wizard/setup_wizards.py +++ b/addons/account/wizard/setup_wizards.py @@ -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' @@ -89,4 +89,4 @@ class SetupBarBankConfigWizard(models.TransientModel): """ Called by the validation button of this wizard. Serves as an extension hook in account_bank_statement_import. """ - pass + self.env.user.company_id.set_onboarding_step_done('account_setup_bank_data_state') diff --git a/addons/account/wizard/setup_wizards_view.xml b/addons/account/wizard/setup_wizards_view.xml index 1c9e21c8592..3147f5e8bcc 100644 --- a/addons/account/wizard/setup_wizards_view.xml +++ b/addons/account/wizard/setup_wizards_view.xml @@ -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> @@ -65,9 +65,7 @@ <field name="related_acc_type" attrs="{'invisible': [('acc_number','=',False)]}"/> </group> </group> - </sheet> - <footer> <button string="Create" class="oe_highlight" type="object" name="validate"/> <button string="Cancel" special="cancel"/> |
