zoukankan      html  css  js  c++  java
  • JavaScript ,Css and Jquery In OpenERP 7.0

    From: http://openerpbay.blogspot.jp/2013/02/javascript-css-and-jquery-in-openerp-70.html

    Hi fellows,

                   Here i'm showing how can you use  JavaScript ,Css and Jquery In OpenERP 7.0.There is one cool feature added in openERP 7.0 in which you can use HTML tags inside openERP form view. This feature is not available in older version (Web 6.0 , 6.1). OpenERP already use HTML codes like <div> <H1> inside form view. But you can do much more than that you can use css and JavaScript inside form view code (OpenERP XML Code). Even more you can use JQuery also In Form View but JQuery is only work if you have old OpenERP 7 Web.In next few weeks i will show you how jquery also used in latest OpenERP 7.0 Web Code. 

                         Now, let's see how use this thing in form view. It is very if you have little knowledge of CSS and JavaScript. You can apply css as like you apply css in HTML code but only different is here you apply css in openerp form code. 

    CSS

        In HTML we use css(inline) like this- Same like you can apply in OpenERP-

    <p style="color:sienna;font-size:8pt;"></p> 
    <field name="product_id" style="color:sienna;font-size:8pt;"/>

    (This will apply css on that field but only if it in readonly form or it is in saved state.)

    JavaScript
    For JavaScript you can define script anyplace in code whare you can use HTML Tags.

    <record id="product_normal_form_view" model="ir.ui.view">
           <field name="name">product.normal.form</field>
           <field name="model">product.product</field>
           <field name="arch" type="xml">
                   <form string="Product" version="7.0">
                          <sheet>
                            <script>
                                        alert("Hi I'm JavaScript :P "); 
                            </script>
                           <field name="image_medium" widget="image" class="oe_avatar oe_left"/>
                           <div class="oe_title">
                           <div class="oe_edit_only">
                                    <label for="name" string="Product Name"/>
                           </div>
                           <h1>
                                      <field name="name"/>
                           </h1>
                           ............
                           ............

    JQuery
    For JQuery you need to apply your JQuery code inside script tag same as JavaScript. But this is not working in latest code.
    <record id="product_normal_form_view" model="ir.ui.view">
           <field name="name">product.normal.form</field>
           <field name="model">product.product</field>
           <field name="arch" type="xml">
                   <form string="Product" version="7.0">
                          <sheet>
                            <script>
                                        $(document).ready(function(){
                                        $(".oe_edit_only").click(function(){
                                                $(this).hide();
                                         });
                                  }); 
                            </script>
                           <field name="image_medium" widget="image" class="oe_avatar oe_left"/>
                           <div class="oe_title">
                           <div class="oe_edit_only">
                                    <label for="name" string="Product Name"/>
                           </div>
                           <h1>
                                      <field name="name"/>
                           </h1>
                           ............
                           ............

    Have a good day.
    Save Paper, Save Trees.

  • 相关阅读:
    记一次 .NET 某智能服装智造系统 内存泄漏分析
    记一次 .NET 某化妆品 webapi 卡死分析
    记一次 .NET 某公交卡扣费系统 程序卡死分析
    去掉烦人的:要恢复页面吗?Chrome未正确关闭
    C#Excel转图片代码
    ArcEngine实现pagelayout中文本元素的属性对话框
    arcgis 模型版本问题最大
    Arcengine开发所遇错误解决方案(持续更新)
    ArcEngine IPageLayout 添加经纬网和公里网
    Arcengine的复制粘贴
  • 原文地址:https://www.cnblogs.com/chjbbs/p/3910206.html
Copyright © 2011-2022 走看看