跳至內容
選單
此問題已被標幟
2 回覆
2379 瀏覽次數

Hi,  I want to display customers according to the selected branch. Some customers have empty branches, and some have branches. if it's empty it means it can be used in all branches

so what is displayed is the customer's name according to the selected branch but at the same time you can also search for customers with empty branches


I've tried this but it only displays the name of the customer based on the selected branch, and can't search customers name with an empty branch 


domain= {'domain': {'partner_id': ['|',('branch_id', '=', self.branch_id.id)]}}


And if like this, i can search customer with empty branch, but the name that appears when the branch is selected becomes random again and what appears is not the name of the customer with the selected branch 


domain= {'domain': {'partner_id': ['|',('branch_id', '=', self.branch_id.id),('branch_id', '=', False) ]}}


how can i display customer names based on the selected branch, while at the same time being able to search for customer names with empty branches?

is there any suggestion to solve this problem?


Thanks!

頭像
捨棄
最佳答案

Returning a domain using onchange method has been deprecated in Odoo 14.

I'm using this OCA module to filter field depend on another field.

Web Domain Field | The Odoo Community Organisation | OCA (odoo-community.org)

頭像
捨棄
最佳答案

Hello someone,

You can use below example.

Please find code in comment.

I hope this helps.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

頭像
捨棄

class ResPartner(models.Model):
_inherit = "res.partner"

branch_id = fields.Many2one('branch.branch', "Branch")

class SaleOrderInherit(models.Model):
_inherit = "sale.order"

partner_id = fields.Many2one('res.partner', "Partner")
branch_id = fields.Many2one('branch.branch', "Branch")

@api.onchange('branch_id')
def _get_partner_domain(self):
for rec in self:
return {
'domain': {'partner_id': [('branch_id', '=', rec.branch_id.id)]},
}

Returning a domain using onchange method has been deprecated in Odoo 14.

相關帖文 回覆 瀏覽次數 活動
1
9月 19
4447
7
3月 25
10985
3
5月 24
5447
3
11月 24
45495
1
4月 23
5228