Skip to Content
Menu
This question has been flagged
8138 Views

Wizard_report.py

from openerp import models, api, fields

class purchase_report_order(models.TransientModel):

        _name="purchase.report.data"

        sup_name = fields.Many2many("res.partner", string="Supplier")

        sta_status = fields.Selection([('draft','Draft Po'),

                                                            ('sent','RFQ'),

                                                             ('bid','Bid Received'),

                                                            ('confirmed','Waiting Approval'),

                                                             ('approved','Purchase Confirmed'),

                                                              ('except-picking','Shipping Exception'),

                                                               ('except-invoice','Invoice Exception'),

                                                               ('done','Done'), ('cancel','Cancelled')],

                                                            'Status', select=True)

        date_to = fields.Datetime(string="ToDate")

        date_from = fields.Datetime(string="FromDate")


        @api.multi def show_record_in_report(self):

        sup = self.sup_name

         print " Welcome..",sup

         if not self.date_from and not self.date_to and not self.sta_status:

            for a in self.sup_name:

                po_obj = self.env['purchase.order'].search([('partner_id','=',a.id)]) for purchase_order in po_obj:

                    print "Supplier Name 1111111111111---: ",purchase_order.partner_id.name

        elif not self.date_from and not self.date_to and not self.sup_name:

            po_obj = self.env['purchase.order'].search([('state','=',self.sta_status)]) for purchase_order in po_obj:

                print "Supplier Name: 22222222222------",purchase_order.partner_id.name  

                print "Status:",purchase_order.state

        elif not self.sta_status and not self.sup_name:

            po_obj = self.env['purchase.order'].search([('date_order','>=',self.date_from),('date_order','<=',self.date_to)])

         for purchase_order in po_obj:

                print "Supplier Names: 33333333333333-----------", purchase_order.partner_id.name

         elif not self.sup_name:

            po_obj = self.env['purchase.order'].search([('date_order','>=',self.date_from),('date_order','<=',self.date_to),('state','=',self.sta_status)]) for purchase_order in po_obj:

                print "Supplier Name: 44444444444-----------",purchase_order.partner_id.name

         elif not self.sta_status:

            for a in self.sup_name:

                po_obj = self.env['purchase.order'].search([('date_order','>=',self.date_from),('date_order','<=',self.date_to),('partner_id','=',a.id)]) for purchase_order in po_obj:

                    print "Supplier Name:55555555555--------",purchase_order.partner_id.name

         elif not self.date_from and not self.date_to:

            po_obj = self.env['purchase.order'].search([('partner_id','=',self.sup_name.id),('state','=',self.sta_status)])

         for purchase_order in po_obj:

                print "Supplier Name:66666666666--------",purchase_order.partner_id.name else:

            for a in self.sup_name:

                po_obj = self.env['purchase.order'].search([('date_order','>=',self.date_from),('date_order','<=',self.date_to),('partner_id','=',a.id),('state','=',self.sta_status)])

         for purchase_order in po_obj:

                    print "Supplier Name:777777777",purchase_order.partner_id.name


data = {

'ids': po_obj,

'model': 'purchase.order',

'form': self.env['purchase.order'].read(['self.sup_name'])

}

return self.env['report'].get_action(self, 'purchase_report.report_purchase_summary_ids', data=data)





Purchase_Report_file.xml

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<template id="report_purchase_summary_ids">

<t t-call="report.html_container">

<t t-call="report.internal_layout">

<div class="page">

<div class="oe_structure"/>

<h2>Purchase summary Report</h2>

                <h3>Analytic Account Reference</h3>

                <table class="table table-condensed">

                <thead>

                 <tr>

             <th>Supplier Name</th>

             <th class="text-center">Refernce</th>

             <th class="text-right">OrderDate</th>

             <th class="text-right">ExpectedDate</th>

             <th class="text-right">Untaxed</th>

             <th class="text-right">Total</th>

             <th class="text-right">Status</th>

         </tr>

         </thead>

         <!-- <tbody>

         <tr t-foreach="ref_lines(data['form'])" t-as="line">

         <td>

            <span t-esc="line['ref_name']"/>

        </td>

         <td class="text-center">

        <span t-esc="line['ref_name']"/>

        </td>

         <td class="text-right">

         <p t-if="line['ref_order']">

         <span t-esc="formatLang(line['ref_order'])"/>

         </p>

         </td>

         <td class="text-right">

         <p t-if="line['ref_amt']">

         <span t-esc="formatLang(line['ref_amt'], currency_obj = res_company.currency_id)"/>

         </p>

         </td>

         <td class="text-right">100.00%</td>

         </tr>

         </tbody> -->

         </table>

     <div class="oe_structure"/>

     </div> </t> </t></template></data></openerp>



Purchase_Report.xml

<openerp>

<data>

<report

         id = "action_report_emps_ids"

         model = "purchase.report.data"

         report_type = "qweb-pdf"

         file = "purchase_report.report_purchase_summary_ids"

         name = "purchase_report.report_purchase_summary_ids" />

</data>

</openerp>





Wizard_report.xml

<openerp>

<data noupdate="0">

     <record id="purchase_reporting_wizard_data_id" model="ir.ui.view">

     <field name="name">purchase.reporting.wizard</field>

     <field name="model">purchase.report.data</field>

     <field name="arch" type="xml">

     <form string="Purchase Summary Report">

         <group colspan="4" col="4">

             <field name="date_from"/>

                 <field name="sup_name" widget="many2many_tags" domain="[('supplier','=',True)]"/>

                 <field name="date_to"/> <field name="sta_status" widget="selection"/>

         </group>

         <footer>

         <button string="Print" name="show_record_in_report" type="object" class="oe_highlight"/>

         <button string="Cancel" special="cancel" class="oe_link"/>

        </footer>

     </form>

     </field>

     </record>


     <record id="action_purchase_report_wizard_view_data" model="ir.actions.act_window">

     <field name="name">Purchase Summary Report</field>

     <field name="res_model">purchase.report.data</field>

     <field name="view_type">form</field>

     <field name="view_mode">form</field>

     <field name="target">new</field>

</record>

</data>

</openerp>

Avatar
Discard