[IMP]pms: bank_statements property compute

This commit is contained in:
Darío Lodeiros
2022-02-18 18:46:25 +01:00
parent a9326a52c9
commit d8aad956ec
2 changed files with 24 additions and 6 deletions

View File

@@ -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):
"""

View File

@@ -4,9 +4,16 @@
<field name="model">account.bank.statement</field>
<field name="inherit_id" ref="account.view_bank_statement_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='company_id']" position="after">
<field name="pms_property_id" />
</xpath>
<xpath expr="//field[@name='ref']" position="after">
<field name="pms_property_id" invisible="1" />
<field name="folio_ids" widget="many2many_tags" optional="hidden" />
</xpath>
</field>
</record>
</odoo>