Skip to content

Commit

Permalink
[IMP] account_reconcile_model: added company based domains on One2man…
Browse files Browse the repository at this point in the history
…y and Many2many properties

From now on, users will not be able to select journals, accounts or taxes pertaining to a company
other than the one the reconciliation model is set up for.

Up until now, when in superuser mode, and in a multi company environment, users could reference
taxes, journals and accounts from all the companies. This allowed for misconfiguration ending
in errors when using the reconciliation widget.

Ticket #2375446

closes #62636

X-original-commit: a3ce6c2
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Julien CHEVREAU <Julien-CHEVREAU@users.noreply.github.com>
  • Loading branch information
Julien-CHEVREAU committed Nov 30, 2020
1 parent 2b3de65 commit 1d00daf
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions addons/account/models/account_reconcile_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AccountReconcileModel(models.Model):

# ===== Conditions =====
match_journal_ids = fields.Many2many('account.journal', string='Journals',
domain="[('type', 'in', ('bank', 'cash'))]",
domain="[('type', 'in', ('bank', 'cash')), ('company_id', '=', company_id)]",
help='The reconciliation model will only be available from the selected journals.')
match_nature = fields.Selection(selection=[
('amount_received', 'Amount Received'),
Expand Down Expand Up @@ -90,8 +90,8 @@ class AccountReconcileModel(models.Model):

# ===== Write-Off =====
# First part fields.
account_id = fields.Many2one('account.account', string='Account', ondelete='cascade', domain=[('deprecated', '=', False)])
journal_id = fields.Many2one('account.journal', string='Journal', ondelete='cascade', help="This field is ignored in a bank statement reconciliation.")
account_id = fields.Many2one('account.account', string='Account', ondelete='cascade', domain="[('deprecated', '=', False), ('company_id', '=', company_id)]")
journal_id = fields.Many2one('account.journal', string='Journal', ondelete='cascade', help="This field is ignored in a bank statement reconciliation.", domain="[('company_id', '=', company_id)]")
label = fields.Char(string='Journal Item Label')
amount_type = fields.Selection([
('fixed', 'Fixed'),
Expand All @@ -106,13 +106,12 @@ class AccountReconcileModel(models.Model):
decimal_separator = fields.Char(default=lambda self: self.env['res.lang']._lang_get(self.env.user.lang).decimal_point, help="Every character that is nor a digit nor this separator will be removed from the matching string")
tax_ids = fields.Many2many('account.tax', string='Taxes', ondelete='restrict')
analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account', ondelete='set null')
analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic Tags',
analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Analytic Tags', domain="[('company_id', '=', company_id)]",
relation='account_reconcile_model_analytic_tag_rel')

# Second part fields.
has_second_line = fields.Boolean(string='Add a second line', default=False)
second_account_id = fields.Many2one('account.account', string='Second Account', ondelete='cascade', domain=[('deprecated', '=', False)])
second_journal_id = fields.Many2one('account.journal', string='Second Journal', ondelete='cascade', help="This field is ignored in a bank statement reconciliation.")
second_account_id = fields.Many2one('account.account', string='Second Account', ondelete='cascade', domain="[('deprecated', '=', False), ('company_id', '=', company_id)]")
second_journal_id = fields.Many2one('account.journal', string='Second Journal', ondelete='cascade', help="This field is ignored in a bank statement reconciliation.", domain="[('company_id', '=', company_id)]")
second_label = fields.Char(string='Second Journal Item Label')
second_amount_type = fields.Selection([
('fixed', 'Fixed'),
Expand All @@ -126,7 +125,7 @@ class AccountReconcileModel(models.Model):
second_amount_from_label_regex = fields.Char(string="Second Amount from Label (regex)", default=r"([\d\.,]+)")
second_tax_ids = fields.Many2many('account.tax', relation='account_reconcile_model_account_tax_bis_rel', string='Second Taxes', ondelete='restrict')
second_analytic_account_id = fields.Many2one('account.analytic.account', string='Second Analytic Account', ondelete='set null')
second_analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Second Analytic Tags',
second_analytic_tag_ids = fields.Many2many('account.analytic.tag', string='Second Analytic Tags', domain="[('company_id', '=', company_id)]",
relation='account_reconcile_model_second_analytic_tag_rel')

number_entries = fields.Integer(string='Number of entries related to this model', compute='_compute_number_entries')
Expand Down

0 comments on commit 1d00daf

Please sign in to comment.