Below code is account_invoice inherited class . Here i will add 'arrondissement_id', 'town_id'
arrondissement_id = fields.Many2one('account.arrondissement','Arrondissement')
town_id = fields.Many2one('account.town','Commune')
Now i want if i select 'town_id' with 'RABAT' (FOR EXAMPLE) then next field 'arrondissemnet_id' i have to get only 'RABAT'
drop down list and previous selected 'arrondissement_id' values should get deleted . i have tried with domain filter option but isnt work this is my code :
class account_town(models.Model):
_name = 'account.town'
_description = "town"
name = fields.Char('Nom de la Commune', required=True)
code = fields.Char('Code de la Commune')
prefecture_id = fields.Many2one('account.prefecture','Préfecture')
# @api.onchange('name')
# def onchange_town(self):
# res = {}
# if self.name:
# res['domain'] = {'arrondissement_id': [('town_id', '=', self.town.id)]}
# return res
class account_arrondissement(models.Model):
_name = 'account.arrondissement'
_description = "arrondissement"
name = fields.Char('Nom d\'Arrondissements', required=True)
code = fields.Char('Code d\'Arrondissements')
town_id = fields.Many2one('account.town','Commune')
class AccountInvoice(models.Model):
_name = 'account.invoice'
_inherit = 'account.invoice'
is_oi_generated = fields.Boolean('OI généré ?',default=0)
prefecture_id = fields.Many2one('account.prefecture','Préfecture')
town_id = fields.Many2one('account.town','Commune')
arrondissement_id = fields.Many2one('account.arrondissement','Arrondissement')
maitre_ouvrage = fields.Char('Maitre ouvrage')
num_dossier = fields.Char('N°dossier')
type_paiement = fields.Selection([('online', 'Paiement En ligne'), ('chek2', 'chèque'), ('cash1', 'Espèce'), ('cart', 'Carte Bancaire'), ('virement', 'Virement')],string='Type de paiement')