Skip to content

Commit

Permalink
[ADD] website_sale_fixed_name_height: add module
Browse files Browse the repository at this point in the history
  • Loading branch information
dessanhemrayev committed Feb 8, 2024
1 parent 1a3734b commit 6b816da
Show file tree
Hide file tree
Showing 19 changed files with 709 additions and 0 deletions.
6 changes: 6 additions & 0 deletions setup/website_sale_fixed_name_height/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
94 changes: 94 additions & 0 deletions website_sale_fixed_name_height/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
=============================
Product Description On N Rows
=============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:207c3d1b4316c75e927936781f86daf43328b77c4b5910c71224b9d6ac1bdfd0
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fe--commerce-lightgray.png?logo=github
:target: https://github.com/OCA/e-commerce/tree/14.0/website_sale_fixed_name_height
:alt: OCA/e-commerce
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/e-commerce-14-0/e-commerce-14-0-website_sale_fixed_name_height
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/e-commerce&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module lets the user set for each website how many lines of description to display in /shop page,
and if the name of the product does not fit the lines set, then the name is shortened with suspension dots.

**Table of contents**

.. contents::
:local:

Use Cases / Context
===================

In /shop page, if on a grid line you have some products with a name that fits in one line and other products with a name longer than one line, this is breaking alignment of "add to cart" buttons


Configuration
=============

User goes to setting > website and sets for website 1 "Number of product description lines to display" = 1

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/e-commerce/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_fixed_name_height%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Ooops
* Cetmix

Contributors
~~~~~~~~~~~~

* `Cetmix <https://cetmix.com>`__:

* Ivan Sokolov
* George Smirnov
* Dessan Hemrayev


Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/e-commerce <https://github.com/OCA/e-commerce/tree/14.0/website_sale_fixed_name_height>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions website_sale_fixed_name_height/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
16 changes: 16 additions & 0 deletions website_sale_fixed_name_height/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2024 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Product Description On N Rows",
"version": "14.0.1.0.0",
"category": "Website",
"author": "Ooops, Cetmix, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/e-commerce",
"license": "AGPL-3",
"summary": """This module lets user set for each website how many lines
of description to display in /shop page""",
"depends": ["website_sale"],
"data": ["views/website_sale_template.xml", "views/res_config_settings_view.xml"],
"installable": True,
}
3 changes: 3 additions & 0 deletions website_sale_fixed_name_height/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import res_company
from . import res_config_settings
from . import product_template
11 changes: 11 additions & 0 deletions website_sale_fixed_name_height/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (C) 2024 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import models


class ProductTemplate(models.Model):
_inherit = "product.template"

def get_row_count(self):
return self.env.company.row_count
21 changes: 21 additions & 0 deletions website_sale_fixed_name_height/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2024 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo.exceptions import ValidationError


class ResCompany(models.Model):
_inherit = "res.company"

@api.constrains("row_count")
def _check_row_count(self):
for record in self:
if record.row_count < 1:
raise ValidationError(_("Row count must be greater than 0"))

row_count = fields.Integer(
string="Row count in description",
default=1,
help="Number of rows to display in description",
)
14 changes: 14 additions & 0 deletions website_sale_fixed_name_height/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (C) 2024 Cetmix OÜ
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

row_count = fields.Integer(
related="company_id.row_count",
help="Number of rows to display in description",
readonly=False,
)
1 change: 1 addition & 0 deletions website_sale_fixed_name_height/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
User goes to setting > website and sets for website 1 "Number of product description lines to display" = 1
2 changes: 2 additions & 0 deletions website_sale_fixed_name_height/readme/CONTEXT.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In /shop page, if on a grid line you have some products with a name that fits in one line and other products with a name longer than one line, this is breaking alignment of "add to cart" buttons

6 changes: 6 additions & 0 deletions website_sale_fixed_name_height/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* `Cetmix <https://cetmix.com>`__:

* Ivan Sokolov
* George Smirnov
* Dessan Hemrayev

2 changes: 2 additions & 0 deletions website_sale_fixed_name_height/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This module lets the user set for each website how many lines of description to display in /shop page,
and if the name of the product does not fit the lines set, then the name is shortened with suspension dots.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 6b816da

Please sign in to comment.