Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] website_sale_secondary_unit #993

Draft
wants to merge 46 commits into
base: 16.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b40bde5
[11.0][ADD] website_sale_secondary_unit: New module
sergio-teruel Mar 4, 2019
0e3167d
[11.0][FIX] website_sale_secondary_unit: Crash if product_uom not com…
sergio-teruel Apr 16, 2019
db405b4
[11.0][FIX] website_sale_secondary_unit: Fix tour tests
sergio-teruel Apr 18, 2019
764e77f
[11.0][IMP] website_sale_secondary_unit: Display product uom after pr…
sergio-teruel Jun 14, 2019
01e96a0
[MIG] website_sale_secondary_unit: Migration to v12.0
sergio-teruel Oct 24, 2019
e27efcc
[FIX] website_sale_secondary_unit: Fix quantity position in cart lines
sergio-teruel May 4, 2020
924834a
[IMP] website_sale_secondary_unit: Set default secondary uom for prod…
sergio-teruel Jul 21, 2020
eb31c98
Added translation using Weblate (German)
AndreVolksdorf Aug 11, 2020
c582507
[IMP] website_sale_secondary_unit: black, isort, prettier
CarlosRoca13 Feb 17, 2021
7610669
[MIG] website_sale_secondary_unit: Migration to v13.0
CarlosRoca13 Feb 17, 2021
984c631
[FIX] website_sale_secondary_unit: Adjust to upstream changes
pedrobaeza Apr 5, 2021
97491ae
[FIX] website_sale_secondary_unit: Remove sudo access to avoid to dis…
sergio-teruel Jul 15, 2021
0db4b3b
FIX: script for delete view before update
celm1990 Sep 10, 2021
c2791bf
[FIX] website_sale_secondary_unit: Fixed price computation
CarlosRoca13 May 14, 2021
ef6b2bd
[IMP] website_sale_secondary_unit: black, isort, prettier
CarlosRoca13 May 26, 2022
be3102f
[MIG] website_sale_secondary_unit: Migration to 15.0
CarlosRoca13 May 27, 2022
a3657fc
[UPD] Update website_sale_secondary_unit.pot
Oct 1, 2022
a1b242a
[UPD] README.rst
OCA-git-bot Oct 1, 2022
46263f3
[UPD] Update website_sale_secondary_unit.pot
Dec 16, 2022
ae46970
Update translation files
weblate Dec 16, 2022
61390b1
[IMP] website_sale_secondary_unit: mobile UX
chienandalu Dec 20, 2022
748a702
Translated using Weblate (Italian)
francesco-ooops Apr 7, 2023
125792b
website_sale_secondary_unit 15.0.1.1.0
OCA-git-bot Apr 23, 2023
eab14b5
Translated using Weblate (Italian)
francesco-ooops Jun 6, 2023
4b2aca4
Translated using Weblate (Spanish)
Ivorra78 Jul 5, 2023
059fbbd
Translated using Weblate (Italian)
mymage Jul 18, 2023
c34f4af
Translated using Weblate (Italian)
mymage Jul 21, 2023
953a804
[UPD] Update website_sale_secondary_unit.pot
Aug 11, 2023
1d50f78
Update translation files
weblate Aug 11, 2023
7258a8a
[UPD] README.rst
OCA-git-bot Sep 3, 2023
7e73631
[FIX] website_sale_secondary_unit: t-esc directives are deprecated
pilarvargas-tecnativa Sep 13, 2023
cca0aad
[IMP] website_sale_secondary_unit: Hide/show uom name in secondary qu…
pilarvargas-tecnativa Sep 13, 2023
5cc7bcc
[UPD] Update website_sale_secondary_unit.pot
Sep 14, 2023
1927f25
[UPD] README.rst
OCA-git-bot Sep 14, 2023
9858838
website_sale_secondary_unit 15.0.1.2.0
OCA-git-bot Sep 14, 2023
02dc8b7
[UPD] README.rst
OCA-git-bot Sep 14, 2023
59e1156
Update translation files
weblate Sep 20, 2023
6fe9090
Translated using Weblate (Italian)
mymage Sep 22, 2023
ef6f42b
Translated using Weblate (Spanish)
Ivorra78 Oct 4, 2023
f78c87f
[IMP] website_sale_b2x_alt_price: test performance improvement
josep-tecnativa Oct 18, 2023
cd9bc1e
[IMP] website_sale_secondary_unit: test performance improvement
josep-tecnativa Oct 18, 2023
6066f08
[BOT] post-merge updates
OCA-git-bot Oct 23, 2023
e7a40e2
Translated using Weblate (Italian)
mymage Oct 29, 2023
44d6958
Translated using Weblate (Italian)
mymage Oct 31, 2023
99fc1f1
[IMP] website_sale_secondary_uni: pre-commit stuff
santostelmo Dec 9, 2024
8a0cf88
WIP FIX behavior
StephaneMangin Jan 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setup/website_sale_secondary_unit/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,
)
98 changes: 98 additions & 0 deletions website_sale_secondary_unit/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
===========================
Website Sale Secondary Unit
===========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/16.0/website_sale_secondary_unit
: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-16-0/e-commerce-16-0-website_sale_secondary_unit
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/webui/builds.html?repo=OCA/e-commerce&target_branch=16.0
:alt: Try me on Runboat

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

