From 5c1fc49cc4e31522829e73042a3aa1b17ba9c311 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Tue, 19 Nov 2024 01:23:20 +0100 Subject: [PATCH] [IMP] fiscal_company_*: more security regarding the impossibility to create items on group company, or other kinds of companies --- fiscal_company_account/models/account_bank_statement.py | 2 +- fiscal_company_account/models/account_journal.py | 3 +++ fiscal_company_account/models/account_move.py | 2 +- fiscal_company_account/models/account_move_line.py | 2 +- fiscal_company_account/models/account_payment.py | 8 +++++++- fiscal_company_account/models/account_tax.py | 2 +- fiscal_company_point_of_sale/models/pos_config.py | 8 +++++++- fiscal_company_sale/models/sale_order.py | 2 +- 8 files changed, 22 insertions(+), 7 deletions(-) diff --git a/fiscal_company_account/models/account_bank_statement.py b/fiscal_company_account/models/account_bank_statement.py index b6f8fda..4e3fb3f 100644 --- a/fiscal_company_account/models/account_bank_statement.py +++ b/fiscal_company_account/models/account_bank_statement.py @@ -9,6 +9,6 @@ class AccountBankStatement(models.Model): _name = "account.bank.statement" _inherit = ["account.bank.statement", "fiscal.company.check.company.mixin"] - _fiscal_company_forbid_fiscal_type = ["fiscal_mother"] + _fiscal_company_forbid_fiscal_type = ["group", "fiscal_mother"] company_id = fields.Many2one(related=False) diff --git a/fiscal_company_account/models/account_journal.py b/fiscal_company_account/models/account_journal.py index 9dd4e82..482d8b2 100644 --- a/fiscal_company_account/models/account_journal.py +++ b/fiscal_company_account/models/account_journal.py @@ -11,8 +11,11 @@ class AccountJournal(models.Model): _inherit = [ "account.journal", "fiscal.company.change.search.domain.mixin", + "fiscal.company.check.company.mixin", ] + _fiscal_company_forbid_fiscal_type = ["group"] + def _get_journal_dashboard_data_batched(self): # Modify Context to add domain based on allowed companies # when making request on account.move diff --git a/fiscal_company_account/models/account_move.py b/fiscal_company_account/models/account_move.py index d2e552b..deae396 100644 --- a/fiscal_company_account/models/account_move.py +++ b/fiscal_company_account/models/account_move.py @@ -13,7 +13,7 @@ class AccountMove(models.Model): "fiscal.company.check.company.mixin", ] - _fiscal_company_forbid_fiscal_type = ["fiscal_mother"] + _fiscal_company_forbid_fiscal_type = ["group", "fiscal_mother"] journal_id = fields.Many2one(check_company=False) diff --git a/fiscal_company_account/models/account_move_line.py b/fiscal_company_account/models/account_move_line.py index ff3cfe5..b9154ae 100644 --- a/fiscal_company_account/models/account_move_line.py +++ b/fiscal_company_account/models/account_move_line.py @@ -13,7 +13,7 @@ class AccountMoveLine(models.Model): "fiscal.company.check.company.mixin", ] - _fiscal_company_forbid_fiscal_type = ["fiscal_mother"] + _fiscal_company_forbid_fiscal_type = ["group", "fiscal_mother"] account_id = fields.Many2one(check_company=False) diff --git a/fiscal_company_account/models/account_payment.py b/fiscal_company_account/models/account_payment.py index 67636e4..140329e 100644 --- a/fiscal_company_account/models/account_payment.py +++ b/fiscal_company_account/models/account_payment.py @@ -7,7 +7,13 @@ class AccountPayment(models.Model): - _inherit = "account.payment" + _name = "account.payment" + _inherit = [ + "account.payment", + "fiscal.company.check.company.mixin", + ] + + _fiscal_company_forbid_fiscal_type = ["group"] destination_account_id = fields.Many2one(check_company=False) diff --git a/fiscal_company_account/models/account_tax.py b/fiscal_company_account/models/account_tax.py index 1885f17..42775f7 100644 --- a/fiscal_company_account/models/account_tax.py +++ b/fiscal_company_account/models/account_tax.py @@ -15,4 +15,4 @@ class AccountTax(models.Model): "fiscal.company.check.company.mixin", ] - _fiscal_company_forbid_fiscal_type = ["fiscal_child"] + _fiscal_company_forbid_fiscal_type = ["group", "fiscal_child"] diff --git a/fiscal_company_point_of_sale/models/pos_config.py b/fiscal_company_point_of_sale/models/pos_config.py index 4589bd1..6412852 100644 --- a/fiscal_company_point_of_sale/models/pos_config.py +++ b/fiscal_company_point_of_sale/models/pos_config.py @@ -7,7 +7,13 @@ class PosConfig(models.Model): - _inherit = "pos.config" + _name = "pos.config" + _inherit = [ + "pos.config", + "fiscal.company.check.company.mixin", + ] + + _fiscal_company_forbid_fiscal_type = ["group", "fiscal_mother"] # Overwrite company constrains @api.constrains("company_id", "invoice_journal_id") diff --git a/fiscal_company_sale/models/sale_order.py b/fiscal_company_sale/models/sale_order.py index 6e05057..9a1f034 100644 --- a/fiscal_company_sale/models/sale_order.py +++ b/fiscal_company_sale/models/sale_order.py @@ -9,4 +9,4 @@ class SaleOrder(models.Model): _name = "sale.order" _inherit = ["sale.order", "fiscal.company.check.company.mixin"] - _fiscal_company_forbid_fiscal_type = ["fiscal_mother"] + _fiscal_company_forbid_fiscal_type = ["group", "fiscal_mother"]