diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 29fcaa17c8e..21bc3ff9a43 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -662,6 +662,8 @@ class AccountTax(models.Model): analytic = fields.Boolean(string="Include in Analytic Cost", help="If set, the amount computed by this tax will be assigned to the same analytic account as the invoice line (if any)") tag_ids = fields.Many2many('account.account.tag', 'account_tax_account_tag', string='Tags', help="Optional tags you may want to assign for custom reporting") tax_group_id = fields.Many2one('account.tax.group', string="Tax Group", default=_default_tax_group, required=True) + # Technical field to make the 'use_cash_basis' field invisible if the same named field is set to false in 'res.company' model + hide_use_cash_basis = fields.Boolean(string='Hide Use Cash Basis Option', related='company_id.use_cash_basis') use_cash_basis = fields.Boolean( 'Use Cash Basis', help="Select this if the tax should use cash basis," diff --git a/addons/account/models/account_config_settings.py b/addons/account/models/account_config_settings.py index 66fc95756ac..c70bb30bf4e 100644 --- a/addons/account/models/account_config_settings.py +++ b/addons/account/models/account_config_settings.py @@ -60,6 +60,8 @@ class AccountConfigSettings(models.TransientModel): module_product_margin = fields.Boolean(string="Allow Product Margin") module_l10n_eu_service = fields.Boolean(string="EU Digital Goods VAT") module_account_taxcloud = fields.Boolean(string="Account TaxCloud") + use_cash_basis = fields.Boolean(string='Cash Basis', related='company_id.use_cash_basis') + tax_cash_basis_journal_id = fields.Many2one('account.journal', related='company_id.tax_cash_basis_journal_id', string="Tax Cash Basis Journal") @api.model def get_values(self): @@ -123,6 +125,21 @@ class AccountConfigSettings(models.TransientModel): if self.module_account_yodlee: self.module_account_plaid = True + @api.onchange('use_cash_basis') + def _onchange_use_cash_basis(self): + res = {} + tax = self.env['account.tax'].search([ + ('company_id', '=', self.env.user.company_id.id), ('use_cash_basis', '=', True) + ], limit=1) + if not self.use_cash_basis and tax: + self.use_cash_basis = True + res['warning'] = { + 'title': _('Error!'), + 'message': _('You cannot disable this setting because some of your taxes are cash basis. ' + 'Modify your taxes first before disabling this setting.') + } + return res + @api.model def create(self, values): # Optimisation purpose, saving a res_config even without changing any values will trigger the write of all diff --git a/addons/account/models/chart_template.py b/addons/account/models/chart_template.py index 4bd84cd5037..8c59f15fad8 100644 --- a/addons/account/models/chart_template.py +++ b/addons/account/models/chart_template.py @@ -598,6 +598,11 @@ class AccountTaxTemplate(models.Model): 'cash_basis_account': tax.cash_basis_account.id, } + if any([tax.use_cash_basis for tax in self]): + # When a CoA is being installed automatically and if it is creating account tax(es) whose field `Use Cash Basis`(use_cash_basis) is set to True by default + # (exapmple of such CoA's are l10n_fr and l10n_mx) then in the `Accounting Settings` the option `Cash Basis` should be checked by default. + company.use_cash_basis = True + return { 'tax_template_to_tax': tax_template_to_tax, 'account_dict': todo_dict diff --git a/addons/account/models/company.py b/addons/account/models/company.py index 584c1e44c99..4bcdbd191b8 100644 --- a/addons/account/models/company.py +++ b/addons/account/models/company.py @@ -44,6 +44,7 @@ If you have any queries regarding your account, Please contact us. Thank you in advance for your cooperation. Best Regards,''') + use_cash_basis = fields.Boolean(string='Use Cash Basis') @api.multi def compute_fiscalyear_dates(self, date): diff --git a/addons/account/views/account_config_settings_views.xml b/addons/account/views/account_config_settings_views.xml index c9fd59d1954..66ff5ab2076 100644 --- a/addons/account/views/account_config_settings_views.xml +++ b/addons/account/views/account_config_settings_views.xml @@ -112,6 +112,24 @@ +
+
+ +
+
+
+

Accounting Reports

@@ -189,31 +207,6 @@
-

Invoicing

-
-
-
- -
-
-
-
-
-
- -
-
-
-
-

Customer Payments

@@ -379,6 +372,31 @@
+

Invoicing

+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
diff --git a/addons/account/views/account_view.xml b/addons/account/views/account_view.xml index f8679f58ab8..6adbb40edf7 100644 --- a/addons/account/views/account_view.xml +++ b/addons/account/views/account_view.xml @@ -1053,7 +1053,8 @@ - + + diff --git a/addons/account_accountant/models/account_config_settings.py b/addons/account_accountant/models/account_config_settings.py index 3059bbd2d93..b88619b224a 100644 --- a/addons/account_accountant/models/account_config_settings.py +++ b/addons/account_accountant/models/account_config_settings.py @@ -29,7 +29,3 @@ class AccountConfigSettings(models.TransientModel): related='company_id.transfer_account_id', domain=lambda self: [('reconcile', '=', True), ('user_type_id.id', '=', self.env.ref('account.data_account_type_current_assets').id)], help="Intermediary account used when moving money from a liquidity account to another") - tax_cash_basis_journal_id = fields.Many2one( - 'account.journal', - related='company_id.tax_cash_basis_journal_id', - string="Tax Cash Basis Journal",) diff --git a/addons/account_accountant/views/account_config_settings_views.xml b/addons/account_accountant/views/account_config_settings_views.xml index 50ce3007618..68f5eef97ca 100644 --- a/addons/account_accountant/views/account_config_settings_views.xml +++ b/addons/account_accountant/views/account_config_settings_views.xml @@ -77,23 +77,6 @@ -
-
-
-
-
-
-

Automated Entries