Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
1793 Lượt xem

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!

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello someone,

You can use below example.

Please find code in comment.

I hope this helps.

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

Ảnh đại diện
Huỷ bỏ

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 9 19
3527
7
thg 3 25
7601
3
thg 5 24
4316
3
thg 11 24
44520
1
thg 4 23
4484