示例#1
0
	def setConditionalDefaults(self, field, value):
		ir = RpcProxy('ir.values')
		values = ir.get('default', '%s=%s' % (field, value),
						[(self.group.resource, False)], False, {})
		data = {}
		for index, fname, value in values:
			data[fname] = value
		self.setDefaults(data)
示例#2
0
 def setConditionalDefaults(self, field, value):
     """
     This functions is called whenever a field with 'change_default'
     attribute set to True is modified. The function sets all conditional
     defaults to each field.
     Conditional defaults is a mechanism by which the user can establish
     default values on fields, depending on the value of another field (
     the 'change_default' field). An example of this case is the zip field
     in the partner model.
     :param field:
     :param value:
     :return:
     """
     ir = RpcProxy('ir.values')
     values = ir.get('default', '%s=%s' % (field, value),
                     [(self.group.resource, False)], False, {})
     data = {}
     for index, fname, value in values:
         data[fname] = value
     self.setDefaults(data)