So, I am having the code to update my field task_name from similar excel field.
But Things are not going to happen.. Please give a loot at the vode below
excel_file= fields.Char('/home/mazhar/Desktop/Odoo project activity list.xlsx',size = 250),
sheet_name =fields.Char('Activities Sheet'),
db_name = fields.Char('spectec'),
def action_list(self,cr,uid,ids,context=None):
#wbk = xlwt.Workbook()
#sheet1 = wbk.add_sheet('my sheet')
#file_data=StringIO.StringIO()
#o=wbk.save(file_data)
#out=base64.encodestring(file_data.getvalue())
#return out
for data2 in self.browse(cr, uid, ids, context=context):
file_path = data2.excel_file
sheet_name_1 = data2.sheet_name
db_name_1 = data2.db_name
# connection for DB
conn_string = "dbname='"+ db_name_1+"' user='admin' password='admin' host='localhost'"
conn = psycopg2.connect(conn_string)
cursor = conn.cursor()
# read the excel file
wb_c = openpyxl.reader.excel.load_workbook(file_path)
s_c = wb_c.get_sheet_by_name(name=sheet_name_1)
d_c = s_c.calculate_dimension()
r_c = s_c.range(d_c)
for row in r_c:
task_name_from_excel =row[0].value
statement = "select task_name from activity_track where LOWER(name)=LOWER('"+task_name_from_excel+"')"
cursor.execute(statement)
conn.commit()
task_name = cursor.fetchone()
Pleae need your sincere guidance
Thanks
Thanks..But action_list is my button name which will be clicked and update the field
method name : action_list is ok... and button is ok.. no prob with it.. read the rest of comments ;)
You mean I should use something like this cr.execute("SELECT anyvalues FROM anytable WHERE id =%s",ids) result= map(lambda x: x[0], cr.fetchall())
Also please answer my other question for excel also plzz.. In Odoo forum..About showing table on front end Thanks
jup.. you got the point of cr.execute... other question.. please provide link to it so i don't need to search..
Here is the Link https://www.odoo.com/forum/help-1/question/buttton-click-event-73086 I have an excel file and that file has some values. I have a condition like if I select some check box then 2nd value from database will be shown only on button click and then save as excel will take place (one more button will be there in wizard view I am getting). So, what you suggest.. I should upload excel file fom some control in odoo ? Or I shoupd put all values from excel to some table?