odoo pandas

CrossPython / 2023-07-28 / 原文

        fieldstr = '''id,debit,credit,balance'''
        self.env.cr.execute('''select %s from account_move_line
                        order by id desc''' % fieldstr)
        try:
            a = self.env.cr.fetchall()

        except:
            pass

        df = pd.DataFrame(a, columns=fieldstr.split(','))
        df.to_excel(r'D:\odoo\odoo16\attachments\1.xlsx', index=False)