This question has been flagged

Hello All,

i have 3 districts and some areas related to these district. Now, i want that when i select area than related district default show in next field, no need to fill district. for this my code is below:

Python Code:

class district_code_form(models.Model):
    _name = 'district.districe.code'
    _rec_name = 'district_value'

    district_value = fields.Char('District Value')
    district_region = fields.One2many('district.district', 'district_id', string="District Workflow")

class district_form(models.Model):
    _name = 'district.district'
    _rec_name = 'district'

    district_id = fields.Many2one('district.district.code', string='Districts Id', ondelete='cascade', index=True, copy=False)
    district = fields.Char("District")
    district_code = fields.Char('District Code')

Now i want to access this configuration table for this my code is here:

class customer_information(models.Model):
    _inherit = "res.partner"
   
    @api.onchange('district_table_case', 'district_table')
    def _onchange_district_table(self):
        print "A:", self.district_table_case.district_region
        print "B:", self.district_table_case.district_value
        rec = self.district_table_case.district_region
        res = self.district_table_case.district_value
        print "res:", res
        if res:
            return {'domain': {'district_table_case': [('id', 'in', res)]}}
        else:
            return {'domain': {'district_table_case': []}}
       
    district_table = fields.Many2one('district.district')
    district_table_case = fields.Many2one('district.districe.code', change_default=True,
                                          default=_onchange_district_table)

i am getting all ids on terminal screen but not getting upto the mark

Thanks in advance.

Avatar
Discard