-
-
Notifications
You must be signed in to change notification settings - Fork 482
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
29 changed files
with
1,333 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 |
---|---|---|
@@ -1 +1,3 @@ | ||
website | ||
product-attribute | ||
sale-workflow |
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,87 @@ | ||
=========================== | ||
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/12.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-12-0/e-commerce-12-0-website_sale_secondary_unit | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png | ||
:target: https://runbot.odoo-community.org/runbot/113/12.0 | ||
:alt: Try me on Runbot | ||
|
||
|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: | ||
|
||
Usage | ||
===== | ||
|
||
To use this module you need to: | ||
|
||
* Go to *'Sales > Catalog > Products'*. | ||
* Create secondary units for a product. | ||
* 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:%2012.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 | ||
~~~~~~~~~~~~ | ||
|
||
* Sergio Teruel <sergio.teruel@tecnativa.com> | ||
|
||
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/12.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,26 @@ | ||
# 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': '12.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/website_sale_secondary_unit.xml', | ||
'views/assets.xml', | ||
'views/product_template_views.xml', | ||
'views/product_secondary_unit_views.xml', | ||
'views/templates.xml', | ||
], | ||
'post_init_hook': '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,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,31 @@ | ||
# Copyright 2019 Tecnativa - Sergio Teruel | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo.addons.website_sale.controllers.main import WebsiteSale | ||
from odoo import http | ||
from odoo.http import request | ||
|
||
|
||
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 'secondary_uom_id' in kw: | ||
secondary_uom = request.env['product.secondary.unit'].browse( | ||
int(kw['secondary_uom_id'])) | ||
request.session['secondary_uom_id'] = secondary_uom.id | ||
return super(WebsiteSaleSecondaryUnit, self).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): | ||
so_line = request.env['sale.order.line'].browse(line_id) | ||
request.session.pop('secondary_uom_id', None) | ||
if so_line.sudo().secondary_uom_id: | ||
request.session['secondary_uom_id'] = \ | ||
so_line.sudo().secondary_uom_id.id | ||
return super(WebsiteSaleSecondaryUnit, self).cart_update_json( | ||
product_id, line_id=line_id, add_qty=add_qty, set_qty=set_qty, | ||
display=display) |
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,26 @@ | ||
<?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="product.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="product.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,14 @@ | ||
# 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; | ||
""") |
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,66 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * website_sale_secondary_unit | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-03-13 16:54+0000\n" | ||
"PO-Revision-Date: 2019-03-13 17:56+0100\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"Language: es\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
"X-Generator: Poedit 2.0.6\n" | ||
|
||
#. 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 "Permitir vender en la unidad de medida" | ||
|
||
#. 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,name:website_sale_secondary_unit.model_product_template | ||
msgid "Product Template" | ||
msgstr "Plantilla de producto" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.ui.view,arch_db:website_sale_secondary_unit.cart_popover | ||
msgid "Qty:" | ||
msgstr "Ctdad." | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.ui.view,arch_db:website_sale_secondary_unit.cart_lines | ||
#: model:ir.ui.view,arch_db:website_sale_secondary_unit.payment | ||
msgid "Quantity" | ||
msgstr "Cantidad" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.model,name:website_sale_secondary_unit.model_sale_order | ||
msgid "Quotation" | ||
msgstr "Presupuesto" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.model,name:website_sale_secondary_unit.model_sale_order_line | ||
msgid "Sales Order Line" | ||
msgstr "Línea de pedido" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.model.fields,field_description:website_sale_secondary_unit.field_product_secondary_unit_website_published | ||
msgid "Visible in Website" | ||
msgstr "Visible en website" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.model,name:website_sale_secondary_unit.model_product_secondary_unit | ||
msgid "product.secondary.unit" | ||
msgstr "" |
63 changes: 63 additions & 0 deletions
63
website_sale_secondary_unit/i18n/website_sale_secondary_unit.pot
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,63 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * website_sale_secondary_unit | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 11.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. 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 "" | ||
|
||
#. 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,name:website_sale_secondary_unit.model_product_template | ||
msgid "Product Template" | ||
msgstr "" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.ui.view,arch_db:website_sale_secondary_unit.cart_popover | ||
msgid "Qty:" | ||
msgstr "" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.ui.view,arch_db:website_sale_secondary_unit.cart_lines | ||
#: model:ir.ui.view,arch_db:website_sale_secondary_unit.payment | ||
msgid "Quantity" | ||
msgstr "" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.model,name:website_sale_secondary_unit.model_sale_order | ||
msgid "Quotation" | ||
msgstr "" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.model,name:website_sale_secondary_unit.model_sale_order_line | ||
msgid "Sales Order Line" | ||
msgstr "" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.model.fields,field_description:website_sale_secondary_unit.field_product_secondary_unit_website_published | ||
msgid "Visible in Website" | ||
msgstr "" | ||
|
||
#. module: website_sale_secondary_unit | ||
#: model:ir.model,name:website_sale_secondary_unit.model_product_secondary_unit | ||
msgid "product.secondary.unit" | ||
msgstr "" | ||
|
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 product_template | ||
from . import product_secondary_unit | ||
from . import sale_order |
10 changes: 10 additions & 0 deletions
10
website_sale_secondary_unit/models/product_secondary_unit.py
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,10 @@ | ||
# Copyright 2019 Tecnativa - Sergio Teruel | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import models, fields | ||
|
||
|
||
class ProductSecondaryUnit(models.Model): | ||
_inherit = ['product.secondary.unit', 'website.published.mixin'] | ||
_name = 'product.secondary.unit' | ||
|
||
website_published = fields.Boolean(default=True) |
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,12 @@ | ||
# Copyright 2019 Tecnativa - Sergio Teruel | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from odoo import models, fields | ||
|
||
|
||
class ProductTemplate(models.Model): | ||
_inherit = 'product.template' | ||
|
||
allow_uom_sell = fields.Boolean( | ||
string='Allow to sell in unit of measure', | ||
default=True, | ||
) |
Oops, something went wrong.