This module extends the functionality of sale_order_secondary_unit module to
allow sell products in online store in secondary units defined.

**Table of contents**

.. contents::
:local:

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

For define the secondary units, you should active *Manage multiples units of measure* on
the user that will be responsable of this function.

Usage
=====

To use this module you need to:

* Go to *'Website > Products > Products'*.
* Select a template.
* Set the secondary units that you need.
* Go to Website Shop and buy this product, you will see a selectable option
with all secondary units defined in the product and visible in website.
* If you do not want to sell in a base product unit and only allow sell in a
secondary unit you can disable the option *'Allow to sell in unit of
measure'* in a product sale tab.

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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_secondary_unit%0Aversion:%2016.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
~~~~~~~

* Tecnativa

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

* `Tecnativa <https://www.tecnativa.com>`_:

* Sergio Teruel
* Carlos Roca
* Pilar Vargas

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/16.0/website_sale_secondary_unit>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions website_sale_secondary_unit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import controllers
from . import models
from .hooks import post_init_hook
33 changes: 33 additions & 0 deletions website_sale_secondary_unit/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2019 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Website Sale Secondary Unit",
"summary": "Allow manage secondary units in website shop",
"version": "16.0.1.0.0",
"development_status": "Beta",
"category": "Website",
"website": "https://github.com/OCA/e-commerce",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": ["website_sale", "sale_order_secondary_unit"],
"data": [
"security/ir.model.access.csv",
"security/website_sale_secondary_unit.xml",
"views/product_secondary_unit_views.xml",
"views/product_template_views.xml",
"views/templates.xml",
],
"demo": ["data/demo.xml"],
"post_init_hook": "post_init_hook",
"assets": {
"web.assets_frontend": [
"/website_sale_secondary_unit/static/src/js/website_sale_secondary_unit.js",
"/website_sale_secondary_unit/static/src/scss/website_sale_secondary_unit.scss",
],
"web.assets_tests": [
"/website_sale_secondary_unit/static/src/js/website_sale_secondary_unit_tour.js"
],
},
}
2 changes: 2 additions & 0 deletions website_sale_secondary_unit/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import main
48 changes: 48 additions & 0 deletions website_sale_secondary_unit/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2019 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from odoo import http
from odoo.http import request

from odoo.addons.website_sale.controllers.main import WebsiteSale


class WebsiteSaleSecondaryUnit(WebsiteSale):
@http.route()
def cart_update(self, product_id, add_qty=1, set_qty=0, **kw):
# Add secondary uom info to session
request.session.pop("secondary_uom_id", None)
if kw.get("secondary_uom_id"):
secondary_uom = request.env["product.secondary.unit"].browse(
int(kw["secondary_uom_id"])
)
request.session["secondary_uom_id"] = secondary_uom.id
return super().cart_update(product_id, add_qty=add_qty, set_qty=set_qty, **kw)

@http.route()
def cart_update_json(
self, product_id, line_id=None, add_qty=None, set_qty=None, display=True, **kw
):
so_line = request.env["sale.order.line"].browse(line_id)
request.session.pop("secondary_uom_id", None)
if kw.get("secondary_uom_id"):
secondary_uom = request.env["product.secondary.unit"].browse(
int(kw["secondary_uom_id"])
)
request.session["secondary_uom_id"] = secondary_uom.id
if so_line.sudo().secondary_uom_id:
request.session["secondary_uom_id"] = so_line.sudo().secondary_uom_id.id
return super().cart_update_json(
product_id,
line_id=line_id,
add_qty=add_qty,
set_qty=set_qty,
display=display,
**kw,
)

