summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwan <wan@odoo.com>2019-07-24 09:59:24 +0000
committerwan <wan@odoo.com>2019-08-19 10:17:47 +0000
commit646a6d5a73722c6d431e8ac71da4e1bb64c66e86 (patch)
treecc94b6aa2782c013cb8af38468e70e979a364aa9
parentdc066a54f1c695eb5223f1316dead96ac8b53193 (diff)
[IMP] account: improve the onboarding
Task 2031686 * Change some labels on the dashboard * Move the action "Take money In/Out" to a button because it was also dsplayed in bank journals and we only want it for cash journals * Add reconciliation param on the first account config list, as well as a button to go to the form (it is an editable list) * Add an action to duplicate accounts in batch * Smartly detect when a cash statement can be extended instead of creating a new one, making it more obvious to the user that he may need to validate his previous statement(s) closes odoo/odoo#35137 Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
-rw-r--r--addons/account/__manifest__.py2
-rw-r--r--addons/account/models/account.py16
-rw-r--r--addons/account/models/account_journal_dashboard.py18
-rw-r--r--addons/account/models/company.py2
-rw-r--r--addons/account/views/account_onboarding_templates.xml4
-rw-r--r--addons/account/views/account_view.xml12
-rw-r--r--addons/account/wizard/pos_box.xml1
-rw-r--r--addons/account/wizard/setup_wizards.py2
-rw-r--r--addons/account/wizard/setup_wizards_view.xml35
9 files changed, 63 insertions, 29 deletions
diff --git a/addons/account/__manifest__.py b/addons/account/__manifest__.py
index 8ac138e2e3a..fb30ac2ebe7 100644
--- a/addons/account/__manifest__.py
+++ b/addons/account/__manifest__.py
@@ -28,12 +28,12 @@ You could use this simplified accounting in case you work with an (external) acc
'wizard/account_move_reversal_view.xml',
'views/account_move_views.xml',
'wizard/setup_wizards_view.xml',
+ 'wizard/pos_box.xml',
'views/account_view.xml',
'views/report_statement.xml',
'views/account_report.xml',
'data/mail_template_data.xml',
'wizard/account_validate_move_view.xml',
- 'wizard/pos_box.xml',
'views/account_end_fy.xml',
'views/partner_view.xml',
'views/product_view.xml',
diff --git a/addons/account/models/account.py b/addons/account/models/account.py
index 69c5d290e71..c1bfb6766b1 100644
--- a/addons/account/models/account.py
+++ b/addons/account/models/account.py
@@ -476,6 +476,22 @@ class AccountAccount(models.Model):
'context': action_context,
}
+ def action_read_account(self):
+ self.ensure_one()
+ return {
+ 'name': self.display_name,
+ 'type': 'ir.actions.act_window',
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'account.account',
+ 'res_id': self.id,
+ 'target': 'new',
+ }
+
+ def action_duplicate_accounts(self):
+ for account in self.browse(self.env.context['active_ids']):
+ account.copy()
+
class AccountGroup(models.Model):
_name = "account.group"
diff --git a/addons/account/models/account_journal_dashboard.py b/addons/account/models/account_journal_dashboard.py
index 1cde8e6dc88..a2ff5d54571 100644
--- a/addons/account/models/account_journal_dashboard.py
+++ b/addons/account/models/account_journal_dashboard.py
@@ -135,14 +135,14 @@ class account_journal(models.Model):
def get_bar_graph_datas(self):
data = []
today = fields.Datetime.now(self)
- data.append({'label': _('Past'), 'value':0.0, 'type': 'past'})
+ data.append({'label': _('Due'), 'value':0.0, 'type': 'past'})
day_of_week = int(format_datetime(today, 'e', locale=self._context.get('lang') or 'en_US'))
first_day_of_week = today + timedelta(days=-day_of_week+1)
for i in range(-1,4):
if i==0:
label = _('This Week')
elif i==3:
- label = _('Future')
+ label = _('Not Due')
else:
start_week = first_day_of_week + timedelta(days=i*7)
end_week = start_week + timedelta(days=6)
@@ -391,13 +391,25 @@ class account_journal(models.Model):
def create_cash_statement(self):
ctx = self._context.copy()
ctx.update({'journal_id': self.id, 'default_journal_id': self.id, 'default_journal_type': 'cash'})
- return {
+ open_statements = self.env['account.bank.statement'].search([('journal_id', '=', self.id), ('state', '=', 'open')])
+ action = {
'name': _('Create cash statement'),
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'account.bank.statement',
'context': ctx,
}
+ if len(open_statements) == 1:
+ action.update({
+ 'view_mode': 'form',
+ 'res_id': open_statements.id,
+ })
+ elif len(open_statements) > 1:
+ action.update({
+ 'view_mode': 'tree,form',
+ 'domain': [('id', 'in', open_statements.ids)],
+ })
+ return action
def action_open_reconcile(self):
if self.type in ['bank', 'cash']:
diff --git a/addons/account/models/company.py b/addons/account/models/company.py
index 7c4743ee2b6..95980862702 100644
--- a/addons/account/models/company.py
+++ b/addons/account/models/company.py
@@ -320,7 +320,7 @@ Best Regards,'''))
return {
'type': 'ir.actions.act_window',
- 'name': _('Fiscal Year'),
+ 'name': _('Accounting Periods'),
'view_mode': 'form',
'res_model': 'account.financial.year.op',
'target': 'new',
diff --git a/addons/account/views/account_onboarding_templates.xml b/addons/account/views/account_onboarding_templates.xml
index 1f2af4843fb..775eef36cb4 100644
--- a/addons/account/views/account_onboarding_templates.xml
+++ b/addons/account/views/account_onboarding_templates.xml
@@ -39,8 +39,8 @@
</template>
<template id="onboarding_fiscal_year_step">
<t t-call="base.onboarding_step">
- <t t-set="title">Fiscal Year</t>
- <t t-set="description">Define your fiscal years opening &amp; closing dates.</t>
+ <t t-set="title">Accounting Periods</t>
+ <t t-set="description">Define your fiscal years &amp; tax returns periodicity.</t>
<t t-set="btn_text">Configure</t>
<t t-set="done_text">Step Completed!</t>
<t t-set="method" t-value="'setting_init_fiscal_year_action'" />
diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml
index 18f65bc285a..767d6779c79 100644
--- a/addons/account/views/account_view.xml
+++ b/addons/account/views/account_view.xml
@@ -121,6 +121,17 @@
<menuitem action="action_account_form" id="menu_action_account_form" parent="account.account_account_menu" groups="account.group_account_user" sequence="2"/>
+ <record id="action_duplicate_account" model="ir.actions.server">
+ <field name="name">Duplicate</field>
+ <field name="model_id" ref="model_account_account"/>
+ <field name="binding_model_id" ref="account.model_account_account"/>
+ <field name="binding_view_types">list</field>
+ <field name="state">code</field>
+ <field name="code">
+ action = model.action_duplicate_accounts()
+ </field>
+ </record>
+
<!-- Account Journal -->
<record id="view_account_journal_tree" model="ir.ui.view">
<field name="name">account.journal.tree</field>
@@ -554,6 +565,7 @@ action = model.setting_init_bank_account_action()
<field name="all_lines_reconciled" invisible="1" />
<button name="action_bank_reconcile_bank_statements" string="Reconcile" type="object" class="oe_highlight" attrs="{'invisible':['|','|',('all_lines_reconciled','=',True),('line_ids','=',[]),('state', '!=', 'open')]}"/>
<button name="check_confirm_bank" string="Validate" type="object" class="oe_highlight" attrs="{'invisible':['|','|',('all_lines_reconciled','=',False),('line_ids','=',[]),('state', '!=', 'open')]}"/>
+ <button name="%(action_cash_box_out)d" string="Take Money In/Out" type="action" class="oe_highlight" attrs="{'invisible': [('journal_type','!=','cash')]}"/>
<field name="state" widget="statusbar" statusbar_visible="open,confirm"/>
</header>
<sheet>
diff --git a/addons/account/wizard/pos_box.xml b/addons/account/wizard/pos_box.xml
index d8efbc160ff..4657a145e85 100644
--- a/addons/account/wizard/pos_box.xml
+++ b/addons/account/wizard/pos_box.xml
@@ -23,7 +23,6 @@
<act_window
name="Take Money In/Out"
res_model="cash.box.out"
- binding_model="account.bank.statement"
view_mode="form"
target="new"
id="action_cash_box_out" />
diff --git a/addons/account/wizard/setup_wizards.py b/addons/account/wizard/setup_wizards.py
index bfa7ea07ddc..e54f38a0ea8 100644
--- a/addons/account/wizard/setup_wizards.py
+++ b/addons/account/wizard/setup_wizards.py
@@ -14,7 +14,7 @@ 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,
+ fiscalyear_last_day = fields.Integer(related="company_id.fiscalyear_last_day", required=True, readonly=False,
help="The last day of the month will be used if the chosen day doesn't exist.")
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,
diff --git a/addons/account/wizard/setup_wizards_view.xml b/addons/account/wizard/setup_wizards_view.xml
index f0c297f26ca..9ae9c8d00da 100644
--- a/addons/account/wizard/setup_wizards_view.xml
+++ b/addons/account/wizard/setup_wizards_view.xml
@@ -7,27 +7,20 @@
<field name="model">account.financial.year.op</field>
<field name="arch" type="xml">
<form>
- <div class="row">
- <div class="col-2">
- <label for="opening_date"/>
- </div>
- <div class="col-3">
- <field name="opening_move_posted" invisible="1"/>
- <field name="opening_date" attrs="{'readonly': [('opening_move_posted', '=', True)]}"/>
- </div>
- </div>
+ <sheet>
+ <group>
+ <group string="Fiscal Years">
+ <field name="opening_move_posted" invisible="1"/>
+ <field name="opening_date" attrs="{'readonly': [('opening_move_posted', '=', True)]}"/>
- <div class="row">
- <div class="col-2">
- <strong>Fiscal Year End</strong>
- </div>
- <div class="col-1">
- <field name="fiscalyear_last_day"/>
- </div>
- <div class="col-2">
- <field name="fiscalyear_last_month"/>
- </div>
- </div>
+ <label for="fiscalyear_last_month" string="Fiscal Year End"/>
+ <div>
+ <field name="fiscalyear_last_day"/>
+ <field name="fiscalyear_last_month"/>
+ </div>
+ </group>
+ </group>
+ </sheet>
<footer>
<button name="action_save_onboarding_fiscal_year" string="Apply"
class="oe_highlight" type="object" />
@@ -84,8 +77,10 @@
<field name="code"/>
<field name="name"/>
<field name="user_type_id"/>
+ <field name="reconcile" widget="boolean_toggle"/>
<field name="opening_debit"/>
<field name="opening_credit"/>
+ <button name="action_read_account" type="object" icon="fa-expand" title="Open" aria-label="Open" class="float-right"/>
</tree>
</field>
</record>