本人学习odoo不久,在做报表的时候遇到一个问题,graph视图中希望可以按照“时间条件”显示对应数据
这是python文件
class keywind_product_report(osv.osv):<br /> _name = "keywind.product.report"<br /> _auto = False<br /> _description = "keywind_product"<br /># _rec_name = 'date_deadline'<br /># _inherit = ["crm.tracking.mixin"]<br /><br /> _columns = {<br /> 'product': fields.many2one('keywind.kwproduct', '物资名称', readonly=True),<br /> 'xinghao': fields.char(u'规格型号', readonly=True),<br /> 'unit': fields.many2one('keywind.unit', u'单位', readonly=True),<br /> 'jiag': fields.float('单价', digits=(16, 4), readonly=True),<br /> 'invoice': fields.char('发票号',readonly=True),<br /> 'num_inwms': fields.float('入库数量', readonly=True, digits=(8, 2)),<br /> 'num_outwms': fields.float('出库数量', readonly=True, digits=(8, 2)),<br /> 'num_last': fields.float('剩余数量', readonly=True, digits=(8, 2)),<br /> 'out_to': fields.char(u'项目名', readonly=True),<br /> <br /> 'in_date': fields.datetime('入库时间', readonly=True),<br /> 'out_date': fields.datetime('出库时间', readonly=True),<br /> 'in_date_month': fields.datetime('入库月份', readonly=True),<br /> }<br /><br /> def init(self, cr):<br /> tools.sql.drop_view_if_exists(cr, 'keywind_product_report')<br /> cr.execute("""<br /> create or replace view keywind_product_report as (<br /> select<br /> sq.id,<br /> sq.product_id as product,<br /> sq.guigxh as xinghao,<br /> sq.product_jiag as jiag,<br /> sq.qty as num_inwms,<br /> sum(ow.shul) as num_outwms,<br /> sq.qtylast as num_last,<br /> ow.project as out_to,<br /> sq.in_date as in_date,<br /> <br /> extract(month from sq.in_date) as in_date_month<br /> <br /> from stock_quant sq<br /> left join out_wms ow on (sq.id=ow.quant_id)<br /> <br /> group by sq.guigxh, ow.project,<br /> sq.product_id, sq.product_jiag, sq.qty, sq.qtylast, sq.id, <br /> sq.in_date<br /><br /> <br /> <br /> )<br /> """)
xml文件
<?xml version="1.0" encoding="utf-8"?><br /><openerp><br /> <data><br /> <br /> <menuitem id="menu_keywind_report" name="报表" parent="menu_stock" /><br /> <br /><br /> <record id="action_report_crm_lead" model="ir.actions.act_window"><br /> <field name="name">报表</field><br /> <field name="res_model">keywind.product.report</field><br /> <field name="view_type">form</field><br /> <field name="view_mode">graph</field><br /> <field name="context">{}</field><br /> <field name="domain">[]</field><br /> </record><br /> <br /> <br /> <!-- Leads by user and section Graph View --><br /> <record id="view_report_crm_lead_graph" model="ir.ui.view"><br /> <field name="name">keywind.product.report.graph</field><br /> <field name="model">keywind.product.report</field><br /> <field name="arch" type="xml"><br /> <graph string="Leads Analysis" type="pivot" stacked="True"><br /> <br /> <field name="product" type="row" /><br /> <field name="xinghao" type="row" /><br /> <field name="in_date" type="col"/><br /> <field name="out_to" type="col" /><br /> <field name="num_inwms" type="measure" /><br /> <field name="num_outwms" type="measure" /><br /> <field name="num_last" type="measure" /><br /> <field name="jiag" type="measure" /><br /> <br /> </graph><br /> </field><br /> </record><br /> <br /> <!-- Leads by user and section Search View --><br /> <record id="view_report_crm_lead_filter" model="ir.ui.view"><br /> <field name="name">keywind.product.report.select</field><br /> <field name="model">keywind.product.report</field><br /> <field name="arch" type="xml"><br /> <search string="Leads Analysis"><br /> <br /> <!--<br /> <field name="in_date" string='入库时间' /><br /> <field name="in_date_month" filter_domain="[('in_date_month','ilike',self)]"/><br /> <filter name="in_date_month" context="{'group_by':'in_date:month'}" /><br /> --><br /> <br /> <field name="in_date_month" filter_domain="[('in_date_month','ilike',self)]"/><br /> <br /> <br /> <group expand="1" string="分组"><br /> <br /> <!-- <br /> <filter string="入库时间" context="{'group_by':'in_date:month'}" /><br /> --><br /> </group><br /> </search><br /> </field><br /> </record><br /> <br /> <menuitem id="menu_act_estimate_report" action="action_report_crm_lead" name="估入报表" parent="menu_keywind_report" /><br /> <br /> <record id="action_report_crm_lead_graph" model="ir.actions.act_window.view"><br /> <field name="sequence" eval="2" /><br /> <field name="view_mode">graph</field><br /> <field name="view_id" ref="view_report_crm_lead_graph" /><br /> <field name="act_window_id" ref="action_report_crm_lead" /><br /> </record><br /> <br /> </data><br /></openerp>
希望在搜索框中输入2015/9的时候,显示的是2015年9月的入库和出库信息,而现在当我输入2015/9的时候,默认搜索的是“2015/9/1 00:00:00”
求大神指点