Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
15532 Visualizzazioni

Hello all,

 

If I change the CSS code in this file : /home/odoo/addons/point_of_sale/static/src/css/pos.css

I automatically see my changes on the POS.

 

But if I make this changes in my custom module css : /home/odoo/addons/report_lapagept/static/src/css/pos_as.css

impossible to override the original CSS. I never see the changes. Only if they are in the original pos.css.

 

I have tried 2 ways to import my pos_as.css file in my custom module :

  • I put it in my __openerp__.py            

'css': [
        'static/src/css/pos_as.css',
    ],

  • I also tried with a xml file (like usually), but I'm not sure of my declaration

        <template id="assets_pos_as" name="Assets POS - AS" inherit_id="web.assets_backend">
            <xpath expr="." position="inside">
                <link rel="stylesheet" href="/report_lapagept/static/src/css/pos_as.css"/>
            </xpath>
        </template>

 

So, what is the best way TO OVERRIDE the original CSS in the point of sale of Odoo v8?

Thanks all

Avatar
Abbandona
Autore Risposta migliore

Did not find better (shorter) way until today.

In /home/odoo-test/odoo-test/addons/pos_lapagept/__openerp__.py :

{
 
    'depends' : ['point_of_sale',],
    "data" : [
                'lapagept_templates.xml',
              ],
}
 

In /home/odoo-test/odoo-test/addons/pos_lapagept/lapagept_templates.xml :

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

<openerp>
    <data>
<template id="index_as" name="POS Index - AS">&lt;!DOCTYPE html&gt;
<html>
    <head>
        <title>Odoo POS - AS</title>

        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <meta http-equiv="content-type" content="text/html, charset=utf-8" />

        <meta name="viewport" content=" width=1024, user-scalable=no"/>
        <meta name="apple-mobile-web-app-capable" content="yes"/>
        <meta name="mobile-web-app-capable" content="yes"/>

        <link rel="shortcut icon"    sizes="196x196" href="/point_of_sale/static/src/img/touch-icon-196.png"/>
        <link rel="shortcut icon"    sizes="128x128" href="/point_of_sale/static/src/img/touch-icon-128.png"/>
        <link rel="apple-touch-icon"                 href="/point_of_sale/static/src/img/touch-icon-iphone.png"/>
        <link rel="apple-touch-icon" sizes="76x76"   href="/point_of_sale/static/src/img/touch-icon-ipad.png"/>
        <link rel="apple-touch-icon" sizes="120x120" href="/point_of_sale/static/src/img/touch-icon-iphone-retina.png"/>
        <link rel="apple-touch-icon" sizes="152x152" href="/point_of_sale/static/src/img/touch-icon-ipad-retina.png"/>

        <link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/>
        <link rel="stylesheet" href="/point_of_sale/static/src/fonts/lato/stylesheet.css" />
        <link rel="stylesheet" href="/point_of_sale/static/src/fonts/font-awesome-4.0.3/css/font-awesome.min.css" />
        <link rel="stylesheet" href="/point_of_sale/static/src/css/pos.css" id="pos-stylesheet"/>
        <link rel="stylesheet" href="/pos_lapagept/static/src/css/pos_as.css"/>
        <link rel="stylesheet" href="/point_of_sale/static/src/css/keyboard.css" />

        <t t-call-assets="web.assets_common" t-css="false" />
        <t t-call-assets="web.assets_backend" t-css="false" />

        <script type="text/javascript" id="loading-script">
            $(function() {
            var s = new openerp.init(<t t-raw='modules' />);
                <t t-raw='init' />
            });
        </script>

    </head>
    <body>
        <div class='openerp openerp_webclient_container'>
            <table class='oe_webclient'>
                <tr>
                    <td class='oe_application' />
                </tr>
            </table>
        </div>
    </body>
