Browse Source

[IMP] the font size of the displayed product name depends on the length of the product name

pull/538/head
Sylvain LE GAL 4 years ago
parent
commit
8d9b9f8ff2
  1. 1
      pos_default_empty_image/__manifest__.py
  2. 1
      pos_default_empty_image/models/__init__.py
  3. 16
      pos_default_empty_image/models/pos_config.py
  4. 7
      pos_default_empty_image/readme/CONFIGURATION.rst
  5. BIN
      pos_default_empty_image/static/description/pos_config_form.png
  6. 1
      pos_default_empty_image/static/src/css/pos_default_empty_image.css
  7. 15
      pos_default_empty_image/static/src/xml/pos_default_empty_image.xml
  8. 33
      pos_default_empty_image/views/pos_config.xml

1
pos_default_empty_image/__manifest__.py

@ -13,6 +13,7 @@
], ],
'data': [ 'data': [
'views/templates.xml', 'views/templates.xml',
'views/pos_config.xml',
], ],
'qweb': [ 'qweb': [
'static/src/xml/pos_default_empty_image.xml', 'static/src/xml/pos_default_empty_image.xml',

1
pos_default_empty_image/models/__init__.py

@ -1 +1,2 @@
from . import pos_config
from . import product_product from . import product_product

16
pos_default_empty_image/models/pos_config.py

@ -0,0 +1,16 @@
# Copyright (C) 2020 - Today:
# GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import models, fields
class PosConfig(models.Model):
_inherit = 'pos.config'
iface_fixed_font_size = fields.Integer(
string="Fixed Font Size",
help="Font size of the product name, when it has no image."
" Set '0' will set adaptative font-size, depending on the"
" length of the name.")

7
pos_default_empty_image/readme/CONFIGURATION.rst

@ -0,0 +1,7 @@
* Go to your PoS Configuration
.. figure:: ../static/description/pos_config_form.png
* Select the font size used to display product name, when there is no image.
* If not set, the font size will depend on the name length.

BIN
pos_default_empty_image/static/description/pos_config_form.png

After

Width: 839  |  Height: 222  |  Size: 20 KiB

1
pos_default_empty_image/static/src/css/pos_default_empty_image.css

@ -14,7 +14,6 @@
top:25px !important; top:25px !important;
padding-top:3px !important; padding-top:3px !important;
height:80px !important; height:80px !important;
font-size: 24px !important;
line-height: 20px; line-height: 20px;
text-align: center; text-align: center;
word-wrap: break-word; word-wrap: break-word;

15
pos_default_empty_image/static/src/xml/pos_default_empty_image.xml

@ -2,6 +2,19 @@
<templates id="template" xml:space="preserve"> <templates id="template" xml:space="preserve">
<t t-name="ProductNoImage"> <t t-name="ProductNoImage">
<article class='product' t-att-data-product-id="product.id" tabindex="0" t-attf-aria-labelledby="article_product_#{product.id}"> <article class='product' t-att-data-product-id="product.id" tabindex="0" t-attf-aria-labelledby="article_product_#{product.id}">
<t t-set="name_length" t-value="product.display_name.length" />
<t t-if='widget.pos.config.iface_fixed_font_size'>
<t t-set="font_size" t-value="widget.pos.config.iface_fixed_font_size" />
</t>
<t t-else="">
<t t-set="font_size" t-value="
name_length >=120 and 11
or name_length >=90 and 12
or name_length >=60 and 13
or name_length>=50 and 14
or name_length>=40 and 16
or 20"/>
</t>
<div class="product-img-without-image"> <div class="product-img-without-image">
<t t-if="!product.to_weight"> <t t-if="!product.to_weight">
<span class="price-tag"> <span class="price-tag">
@ -14,7 +27,7 @@
</span> </span>
</t> </t>
</div> </div>
<div class="product-name-without-image" t-attf-id="article_product_#{product.id}">
<div class="product-name-without-image" t-attf-id="article_product_#{product.id}" t-attf-style="font-size: #{font_size}px !important; line-height: #{font_size}px !important;">
<t t-esc="product.display_name"/> <t t-esc="product.display_name"/>
</div> </div>
</article> </article>

33
pos_default_empty_image/views/pos_config.xml

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2020 Creu Blanca
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.ui.view" id="pos_config_view_form">
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='iface_big_scrollbars']/../.." position="after">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_right_pane">
<label for="iface_fixed_font_size" string="Fixed Font Size"/>
<div class="text-muted">
Font size of the product name, when it has no image. Set '0' will set adaptative font-size, depending on the length of the name.
</div>
<div class="content-group mt16">
<field name="iface_fixed_font_size"/>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save