[REF] account: remove unused actions

Task 2201948

*These actions were either unused or only used in enterprise modules.
The first ones have been deleted, and the second ones have been move to
the corresponding enterprise modules.

* account.fiscal.year: the whole model has been moved to enterprise

closes odoo/odoo#46110

Related: odoo/enterprise#8706
Related: odoo/upgrade#1083
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
This commit is contained in:
wan
2020-05-20 07:29:29 +00:00
committed by william
parent 3d7ed0e74b
commit 576a69e29e
19 changed files with 3 additions and 413 deletions
-1
View File
@@ -68,7 +68,6 @@ You could use this simplified accounting in case you work with an (external) acc
'data/payment_receipt_data.xml',
'views/account_onboarding_templates.xml',
'data/service_cron.xml',
'views/account_fiscal_year_view.xml',
'views/account_incoterms_view.xml',
'data/account_incoterms_data.xml',
'views/digest_views.xml',
-1
View File
@@ -18,7 +18,6 @@ from . import chart_template
from . import account_analytic_line
from . import account_journal_dashboard
from . import product
from . import account_fiscal_year
from . import company
from . import res_config_settings
from . import account_cash_rounding
@@ -1,55 +0,0 @@
# -*- coding: utf-8 -*-
from odoo.exceptions import ValidationError
from odoo import api, fields, models, _
from datetime import datetime
class AccountFiscalYear(models.Model):
_name = 'account.fiscal.year'
_description = 'Fiscal Year'
name = fields.Char(string='Name', required=True)
date_from = fields.Date(string='Start Date', required=True,
help='Start Date, included in the fiscal year.')
date_to = fields.Date(string='End Date', required=True,
help='Ending Date, included in the fiscal year.')
company_id = fields.Many2one('res.company', string='Company', required=True,
default=lambda self: self.env.company)
@api.constrains('date_from', 'date_to', 'company_id')
def _check_dates(self):
'''
Check interleaving between fiscal years.
There are 3 cases to consider:
s1 s2 e1 e2
( [----)----]
s2 s1 e2 e1
[----(----] )
s1 s2 e2 e1
( [----] )
'''
for fy in self:
# Starting date must be prior to the ending date
date_from = fy.date_from
date_to = fy.date_to
if date_to < date_from:
raise ValidationError(_('The ending date must not be prior to the starting date.'))
domain = [
('id', '!=', fy.id),
('company_id', '=', fy.company_id.id),
'|', '|',
'&', ('date_from', '<=', fy.date_from), ('date_to', '>=', fy.date_from),
'&', ('date_from', '<=', fy.date_to), ('date_to', '>=', fy.date_to),
'&', ('date_from', '<=', fy.date_from), ('date_to', '>=', fy.date_to),
]
if self.search_count(domain) > 0:
raise ValidationError(_('You can not have an overlap between two fiscal years, please correct the start and/or end dates of your fiscal years.'))
+1 -57
View File
@@ -6,9 +6,8 @@ from dateutil.relativedelta import relativedelta
from odoo import fields, models, api, _
from odoo.exceptions import ValidationError, UserError, RedirectWarning
from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT, format_date
from odoo.tools.misc import format_date
from odoo.tools.float_utils import float_round, float_is_zero
from odoo.tools import date_utils
from odoo.tests.common import Form
@@ -165,61 +164,6 @@ class ResCompany(models.Model):
'account_setup_coa_state',
]
def compute_fiscalyear_dates(self, current_date):
'''Computes the start and end dates of the fiscal year where the given 'date' belongs to.
:param current_date: A datetime.date/datetime.datetime object.
:return: A dictionary containing:
* date_from
* date_to
* [Optionally] record: The fiscal year record.
'''
self.ensure_one()
date_str = current_date.strftime(DEFAULT_SERVER_DATE_FORMAT)
# Search a fiscal year record containing the date.
# If a record is found, then no need further computation, we get the dates range directly.
fiscalyear = self.env['account.fiscal.year'].search([
('company_id', '=', self.id),
('date_from', '<=', date_str),
('date_to', '>=', date_str),
], limit=1)
if fiscalyear:
return {
'date_from': fiscalyear.date_from,
'date_to': fiscalyear.date_to,
'record': fiscalyear,
}
date_from, date_to = date_utils.get_fiscal_year(
current_date, day=self.fiscalyear_last_day, month=int(self.fiscalyear_last_month))
date_from_str = date_from.strftime(DEFAULT_SERVER_DATE_FORMAT)
date_to_str = date_to.strftime(DEFAULT_SERVER_DATE_FORMAT)
# Search for fiscal year records reducing the delta between the date_from/date_to.
# This case could happen if there is a gap between two fiscal year records.
# E.g. two fiscal year records: 2017-01-01 -> 2017-02-01 and 2017-03-01 -> 2017-12-31.
# => The period 2017-02-02 - 2017-02-30 is not covered by a fiscal year record.
fiscalyear_from = self.env['account.fiscal.year'].search([
('company_id', '=', self.id),
('date_from', '<=', date_from_str),
('date_to', '>=', date_from_str),
], limit=1)
if fiscalyear_from:
date_from = fiscalyear_from.date_to + timedelta(days=1)
fiscalyear_to = self.env['account.fiscal.year'].search([
('company_id', '=', self.id),
('date_from', '<=', date_to_str),
('date_to', '>=', date_to_str),
], limit=1)
if fiscalyear_to:
date_to = fiscalyear_to.date_from - timedelta(days=1)
return {'date_from': date_from, 'date_to': date_to}
def get_new_account_code(self, current_code, old_prefix, new_prefix):
digits = len(current_code)
return new_prefix + current_code.replace(old_prefix, '', 1).lstrip('0').rjust(digits-len(new_prefix), '0')
@@ -29,7 +29,6 @@ class ResConfigSettings(models.TransientModel):
group_analytic_tags = fields.Boolean(string='Analytic Tags', implied_group='analytic.group_analytic_tags')
group_warning_account = fields.Boolean(string="Warnings in Invoices", implied_group='account.group_warning_account')
group_cash_rounding = fields.Boolean(string="Cash Rounding", implied_group='account.group_cash_rounding')
group_fiscal_year = fields.Boolean(string='Fiscal Years', implied_group='account.group_fiscal_year')
# group_show_line_subtotals_tax_excluded and group_show_line_subtotals_tax_included are opposite,
# so we can assume exactly one of them will be set, and not the other.
# We need both of them to coexist so we can take advantage of automatic group assignation.
@@ -61,11 +61,6 @@
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record id="group_fiscal_year" model="res.groups">
<field name="name">Allow to define fiscal years of more or less than a year</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>
<record id="group_sale_receipts" model="res.groups">
<field name="name">Sale Receipt</field>
<field name="category_id" ref="base.module_category_hidden"/>
@@ -25,9 +25,6 @@ access_account_invoice_report,account.invoice.report,model_account_invoice_repor
access_account_incoterms_all,account.incoterms all,model_account_incoterms,,1,0,0,0
access_account_incoterms_manager,account.incoterms manager,model_account_incoterms,account.group_account_manager,1,1,1,1
access_account_fiscal_year_readonly,account.fiscal.year.user,model_account_fiscal_year,account.group_account_readonly,1,0,0,0
access_account_fiscal_year_manager,account.fiscal.year.manager,model_account_fiscal_year,account.group_account_manager,1,1,1,1
access_account_fiscal_position_product_manager,account.fiscal.position account.manager,model_account_fiscal_position,account.group_account_manager,1,1,1,1
access_account_fiscal_position_tax_product_manager,account.fiscal.position.tax account.manager,model_account_fiscal_position_tax,account.group_account_manager,1,1,1,1
access_account_fiscal_position_account_product_manager,account.fiscal.position account.manager,model_account_fiscal_position_account,account.group_account_manager,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
25 access_account_fiscal_position_product_manager access_account_fiscal_position_account_product_manager account.fiscal.position account.manager model_account_fiscal_position model_account_fiscal_position_account account.group_account_manager 1 1 1 1
26 access_account_fiscal_position_tax_product_manager access_account_fiscal_position account.fiscal.position.tax account.manager account.fiscal.position all model_account_fiscal_position_tax model_account_fiscal_position account.group_account_manager base.group_user 1 1 0 1 0 1 0
27 access_account_fiscal_position_account_product_manager access_account_fiscal_position_tax account.fiscal.position account.manager account.fiscal.position.tax all model_account_fiscal_position_account model_account_fiscal_position_tax account.group_account_manager base.group_user 1 1 0 1 0 1 0
access_account_fiscal_position account.fiscal.position all model_account_fiscal_position base.group_user 1 0 0 0
access_account_fiscal_position_tax account.fiscal.position.tax all model_account_fiscal_position_tax base.group_user 1 0 0 0
access_account_fiscal_position_account account.fiscal.position all model_account_fiscal_position_account base.group_user 1 0 0 0
28 access_product_product_account_user access_account_fiscal_position_account product.product.account.user account.fiscal.position all product.model_product_product model_account_fiscal_position_account group_account_readonly base.group_user 1 0 0 0
29 access_product_product_account_manager access_product_product_account_user product.product.account.manager product.product.account.user product.model_product_product account.group_account_manager group_account_readonly 1 1 0 1 0 1 0
30 access_account_cashbox access_product_product_account_manager account.bank.statement.cashbox product.product.account.manager model_account_bank_statement_cashbox product.model_product_product account.group_account_user account.group_account_manager 1 1 1 1
-1
View File
@@ -23,7 +23,6 @@ from . import test_settings
from . import test_tax
from . import test_invoice_taxes
from . import test_templates_consistency
from . import test_account_fiscal_year
from . import test_account_all_l10n
from . import test_reconciliation_matching_rules
from . import test_account_onboarding
@@ -1,131 +0,0 @@
# -*- coding: utf-8 -*-
from odoo.addons.account.tests.common import AccountTestCommon
import odoo.tests
from odoo import fields
from datetime import datetime
@odoo.tests.tagged('post_install', '-at_install')
class TestFiscalPosition(AccountTestCommon):
def check_compute_fiscal_year(self, company, date, expected_date_from, expected_date_to):
'''Compute the fiscal year at a certain date for the company passed as parameter.
Then, check if the result matches the 'expected_date_from'/'expected_date_to' dates.
:param company: The company.
:param date: The date belonging to the fiscal year.
:param expected_date_from: The expected date_from after computation.
:param expected_date_to: The expected date_to after computation.
'''
current_date = fields.Date.from_string(date)
res = company.compute_fiscalyear_dates(current_date)
self.assertEqual(res['date_from'], fields.Date.from_string(expected_date_from))
self.assertEqual(res['date_to'], fields.Date.from_string(expected_date_to))
def test_default_fiscal_year(self):
'''Basic case with a fiscal year xxxx-01-01 - xxxx-12-31.'''
company = self.env.ref('base.main_company')
company.fiscalyear_last_day = 31
company.fiscalyear_last_month = '12'
self.check_compute_fiscal_year(
company,
'2017-12-31',
'2017-01-01',
'2017-12-31',
)
self.check_compute_fiscal_year(
company,
'2017-01-01',
'2017-01-01',
'2017-12-31',
)
def test_leap_fiscal_year_1(self):
'''Case with a leap year ending the 29 February.'''
company = self.env.ref('base.main_company')
company.fiscalyear_last_day = 29
company.fiscalyear_last_month = '2'
self.check_compute_fiscal_year(
company,
'2016-02-29',
'2015-03-01',
'2016-02-29',
)
self.check_compute_fiscal_year(
company,
'2015-03-01',
'2015-03-01',
'2016-02-29',
)
def test_leap_fiscal_year_2(self):
'''Case with a leap year ending the 28 February.'''
company = self.env.ref('base.main_company')
company.fiscalyear_last_day = 28
company.fiscalyear_last_month = '2'
self.check_compute_fiscal_year(
company,
'2016-02-29',
'2015-03-01',
'2016-02-29',
)
self.check_compute_fiscal_year(
company,
'2016-03-01',
'2016-03-01',
'2017-02-28',
)
def test_custom_fiscal_year(self):
'''Case with custom fiscal years.'''
company = self.env.ref('base.main_company')
company.fiscalyear_last_day = 31
company.fiscalyear_last_month = '12'
# Create custom fiscal year covering the 6 first months of 2017.
self.env['account.fiscal.year'].create({
'name': '6 month 2017',
'date_from': '2017-01-01',
'date_to': '2017-05-31',
'company_id': company.id,
})
# Check before the custom fiscal year).
self.check_compute_fiscal_year(
company,
'2017-02-01',
'2017-01-01',
'2017-05-31',
)
# Check after the custom fiscal year.
self.check_compute_fiscal_year(
company,
'2017-11-01',
'2017-06-01',
'2017-12-31',
)
# Create custom fiscal year covering the 3 last months of 2017.
self.env['account.fiscal.year'].create({
'name': 'last 3 month 2017',
'date_from': '2017-10-01',
'date_to': '2017-12-31',
'company_id': company.id,
})
# Check inside the custom fiscal years.
self.check_compute_fiscal_year(
company,
'2017-07-01',
'2017-06-01',
'2017-09-30',
)
@@ -45,16 +45,5 @@
</field>
</record>
<record id="account_tag_action" model="ir.actions.act_window">
<field name="name">Account Tags</field>
<field name="res_model">account.account.tag</field>
<field name="search_view_id" ref="account_tag_view_search"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Add a new tag
</p>
</field>
</record>
</data>
</odoo>
@@ -103,13 +103,8 @@
<field name="context">{"search_default_current":1}</field>
</record>
<record id="action_product_default_list" model="ir.actions.act_window">
<field name="name">Analytic Rules</field>
<field name="res_model">account.analytic.default</field>
<field name="context">{'search_default_product_id': [active_id], 'default_product_id': active_id}</field>
</record>
<menuitem id="menu_analytic_default_list" sequence="3"
<menuitem id="menu_analytic_default_list"
action="action_analytic_default_list"
parent="account.menu_analytic_accounting"/>
@@ -355,14 +355,6 @@
</field>
</record>
<record id="action_bank_statement_draft_tree" model="ir.actions.act_window">
<field name="name">Draft statements</field>
<field name="res_model">account.bank.statement</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('state','=','draft')]</field>
<field name="filter" eval="True"/>
</record>
<record id="account_bank_statement_pivot" model="ir.ui.view">
<field name="name">account.bank.statement.pivot</field>
<field name="model">account.bank.statement</field>
@@ -124,13 +124,6 @@
</field>
</record>
<record id="action_account_template_form" model="ir.actions.act_window">
<field name="name">Account Templates</field>
<field name="res_model">account.account.template</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_account_template_search"/>
</record>
<!-- Account Tax Templates -->
<record id="view_account_tax_template_form" model="ir.ui.view">
@@ -282,17 +275,5 @@
</field>
</record>
<record id="action_account_fiscal_position_template_form" model="ir.actions.act_window">
<field name="name">Fiscal Position</field>
<field name="res_model">account.fiscal.position.template</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_account_position_template_search"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new fiscal position
</p>
</field>
</record>
</data>
</odoo>
@@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record id="actions_account_fiscal_year" model="ir.actions.act_window">
<field name="name">Fiscal Years</field>
<field name="res_model">account.fiscal.year</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click here to create a new fiscal year.
</p>
</field>
</record>
<record id="action_account_fiscal_year_form" model="ir.ui.view">
<field name="name">account.fiscal.year.form</field>
<field name="model">account.fiscal.year</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name" placeholder="Fiscal Year 2018"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="action_account_fiscal_year_search" model="ir.ui.view">
<field name="name">account.fiscal.year.search</field>
<field name="model">account.fiscal.year</field>
<field name="arch" type="xml">
<search>
<field name="name"/>
</search>
</field>
</record>
<record id="action_account_fiscal_year_tree" model="ir.ui.view">
<field name="name">account.fiscal.year.tree</field>
<field name="model">account.fiscal.year</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="date_from"/>
<field name="date_to"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>
</field>
</record>
</data>
</odoo>
@@ -46,17 +46,5 @@
</field>
</record>
<record id="action_account_group_tree" model="ir.actions.act_window">
<field name="name">Account Groups</field>
<field name="res_model">account.group</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_account_group_search"/>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new account group
</p>
</field>
</record>
</data>
</odoo>
@@ -61,6 +61,7 @@
<menuitem id="menu_action_account_form" parent="account.account_account_menu" action="action_account_form" groups="account.group_account_readonly" sequence="1"/>
<menuitem id="menu_action_tax_form" parent="account_account_menu" action="action_tax_form" sequence="2"/>
<menuitem id="menu_action_account_journal_form" parent="account_account_menu" action="action_account_journal_form" groups="account.group_account_manager" sequence="3"/>
<menuitem id="menu_product_product_categories" action="product.product_category_action_form" parent="account.account_account_menu" sequence="3"/>
<menuitem id="account_report_folder" name="Reporting" parent="account_account_menu" groups="account.group_account_readonly" sequence="4"/>
<menuitem id="menu_action_currency_form" action="base.action_currency_form" name="Currencies" parent="account_account_menu" groups="base.group_multi_currency" sequence="4"/>
<menuitem id="menu_action_account_fiscal_position_form" parent="account_account_menu" action="action_account_fiscal_position_form" sequence="5"/>
@@ -1151,12 +1151,6 @@
context="{'search_default_account_id': [active_id]}"
res_model="account.move.line"/>
<act_window
id="action_move_line_select_by_partner"
name="Journal Items"
context="{'search_default_partner_id': [active_id]}"
res_model="account.move.line"/>
<record id="action_accrual_entry" model="ir.actions.server">
<field name="name">Create Accrual Entries</field>
<field name="model_id" ref="account.model_account_move_line"/>
@@ -1166,13 +1160,6 @@
<field name="code">action = records.action_accrual_entry()</field>
</record>
<act_window
id="action_move_line_select_tax_audit"
name="Journal Items for Tax Audit"
context="{'search_default_account_id': [active_id]}"
res_model="account.move.line"
view_id="account.view_move_line_tax_audit_tree"/>
<record id="action_account_moves_all_a" model="ir.actions.act_window">
<field name="context">{'journal_type':'general', 'search_default_group_by_move': 1, 'search_default_posted':1, 'name_groupby':1, 'create':0}</field>
<field name="name">Journal Items</field>
@@ -1255,24 +1242,6 @@
<field name="view_mode">tree,pivot,graph,form,kanban</field>
</record>
<record id="action_move_line_graph" model="ir.actions.act_window">
<field name="name">Journal Items</field>
<field name="view_mode">graph,pivot</field>
<field name="view_id" ref="account_move_line_graph_date"/>
<field name="domain">[('display_type', 'not in', ('line_section', 'line_note'))]</field>
<field name="context">{'search_default_account_id': [active_id]}</field>
<field name="res_model">account.move.line</field>
</record>
<record id="action_move_line_graph_posted" model="ir.actions.act_window">
<field name="name">Journal Items</field>
<field name="view_mode">graph,pivot</field>
<field name="view_id" ref="account_move_line_graph_date"/>
<field name="domain">[('display_type', 'not in', ('line_section', 'line_note'))]</field>
<field name="context">{'search_default_account_id': [active_id], 'search_default_posted': 1}</field>
<field name="res_model">account.move.line</field>
</record>
<!-- account.move (Journal Entry) -->
<record id="action_move_journal_line" model="ir.actions.act_window">
@@ -194,13 +194,5 @@
</field>
</record>
<record id="action_tax_group" model="ir.actions.act_window">
<field name="name">Tax Groups</field>
<field name="res_model">account.tax.group</field>
<field name="view_mode">tree</field>
<field name="domain" eval="False"/> <!-- Force empty -->
<field name="view_id" ref="view_tax_group_tree"/>
</record>
</data>
</odoo>
@@ -23,12 +23,4 @@
</field>
</record>
<record id="action_account_common_menu" model="ir.actions.act_window">
<field name="name">Common Report</field>
<field name="res_model">account.common.report</field>
<field name="view_mode">form</field>
<field name="view_id" ref="account_common_report_view"/>
<field name="target">new</field>
</record>
</odoo>