lundi 9 octobre 2017

How to add condition for particular class to show field drop -down except partner_id from res.partner form

I want to access res.partner form in my module. But i want that instead of customer(partner_id) it 'pet_name' in drop-down for only particular class. I applied a function and it's work. But, it work for complete res.partner. But i don't want this. So, any one can provide solution or condition for this problem?

My Code is Here:

class customer_information(models.Model):

_inherit = "res.partner"

@api.multi

def name_get(self):

    result = []

    for record in self:

        name = '['

        if record.pet_name:

            name += record.pet_name + ']' + ' ' + record.name

        else:

            name += '] ' + record.name

        result.append((record.id, name))

    return result

pet_name = fields.Char("Pet Name")

dog_cat = fields.Selection([('dog', 'Dog'), ('cat', 'Cat')], string="Dog/Cat")

species = fields.Many2one('species.pet', string="Species")

pet_size = fields.Selection([('large', 'Large'), ('medium', 'Medium'), ('small', 'Small')], string="Size")

class machine_weight(models.Model):

_name = 'machine.weight'

machine_id = fields.Many2one('sale.pet', string='Machine Weight', ondelete='cascade', index=True,

                             copy=False)

pet = fields.Many2one('res.partner')

weight = fields.Integer()

price = fields.Integer()

Aucun commentaire:

Enregistrer un commentaire