-
-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by pedrobaeza
- Loading branch information
Showing
36 changed files
with
2,136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
=========================== | ||
Website Sale Secondary Unit | ||
=========================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:b22305a090cabad4fd64b941824c90c602eec985747acf0fc3039558a4b22968 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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/17.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-17-0/e-commerce-17-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/builds?repo=OCA/e-commerce&target_branch=17.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module extends the functionality of saleorder_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 to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/e-commerce/issues/new?body=module:%20website_sale_secondary_unit%0Aversion:%2017.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 | ||
- Carlos Lopez | ||
|
||
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/17.0/website_sale_secondary_unit>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "17.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/**/*.esm.js", | ||
"/website_sale_secondary_unit/static/src/scss/website_sale_secondary_unit.scss", | ||
], | ||
"web.assets_tests": [ | ||
"/website_sale_secondary_unit/static/tests/tours/website_sale_secondary_unit_tour.esm.js" | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# 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 | ||
|
||
def _get_cart_notification_information(self, order, line_ids): | ||
res = super()._get_cart_notification_information(order, line_ids) | ||
for line in res.get("lines", []): | ||
sale_line = request.env["sale.order.line"].browse(line["id"]) | ||
line["secondary_uom_name"] = "" | ||
line["secondary_uom_qty"] = sale_line.secondary_uom_qty | ||
secondary_uom = sale_line.secondary_uom_id | ||
if not secondary_uom: | ||
continue | ||
factor = ( | ||
int(secondary_uom.factor) == secondary_uom.factor | ||
and int(secondary_uom.factor) | ||
or secondary_uom.factor | ||
) | ||
uom_name = secondary_uom.product_tmpl_id.sudo().uom_id.name | ||
secondary_uom_name = f"{secondary_uom.name} {factor}" | ||
if uom_name != secondary_uom.name: | ||
secondary_uom_name += f" {uom_name}" | ||
line["secondary_uom_name"] = secondary_uom_name | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(env): | ||
""" | ||
At installation time, set allow_uom_sell field as true for all products | ||
that have already been created. | ||
""" | ||
env.cr.execute( | ||
""" | ||
UPDATE product_template | ||
SET allow_uom_sell=true | ||
WHERE allow_uom_sell IS NULL; | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Oops, something went wrong.