Browse Source

Fix domains in smart button

Show selections when partner type is undefined
Apply domain when selecting a type_selection
pull/103/head
Sandy Carter 10 years ago
parent
commit
99dfd76fc4
  1. 12
      partner_relations/model/res_partner_relation_all.py
  2. 2
      partner_relations/view/res_partner_relation_all.xml

12
partner_relations/model/res_partner_relation_all.py

@ -161,6 +161,18 @@ class ResPartnerRelationAll(models.AbstractModel):
for this in self for this in self
} }
@api.onchange('type_selection_id')
def onchange_type_selection_id(self):
"""Add domain on other_partner_id according to category_other"""
if not self.type_selection_id.partner_category_other:
return {'domain': []}
is_company = self.type_selection_id.partner_category_other == 'c'
return {
'domain': {
'other_partner_id': [('is_company', '=', is_company)],
}
}
@api.one @api.one
def write(self, vals): def write(self, vals):
"""divert non-problematic writes to underlying table""" """divert non-problematic writes to underlying table"""

2
partner_relations/view/res_partner_relation_all.xml

@ -18,6 +18,8 @@
name="type_selection_id" name="type_selection_id"
required="True" required="True"
domain="[ domain="[
'|',
('contact_type_this', '=', False),
('contact_type_this', '=', contact_type), ('contact_type_this', '=', contact_type),
]" ]"
options="{'create': false, 'create_edit': false}" options="{'create': false, 'create_edit': false}"

Loading…
Cancel
Save