From bfb06b43ae737c25b700527ea84132c0ca1e126a Mon Sep 17 00:00:00 2001 From: Andhitia Rama Date: Fri, 15 Mar 2024 10:06:17 +0700 Subject: [PATCH] [UPD] ssi_service --- ssi_service/models/service_contract.py | 28 ++++++++++++++++---- ssi_service/views/service_contract_views.xml | 10 ++++++- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ssi_service/models/service_contract.py b/ssi_service/models/service_contract.py index 51887c7..3b707e9 100644 --- a/ssi_service/models/service_contract.py +++ b/ssi_service/models/service_contract.py @@ -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( @@ -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() @@ -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 diff --git a/ssi_service/views/service_contract_views.xml b/ssi_service/views/service_contract_views.xml index 756b4a4..524a62c 100644 --- a/ssi_service/views/service_contract_views.xml +++ b/ssi_service/views/service_contract_views.xml @@ -300,7 +300,15 @@ name="fix_item_receivable_account_id" string="Receivable Account" /> - + +