Skip to Content
Menu
This question has been flagged
4 Replies
2181 Views
# appointment count section
def visitor_appointment(self):
return {
'name': _('Appointment'),
'domain': [('v_name', '=', self.id)],
'view_type': 'form',
'res_model': 'visitor.data',
'view_id': False,
'view_mode': 'tree,form',
'type': 'ir.actions.act_window',
}

def get_appoint_count(self):
count = self.env['visitor.data'].search_count([('v_name', '=', self.id)])
self.appoint_count = count

appoint_count = fields.Integer(string='Appointment', computed='get_appoint_count')

here counted value not show
Avatar
Discard

print the variable count and see what the search count is returned? Might be count is 0 as there is no matching records ? Add a print and see

Author

not working now what can i do, kindly help me

Are you trying to compare string and integer type?

Best Answer

Dear Arjun,

def get_appoint_count(self):
count = self.env['visitor.data'].search_count([('v_name', '=', self.id)])
self.appoint_count = count

check this domain condition ('v_name', '=', self.id), is it based on a name or id.
   


Avatar
Discard
Author

def get_appoint_count(self):

count = self.env['visitor.data'].search_count([('v_name', '=', self.id)])

self.appoint_count = count

I tried this but not working

there is a problem with this domain

count = self.env['visitor.data'].search_count([('v_name', '=', self.id)])

ex 1:

count = self.env['visitor.data'].search_count([('v_name', '=', 'arjun')])

or

count = self.env['visitor.data'].search_count([('id', '=', self.id)])

Author

can i give the code?

Author

here is my field

I_AM = fields.Selection([('visitor', 'Visitor'), ('guest', 'Guest'), ('labour', 'Labour')], required=True)

v_name = fields.Char(string="Name", required=True, track_visibility="always")

v_company = fields.Char(string="Company", required=True, track_visibility="always")

Related Posts Replies Views Activity
1
Apr 24
920
1
Aug 22
1687
0
May 17
6331
1
Mar 15
3096
2
Mar 15
3382