diff --git a/pms/models/account_bank_statement.py b/pms/models/account_bank_statement.py index b61e33384..0232c9267 100644 --- a/pms/models/account_bank_statement.py +++ b/pms/models/account_bank_statement.py @@ -1,19 +1,30 @@ -from odoo import fields, models +from odoo import api, fields, models class AccountBankStatement(models.Model): _inherit = "account.bank.statement" + _check_pms_properties_auto = True pms_property_id = fields.Many2one( string="Property", help="Properties with access to the element", - copy=False, comodel_name="pms.property", + readonly=False, + compute="_compute_pms_property_id", + store=True, + copy=False, + check_pms_properties=True, ) - company_id = fields.Many2one( - string="Company", - help="The company for Account Bank Statement", - ) + company_id = fields.Many2one(check_pms_properties=True) + journal_id = fields.Many2one(check_pms_properties=True) + + @api.depends("journal_id") + def _compute_pms_property_id(self): + for record in self: + if len(record.journal_id.pms_property_ids) == 1: + record.pms_property_id = record.journal_id.pms_property_ids[0] + else: + record.pms_property_id = False def button_post(self): """ diff --git a/pms/views/account_bank_statement_views.xml b/pms/views/account_bank_statement_views.xml index 331a331db..8b0f18ca4 100644 --- a/pms/views/account_bank_statement_views.xml +++ b/pms/views/account_bank_statement_views.xml @@ -4,9 +4,16 @@ account.bank.statement + + + + + + +