Skip to content

Commit

Permalink
Merge PR #69 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by andhit-r
  • Loading branch information
ssi-bot committed Mar 15, 2024
2 parents 261db76 + bfb06b4 commit 9694efa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
28 changes: 23 additions & 5 deletions ssi_service/models/service_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ class ServiceContract(models.Model):
"dom_cancel",
]

allowed_partner_bank_ids = fields.Many2many(
string="Allowed Partner Banks",
comodel_name="res.partner.bank",
compute="_compute_allowed_partner_bank_ids",
)
partner_bank_id = fields.Many2one(
string="Recipient Bank",
comodel_name="res.partner.bank",
domain="[('partner_id', '=', partner_id)]",
required=False,
)
analytic_account_id = fields.Many2one(
Expand Down Expand Up @@ -103,6 +107,24 @@ class ServiceContract(models.Model):
},
)

@api.depends(
"company_id",
)
def _compute_allowed_partner_bank_ids(self):
BankAccount = self.env["res.partner.bank"]
for record in self:
result = []
if record.company_id:
criteria = [("partner_id", "=", record.company_id.partner_id.id)]
result = BankAccount.search(criteria).ids
record.allowed_partner_bank_ids = result

@api.onchange(
"company_id",
)
def onchange_partner_bank_id(self):
self.partner_bank_id = False

@api.model
def _get_policy_field(self):
res = super(ServiceContract, self)._get_policy_field()
Expand Down Expand Up @@ -190,7 +212,3 @@ def onchange_analytic_group_id(self):
self.analytic_group_id = False
if self.type_id:
self.analytic_group_id = self.type_id.analytic_group_id

@api.onchange("partner_id")
def onchange_partner_bank_id(self):
self.partner_bank_id = False
10 changes: 9 additions & 1 deletion ssi_service/views/service_contract_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,15 @@
name="fix_item_receivable_account_id"
string="Receivable Account"
/>
<field name="partner_bank_id" />
<field
name="allowed_partner_bank_ids"
widget="many2many_tags"
invisible="1"
/>
<field
name="partner_bank_id"
domain="[('id','in',allowed_partner_bank_ids)]"
/>
</group>
</page>
<page name="analytic" string="Analytic &amp; Project">
Expand Down

0 comments on commit 9694efa

Please sign in to comment.