</html>
</template>
<template id="index_pt" name="POS Index - PT">&lt;!DOCTYPE html&gt;
<html>
    <head>
        <title>Odoo POS - PT</title>

        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <meta http-equiv="content-type" content="text/html, charset=utf-8" />

        <meta name="viewport" content=" width=1024, user-scalable=no"/>
        <meta name="apple-mobile-web-app-capable" content="yes"/>
        <meta name="mobile-web-app-capable" content="yes"/>

        <link rel="shortcut icon"    sizes="196x196" href="/point_of_sale/static/src/img/touch-icon-196.png"/>
        <link rel="shortcut icon"    sizes="128x128" href="/point_of_sale/static/src/img/touch-icon-128.png"/>
        <link rel="apple-touch-icon"                 href="/point_of_sale/static/src/img/touch-icon-iphone.png"/>
        <link rel="apple-touch-icon" sizes="76x76"   href="/point_of_sale/static/src/img/touch-icon-ipad.png"/>
        <link rel="apple-touch-icon" sizes="120x120" href="/point_of_sale/static/src/img/touch-icon-iphone-retina.png"/>
        <link rel="apple-touch-icon" sizes="152x152" href="/point_of_sale/static/src/img/touch-icon-ipad-retina.png"/>

        <link rel="shortcut icon" href="/web/static/src/img/favicon.ico" type="image/x-icon"/>
        <link rel="stylesheet" href="/point_of_sale/static/src/fonts/lato/stylesheet.css" />
        <link rel="stylesheet" href="/point_of_sale/static/src/fonts/font-awesome-4.0.3/css/font-awesome.min.css" />
        <link rel="stylesheet" href="/point_of_sale/static/src/css/pos.css" id="pos-stylesheet"/>
        <link rel="stylesheet" href="/pos_lapagept/static/src/css/pos_pt.css"/>
        <link rel="stylesheet" href="/point_of_sale/static/src/css/keyboard.css" />

        <t t-call-assets="web.assets_common" t-css="false" />
        <t t-call-assets="web.assets_backend" t-css="false" />

        <script type="text/javascript" id="loading-script">
            $(function() {
            var s = new openerp.init(<t t-raw='modules' />);
                <t t-raw='init' />
            });
        </script>

    </head>
    <body>
        <div class='openerp openerp_webclient_container'>
            <table class='oe_webclient'>
                <tr>
                    <td class='oe_application' />
                </tr>
            </table>
        </div>
    </body>
</html>
</template>


    </data>
</openerp>

All the CSS in the file /home/odoo-test/odoo-test/addons/pos_lapagept/static/src/css/pos_as.css will override the CSS in the original pos.css file. It works very well.

But now, somebody here could say to me why it's written « Odoo » rather than « Odoo POS - AS » when I inspect the code. See below image. ??????

 

 

Avatar
Abbandona
Risposta migliore

You need to update the path of css file in three places.


1.`inherit_id="web.assets_backend"`

2.`inherit_id="web.assets_frontend"`

3.`inherit_id="point_of_sale.assets"`


In the templates which inherites the above templates.

The code is shown below.



    <template id="assets_backend" name="sub_menu assets" inherit_id="web.assets_backend">

            <xpath expr="." position="inside">

                <link rel="stylesheet" href="/pos_update/static/src/css/mypos.css"/>

            </xpath>

        </template>


        <template id="assets_frontend" name="sub_menu assets front" inherit_id="web.assets_frontend">

            <xpath expr="." position="inside">

                <link rel="stylesheet" href="/pos_update/static/src/css/mypos.css"/>

            </xpath>

        </template>


    <data>

        <template id="assets" inherit_id="point_of_sale.assets">

            <xpath expr="." position="inside">

                <link rel="stylesheet" href="/pos_update/static/src/css/mypos.css"/>

                <script type="text/javascript" src="/pos_update/static/src/js/cancel.js"></script>


            </xpath>

        </template>

    </data>



You also need to ensure that if you want to modify an existing template then the stylesheet name must not be changed. 


If you want to create a stylesheet for your template the you only need to set the path of stylesheet in only one place, ie in the main template file in which you are setting the path of js file.


    <template id="assets" inherit_id="point_of_sale.assets">

                <xpath expr="." position="inside">

                    <link rel="stylesheet" href="/pos_update/static/src/css/mypos.css"/>

                    <script type="text/javascript" src="/pos_update/static/src/js/cancel.js"></script>

    

                </xpath>

            </template>



Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
mag 23
2685
0
set 24
1469
1
ago 24
9653
0
set 23
1391
0
mar 23
7535