def _prepare_product_values(self, product, category, search, **kwargs):
res = super()._prepare_product_values(product, category, search, **kwargs)
res["secondary_uom_ids"] = product.secondary_uom_ids.filtered(
lambda su: su.active and su.is_published
)
return res
31 changes: 31 additions & 0 deletions website_sale_secondary_unit/data/demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="0">
<record id="secondary_unit_box_5" model="product.secondary.unit">
<field name="name">Box</field>
<field name="uom_id" ref="uom.product_uom_unit" />
<field name="factor">5.0</field>
<field
name="product_tmpl_id"
ref="product.product_product_11_product_template"
/>
<field name="website_published">True</field>
</record>
<record id="secondary_unit_box_10" model="product.secondary.unit">
<field name="name">Box</field>
<field name="uom_id" ref="uom.product_uom_unit" />
<field name="factor">10.0</field>
<field
name="product_tmpl_id"
ref="product.product_product_11_product_template"
/>
<field name="website_published">True</field>
</record>
<record id="product.product_product_11" model="product.product">
<field
name="secondary_uom_ids"
eval="[(6, 0, [ref('website_sale_secondary_unit.secondary_unit_box_5'),
ref('website_sale_secondary_unit.secondary_unit_box_10')]),]"
/>
<field name="allow_uom_sell" eval="True" />
</record>
</odoo>
16 changes: 16 additions & 0 deletions website_sale_secondary_unit/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


def post_init_hook(cr, registry):
"""
At installation time, set allow_uom_sell field as true for all products
that have already been created.
"""
cr.execute(
"""
UPDATE product_template
SET allow_uom_sell=true
WHERE allow_uom_sell IS NULL;
"""
)
102 changes: 102 additions & 0 deletions website_sale_secondary_unit/i18n/ca.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * website_sale_secondary_unit
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-01-20 20:44+0000\n"
"Last-Translator: claudiagn <claudia.gargallo@qubiq.es>\n"
"Language-Team: none\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: website_sale_secondary_unit
#: model_terms:ir.ui.view,arch_db:website_sale_secondary_unit.cart_lines
#: model_terms:ir.ui.view,arch_db:website_sale_secondary_unit.secondary_qty
msgid "Add one"
msgstr "Afegir un"

#. module: website_sale_secondary_unit
#: model:ir.model.fields,field_description:website_sale_secondary_unit.field_product_product__allow_uom_sell
#: model:ir.model.fields,field_description:website_sale_secondary_unit.field_product_template__allow_uom_sell
msgid "Allow to sell in unit of measure"
msgstr "Permetre vendre en una unitat de mesura"

#. module: website_sale_secondary_unit
#: model:product.secondary.unit,name:website_sale_secondary_unit.secondary_unit_box_10
#: model:product.secondary.unit,name:website_sale_secondary_unit.secondary_unit_box_5
msgid "Box"
msgstr ""

#. module: website_sale_secondary_unit
#: model:ir.model.fields,field_description:website_sale_secondary_unit.field_product_secondary_unit__can_publish
msgid "Can Publish"
msgstr ""

#. module: website_sale_secondary_unit
#: model:ir.model.fields,field_description:website_sale_secondary_unit.field_product_secondary_unit__is_published
msgid "Is Published"
msgstr ""

#. module: website_sale_secondary_unit
#: model:ir.model,name:website_sale_secondary_unit.model_product_secondary_unit
msgid "Product Secondary Unit"
msgstr "Unitat secundària de producte"

#. module: website_sale_secondary_unit
#: model:ir.model,name:website_sale_secondary_unit.model_product_template
msgid "Product Template"
msgstr "Plantilla de producte"

#. module: website_sale_secondary_unit
#: model_terms:ir.ui.view,arch_db:website_sale_secondary_unit.cart_popover
msgid "Qty:"
msgstr "Quantitat:"

#. module: website_sale_secondary_unit
#: model_terms:ir.ui.view,arch_db:website_sale_secondary_unit.cart_lines
msgid "Quantity"
msgstr "Quantitat"

#. module: website_sale_secondary_unit
#: model_terms:ir.ui.view,arch_db:website_sale_secondary_unit.cart_lines
#: model_terms:ir.ui.view,arch_db:website_sale_secondary_unit.secondary_qty
msgid "Remove one"
msgstr "Elimina un"

#. module: website_sale_secondary_unit
#: model:ir.model,name:website_sale_secondary_unit.model_sale_order
msgid "Sales Order"
msgstr ""

#. module: website_sale_secondary_unit
#: model:ir.model,name:website_sale_secondary_unit.model_sale_order_line
msgid "Sales Order Line"
msgstr "Línia de comanda de venda"

#. module: website_sale_secondary_unit
#: model:ir.model.fields,help:website_sale_secondary_unit.field_product_secondary_unit__website_url
msgid "The full URL to access the document through the website."
msgstr ""

#. module: website_sale_secondary_unit
#: model:ir.model.fields,field_description:website_sale_secondary_unit.field_product_secondary_unit__website_published
msgid "Visible on current website"
msgstr ""

#. module: website_sale_secondary_unit
#: model:ir.model.fields,field_description:website_sale_secondary_unit.field_product_secondary_unit__website_url
msgid "Website URL"
msgstr ""

#~ msgid "Is published"
#~ msgstr "Està publicat"

#~ msgid "Sale Order"
#~ msgstr "Comanda de venda"
Loading
Loading