Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to filter by date in a wizard in odoo 8

By
Abayomi Olatidoye
on 10/2/16, 8:13 PM 172 views

I created a wizard to print a payslip report in a specific way i designed. The payslip report works quite well. 

However, I couldn't get it to filter by the specific date selected. It prints every information .

My wizard code is below


class ReportWizard(osv.osv_memory):

     _name = 'bluspiral.sche.schedule'

    # _inherit = 'account.invoice'

     _description = 'Cash Payroll Schedule'

     _columns = {

         'date_from': fields.date('Date From', required=True),

         'date_to': fields.date('Date To', required=True),

     }

     _defaults = {

         'date_from': lambda *a: time.strftime('%Y-%m-01'),

         'date_to': lambda *a: str(datetime.now() + relativedelta.relativedelta(months=+1, day=1, days=-1))[:10],

     }

         def print_payroll_schedule_report(self, cr, uid, ids, context=None):

             datas = {}

             if context is None:

                 context = {}

             data = self.read(cr, uid, ids,['date_from', 'date_to'], context=context)

            date_from = data[0]['date_from']

            date_to = data[0]['date_to']

            obj = self.pool['hr.payslip']

            ids = obj.search(cr, uid, [('date_from','>=',date_from),('date_from','<=',date_to)])

    datas = {

            'ids': ids,

            'model': 'bluspiral.sche.schedule.template',

            'form': data[0]

     }

    return self.pool['report'].get_action( cr, uid, [], 'bluspiral_sche.cash_report', data=datas, context=context )


Any ideas??

     

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/2/16, 8:13 PM
Seen: 172 times
Last updated: 10/3/16, 12:27 AM