Skip to Content
Menu
This question has been flagged
2 Replies
9215 Views

i have tried below code for onchange function but return some unreadable code

class sales_targets(models.Model):
    _name = 'sale.target'

    category = fields.Selection([
        ('normal', 'Product'), ('cloud', 'Cloud EYE'), ('tech', 'Technical Support Group'), ('db', 'Database'),
        ('odoo', 'Odoo'), ('can', 'CAN'), ('tod', 'TOD'), ('rental', 'Rental'), ('tec', 'TEC'), ('top', 'TOP'),
        ('tor', 'TOR'), ('tos', 'TOS'),
        ('aws', 'AWS')], 'Category', default='normal',
        help="A category of the view type is a virtual category that can be used as the parent of another category to create a hierarchical structure.")
    team_ids=fields.Many2many('crm.team','team_target_rel','target_ids','team_id','Sales Team')
    from_date=fields.Date('Budget From Date')
    to_date = fields.Date('Budget To Date')
    no_call=fields.Float('No of Calls')
    target_line=fields.One2many('target.line','target_id','Target Line', copy=True)




    @api.multi
    @api.onchange('team_ids')
    def _onchange_tem_salesperson(self):
        print ".....",self.id,self._origin

above code onchange function result is

...... <odoo.models.NewId object at 0x7f72aff2b290> sale.target()
Avatar
Discard
Best Answer

Hello!


@api.onchange
def _onchange_tem_salesperson(self):
      present_record_id=self._ids

      print present_record_id
     

Avatar
Discard

Does not work. Still outputs <odoo.models.NewId object at 0x7f72aff2b290>

Best Answer

Hello KLN,

AFAI you can't use a x_2many fields in onchange you canr refer to this issue for more info : https://github.com/odoo/odoo/issues/2693

Avatar
Discard
Related Posts Replies Views Activity
1
Jul 21
19922
1
Mar 20
3286
0
Aug 22
890
1
Jul 22
17698
0
Apr 22
1602