Skip to Content
Menu
This question has been flagged
1 Reply
21811 Views

I get typeError when a try to print my costum report via wizard. below the code :

************In report python file**************

class ReportIncomeByDoctor(models.AbstractModel):

_name = 'report.pragtech_dental_management.income_by_insurance'

def get_income_insurance_company(self,start_date, end_date, insurance_company):
invoice_obj = self.env['account.invoice']
inv_dom = ([('date_invoice', '>=', start_date),
('date_invoice', '<=', end_date),('state','in',['open']), ('insurance_company','==',insurance_company)])
tids = invoice_obj.search(inv_dom)
res = invoice_obj.browse(tids)
return res

@api.model
def render_html(self, docids, data=None):
self.model = self.env.context.get('active_model')
act_ids = self.env.context.get('active_ids', [])
docs = self.env[self.model].browse(act_ids)
start_date = data.get('start_date', fields.Date.today())
end_date = data['form'].get('end_date', str(datetime.now() +
relativedelta(months=+1,
day=1, days=-1))[:10])
insurance_company = data['form'].get('insurance_company')
inv_act = self.with_context(data['form'].get('used_context', {}))
get_income_insurance_company = inv_act.get_income_insurance_company(start_date, end_date, insurance_company)
docargs = {
'doc_ids': docids,
'doc_model': self.model,
'data': data['form'],
'docs': docs,
'time': time,
'get_income_insurance_company': get_income_insurance_company,
}
docargs['data'].update({'end_date':
parser.parse(docargs.get('data').
get('end_date')).
strftime('%m/%d/%Y')})
docargs['data'].update({'start_date':
parser.parse(docargs.get('data').
get('start_date')).
strftime('%m/%d/%Y')})
return self.env['report'].render('pragtech_dental_management.income_by_insurance', docargs)

************In wizard python file************
class IncomeByInsuranceCompanyWizard(models.TransientModel):
_name = 'income.by.insurance.company.wizard'

_description ='Income By Procedure Wizard'
date_start = fields.Date('From Date',required = True)
date_end = fields.Date('To Date',required = True)
insurance_company=fields.Many2one('res.partner', 'Insurance Company', required = True)


@api.multi
def print_report(self):
data = {
'ids': self.ids,
'model': 'account.invoice',
'form': self.read(['date_start', 'date_end', 'insurance_company'])[0]
}

value = self.env['report'].get_action(self, 'pragtech_dental_management.income_by_insurance', data)
return value

Thanks for your help

Avatar
Discard
Best Answer

The error says that you try to use a list as dictionary key, you'll have to change your list into tuples if you want to put them as keys in your dictionary. TypeError: unhashable type: 'list' usually means that you are trying to use a list as an hash argument.The only types of values not acceptable as keys are values containing lists or dictionaries or other mutable types that are compared by value rather than by object identity, the reason being that the efficient implementation of dictionaries requires a key’s hash value to remain constant. 

http://net-informations.com/python/iq/unhashable.htm


Avatar
Discard
Related Posts Replies Views Activity
2
Jul 24
566
2
Apr 24
848
4
Oct 20
4204
1
Mar 15
4265
1
Apr 24
30422