Skip to content

Commit

Permalink
[IMP]pms: bank_statements property compute
Browse files Browse the repository at this point in the history
  • Loading branch information
DarioLodeiros committed Feb 18, 2022
1 parent a9326a5 commit d8aad95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
23 changes: 17 additions & 6 deletions pms/models/account_bank_statement.py
Original file line number Diff line number Diff line change
@@ -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):
"""
Expand Down
7 changes: 7 additions & 0 deletions pms/views/account_bank_statement_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit d8aad95

Please sign in to comment.