size
int64
0
304k
ext
stringclasses
1 value
lang
stringclasses
1 value
branch
stringclasses
1 value
content
stringlengths
0
304k
avg_line_length
float64
0
238
max_line_length
int64
0
304k
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
100
py
PYTHON
15.0
import setuptools setuptools.setup( setup_requires=['setuptools-odoo'], odoo_addon=True, )
16.666667
100
457
py
PYTHON
15.0
# Copyright 2023 Quartile Limited # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Website Sales Wishlist Archive Cron", "version": "15.0.1.0.0", "author": "Quartile Limited, Odoo Community Association (OCA)", "website": "https://github.com/OCA/e-commerce", "category": "Website", "license": "AGPL-3", "depends": ["website_sale_wishlist"], "data": ["data/cron_data.xml"], "installable": True, }
35.153846
457
504
py
PYTHON
15.0
# Copyright 2023 Quartile Limited # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import api, models class ProductWishlist(models.Model): _inherit = "product.wishlist" @api.model def _process_wishlist_archive(self): wishlist_records = self.search([("active", "=", True)]) wishlist_records_to_archive = wishlist_records.filtered( lambda x: not x.product_id.active ) wishlist_records_to_archive.write({"active": False})
31.5
504
816
py
PYTHON
15.0
# Copyright 2018 Simone Rubino - Agile Business Group # Copyright 2020 Tecnativa - João Marques # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website sale order type", "summary": "This module allows sale_order_type to work with website_sale.", "version": "15.0.1.0.0", "development_status": "Beta", "category": "Website", "website": "https://github.com/OCA/e-commerce", "maintainers": ["stefan-tecnativa", "pilarvargas-tecnativa"], "author": "Agile Business Group, Odoo Community Association (OCA)", "license": "AGPL-3", "depends": ["website_sale", "sale_order_type"], "assets": { "web.assets_tests": [ "/website_sale_order_type/static/src/js/website_sale_order_type_tour.js" ] }, "auto_install": True, }
38.809524
815
2,016
py
PYTHON
15.0
# Copyright 2018 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo.tests import HttpCase class TestFrontend(HttpCase): def setUp(self): super(TestFrontend, self).setUp() self.sale_type_model = self.env["sale.order.type"] self.partner = self.env.ref("base.partner_admin") self.sale_type = self.create_sale_type() def create_sale_type(self): self.sequence = self.env["ir.sequence"].create( { "name": "Test Sales Order", "code": "sale.order", "prefix": "TSO", "padding": 3, } ) self.journal = self.env["account.journal"].search( [("type", "=", "sale")], limit=1 ) self.warehouse = self.env.ref("stock.warehouse0") self.immediate_payment = self.env.ref("account.account_payment_term_immediate") self.sale_pricelist = self.env.ref("product.list0") self.free_carrier = self.env.ref("account.incoterm_FCA") return self.sale_type_model.create( { "name": "Test Sale Order Type", "sequence_id": self.sequence.id, "journal_id": self.journal.id, "warehouse_id": self.warehouse.id, "picking_policy": "one", "payment_term_id": self.immediate_payment.id, "pricelist_id": self.sale_pricelist.id, "incoterm_id": self.free_carrier.id, } ) def test_website_sale_order_type(self): self.partner.sale_type = self.sale_type existing_orders = self.env["sale.order"].search([]) # In frontend, create an order self.start_tour("/shop", "website_sale_order_type_tour", login="admin") created_order = self.env["sale.order"].search( [("id", "not in", existing_orders.ids)] ) self.assertEqual(created_order.type_id, self.sale_type)
39.529412
2,016
938
py
PYTHON
15.0
# Copyright 2018 Simone Rubino - Agile Business Group # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import models class SaleOrder(models.Model): _inherit = "sale.order" _description = "Allowing sale_order_type to work with website_sale." def _cart_update( self, product_id=None, line_id=None, add_qty=0, set_qty=0, attributes=None, **kwargs ): self.ensure_one() res = super()._cart_update( product_id=product_id, line_id=line_id, add_qty=add_qty, set_qty=set_qty, attributes=attributes, **kwargs ) sale_type = ( self.partner_id.sale_type or self.partner_id.commercial_partner_id.sale_type ) if sale_type: self.type_id = sale_type self.onchange_type_id() return res
26.8
938
665
py
PYTHON
15.0
# Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website Sale Invoice Address", "summary": "Set e-Commerce sale orders invoice address as in backend", "version": "15.0.1.0.0", "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"], "assets": { "web.assets_tests": [ "/website_sale_invoice_address/static/src/js/website_sale_invoice_address_tour.js" ] }, }
35
665
1,179
py
PYTHON
15.0
# Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests import common, tagged @tagged("post_install", "-at_install") class WebsiteSaleHttpCase(common.HttpCase): def setUp(self): super().setUp() self.partner_company = self.env["res.partner"].create( {"name": "Mr. Odoo's company"} ) self.partner = self.env.ref("base.partner_demo_portal") self.partner.parent_id = self.partner_company self.partner_invoice = self.env["res.partner"].create( { "name": "Mr. Odoo's accountant", "type": "invoice", "parent_id": self.partner_company.id, } ) def test_website_sale_invoice_partner(self): """Make an order from the frontend and check that the invoice address is the right one""" self.start_tour("/shop", "website_sale_invoice_address_tour", login="portal") order = self.env["sale.order"].search( [("partner_id", "=", self.partner.id)], limit=1 ) self.assertEqual(order.partner_invoice_id, self.partner_invoice)
39.3
1,179
902
py
PYTHON
15.0
# Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import models class SaleOrder(models.Model): _inherit = "sale.order" def write(self, vals): """Catch the context from the website write so we ensure the correct invoice partner as we would do in backend""" override_invoice_partner = self.env.context.get("override_partner_invoice_id") partner_obj = self.env["res.partner"] if override_invoice_partner and "partner_invoice_id" in vals: partner = vals.get("partner_id", self.partner_id.id) if partner: partner = partner_obj.browse(partner) partner_invoice_id = partner.address_get(["invoice"]).get("invoice") vals["partner_invoice_id"] = partner_obj.browse(partner_invoice_id).id return super().write(vals)
45.1
902
1,259
py
PYTHON
15.0
# Copyright 2020 David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import models class Website(models.Model): _inherit = "website" def sale_get_order( self, force_create=False, code=None, update_pricelist=False, force_pricelist=False, ): """Odoo commit 6e69de67071f2618e00856a74716d861b7f47391 breaks the old flow that puts the invoice partner of the commercial entity. In a B2B environment this is quite necessary. Well catch the context in `sale.order`""" self_ctx = self.with_context(override_partner_invoice_id=True) return super(Website, self_ctx).sale_get_order( force_create=force_create, code=code, update_pricelist=update_pricelist, force_pricelist=force_pricelist, ) def _prepare_sale_order_values(self, partner, pricelist): """Ensure correct invoice partner""" vals = super()._prepare_sale_order_values(partner, pricelist) # Recover v11 partner invoice behavior partner_invoice_id = partner.address_get(["invoice"]).get("invoice") vals.update({"partner_invoice_id": partner_invoice_id}) return vals
37.029412
1,259
708
py
PYTHON
15.0
# © 2020 Solvos Consultoría Informática (<http://www.solvos.es>) # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html { "name": "Website Sale Product Description", "category": "Website", "summary": "Shows custom e-Commerce description for products", "version": "15.0.1.1.0", "website": "https://github.com/OCA/e-commerce", "author": "Solvos, Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, "installable": True, "depends": ["website_sale"], "data": [ "views/website_sale_template.xml", "views/product_template.xml", ], "demo": [ "data/demo_website_sale_product_description.xml", ], }
33.571429
705
459
py
PYTHON
15.0
# © 2020 Solvos Consultoría Informática (<http://www.solvos.es>) # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html from odoo import fields, models from odoo.tools.translate import html_translate class ProductTemplate(models.Model): _inherit = "product.template" public_description = fields.Html( "Description for e-Commerce", sanitize_attributes=False, translate=html_translate, copy=False, )
28.5
456
965
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website Sale Attribute Filter Category", "summary": "Allow group attributes in shop by categories", "version": "15.0.2.1.0", "development_status": "Production/Stable", "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_comparison"], "data": [ "views/templates.xml", "views/website_sale_product_attribute_filter_category_view.xml", ], "assets": { "web.assets_frontend": [ "/website_sale_product_attribute_filter_category/static/src/scss/*.scss", ], "web.assets_tests": [ "/website_sale_product_attribute_filter_category/static/src/js/*.js" ], }, }
35.740741
965
426
py
PYTHON
15.0
# Copyright 2023 Tecnativa - Pilar Vargas # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openupgradelib import openupgrade @openupgrade.migrate() def migrate(env, version): openupgrade.logged_query( env.cr, """ DELETE FROM ir_ui_view WHERE key = 'website_sale_product_attribute_filter_category.products_attributes_collapsible' AND website_id IS NOT NULL """, )
26.625
426
2,793
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests import tagged from odoo.tests.common import HttpCase @tagged("post_install", "-at_install") class WebsiteSaleAttributeFilterCategoryHttpCase(HttpCase): def setUp(self): super().setUp() # Models AttributeCategory = self.env["product.attribute.category"] ProductAttribute = self.env["product.attribute"] ProductAttributeValue = self.env["product.attribute.value"] ProductAttributeLine = self.env["product.template.attribute.line"] self.attribute_category = AttributeCategory.create( {"name": "Test category", "website_folded": False} ) self.product_attribute = ProductAttribute.create( { "name": "Test", "create_variant": "no_variant", "category_id": self.attribute_category.id, } ) self.product_attribute_value_test_1 = ProductAttributeValue.create( {"name": "Test v1", "attribute_id": self.product_attribute.id} ) self.product_attribute_value_test_2 = ProductAttributeValue.create( {"name": "Test v2", "attribute_id": self.product_attribute.id} ) self.product_template = self.env.ref( "product.product_product_4_product_template" ) self.product_attribute_line = ProductAttributeLine.create( { "product_tmpl_id": self.product_template.id, "attribute_id": self.product_attribute.id, "value_ids": [ ( 6, 0, [ self.product_attribute_value_test_1.id, self.product_attribute_value_test_2.id, ], ) ], } ) self.product_template.write( { "attribute_line_ids": [(4, self.product_attribute_line.id)], "is_published": True, } ) # Active filter in /shop. self.env.ref("website_sale.products_attributes").active = True self.env.ref( "website_sale_product_attribute_filter_category.products_attributes_categories" ).active = True def test_ui_website(self): """Test frontend tour.""" tour = ( "odoo.__DEBUG__.services['web_tour.tour']", "website_sale_product_attribute_filter_category", ) self.browser_js( url_path="/", code="%s.run('%s')" % tour, ready="%s.tours['%s'].ready" % tour, login="admin", )
37.743243
2,793
331
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import fields, models class ProductAttributeCategory(models.Model): _inherit = "product.attribute.category" website_folded = fields.Boolean( string="Website folded", default=True, )
27.583333
331
1,292
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import _, http from odoo.addons.website_sale.controllers.main import WebsiteSale class ProductAttributeCategory(WebsiteSale): @http.route() def shop(self, page=0, category=None, search="", ppg=False, **post): response = super(ProductAttributeCategory, self).shop( page=page, category=category, search=search, ppg=ppg, **post ) # Re-order attributes by their category sequence response.qcontext["attributes"] = response.qcontext["attributes"].sorted( lambda x: (x.category_id.sequence, x.id) ) # Load all categories, and load a "False" category for attributes that # has not category and display it under 'Undefined' category categories = [(False, _("Undefined"), True)] categories.extend( (x.id, x.name, x.website_folded) for x in response.qcontext["attributes"].mapped("category_id") ) response.qcontext["attribute_categories"] = categories response.qcontext["filtered_products"] = False if search or post.get("attrib", False): response.qcontext["filtered_products"] = True return response
44.551724
1,292
976
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website Sale Stock Provisioning Date", "summary": "Display provisioning date for a product in shop online", "version": "15.0.1.0.0", "development_status": "Production/Stable", "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_stock"], "data": ["views/product_template_views.xml"], "assets": { "web.assets_frontend": [ "/website_sale_stock_provisioning_date/static/src/js/" "website_sale_stock_provisioning_date.js", ], "web.assets_tests": [ "/website_sale_stock_provisioning_date/static/src/js/" "website_sale_stock_provisioning_date_tour.js", ], }, }
37.538462
976
1,862
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from datetime import datetime, timedelta from odoo.tests.common import Form, HttpCase class WebsiteSaleStockProvisioningDate(HttpCase): def setUp(self): super().setUp() product = self.env["product.product"].create( { "name": "product test - provisioning date", "type": "product", "website_published": True, "show_next_provisioning_date": True, } ) incoming_picking_type = self.env["stock.picking.type"].search( [ ("code", "=", "incoming"), "|", ("warehouse_id.company_id", "=", self.env.user.company_id.id), ("warehouse_id", "=", False), ], limit=1, ) picking_form = Form( recordp=self.env["stock.picking"].with_context( default_picking_type_id=incoming_picking_type.id ), view="stock.view_picking_form", ) with picking_form.move_ids_without_package.new() as move: move.product_id = product move.product_uom_qty = 10 picking = picking_form.save() picking_form = Form(picking) picking_form.scheduled_date = datetime.now() + timedelta(days=2) picking = picking_form.save() picking.action_confirm() def test_ui_website(self): """Test frontend tour.""" tour = ( "odoo.__DEBUG__.services['web_tour.tour']", "website_sale_stock_provisioning_date", ) self.browser_js( url_path="/shop", code="%s.run('%s')" % tour, ready="%s.tours['%s'].ready" % tour, login="admin", )
34.481481
1,862
2,026
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import fields, models from odoo.tools.misc import format_date class ProductTemplate(models.Model): _inherit = "product.template" show_next_provisioning_date = fields.Boolean( help="Shows the next provisioning date in the website shop " "if the product is out of stock. This option may not make " "sense if you don't select an 'Availability' option that " "shows the inventory of the product in the website shop." ) def _get_next_provisioning_date(self, company): return self.product_variant_ids._get_next_provisioning_date(company) def _get_combination_info( self, combination=False, product_id=False, add_qty=1, pricelist=False, parent_combination=False, only_template=False, ): combination_info = super()._get_combination_info( combination=combination, product_id=product_id, add_qty=add_qty, pricelist=pricelist, parent_combination=parent_combination, only_template=only_template, ) if combination_info["product_id"]: product = ( self.env["product.product"] .sudo() .browse(combination_info["product_id"]) ) else: product = self.sudo() provisioning_date = False if ( product.show_next_provisioning_date and product.qty_available - product.outgoing_qty <= 0 ): website_id = self.env.context.get("website_id") company = self.env["website"].browse(website_id).company_id provisioning_date = product._get_next_provisioning_date(company) provisioning_date = format_date(self.env, provisioning_date) combination_info.update(provisioning_date=provisioning_date) return combination_info
36.836364
2,026
738
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import fields, models class ProductProduct(models.Model): _inherit = "product.product" def _get_next_provisioning_date(self, company): domain = [ ("company_id", "=", company.id), ("product_id", "in", self.ids), ("state", "not in", ["draft", "done", "cancel"]), ("location_id.usage", "=", "supplier"), ("location_dest_id.usage", "=", "internal"), ("date", ">=", fields.Datetime.now()), ] move = self.env["stock.move"].sudo().search(domain, order="date", limit=1) return move and move.date.date() or False
38.842105
738
630
py
PYTHON
15.0
# Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website Sale Product Sort", "summary": "Allow to define default sort criteria for e-commerce", "version": "15.0.1.0.0", "development_status": "Production/Stable", "category": "Website", "website": "https://github.com/OCA/e-commerce", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "depends": ["website_sale"], "data": ["views/website_sale_sort.xml", "views/res_config_settings_view.xml"], "application": False, "installable": True, }
39.375
630
395
py
PYTHON
15.0
# Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import fields, models class ResConfigSettings(models.TransientModel): _inherit = "res.config.settings" product_sort_criteria = fields.Selection( related="website_id.default_product_sort_criteria", default_model="website", readonly=False, )
30.384615
395
888
py
PYTHON
15.0
# Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import _, api, fields, models class Website(models.Model): _inherit = "website" @api.model def _get_product_sort_criterias(self): """Extend to add more sort criterias""" return [ ("website_sequence asc", _("Relevance")), ("list_price desc", _("Catalog price: High to Low")), ("list_price asc", _("Catalog price: Low to High")), ("name asc", _("Name - A to Z")), ("name desc", _("Name - Z to A")), ] default_product_sort_criteria = fields.Selection( selection="_get_product_sort_criterias", string="Sort products by", help="Default criteria for sorting products in the shop", default="website_sequence asc", required=True, )
34.153846
888
1,012
py
PYTHON
15.0
# Copyright 2020 Tecnativa - David Vidal # Copyright 2021 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.http import request, route from odoo.addons.website_sale.controllers.main import WebsiteSale class WebsiteSale(WebsiteSale): def _get_search_order(self, post): """We can configure default sort criteria for every website""" if post.get("order"): return super()._get_search_order(post) order = request.website.default_product_sort_criteria return "is_published desc, %s, id desc" % order @route() def shop(self, page=0, category=None, search="", ppg=False, **post): """Transfer custom sort order to QWeb templates.""" response = super().shop( page=page, category=category, search=search, ppg=ppg, **post ) response.qcontext["order"] = ( post.get("order") or request.website.default_product_sort_criteria ) return response
38.923077
1,012
996
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website Sale Product Detail Attribute Image", "summary": "Display attributes images in shop product detail", "version": "15.0.1.0.0", "development_status": "Production/Stable", "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"], "data": [ "views/product_attribute_views.xml", "views/templates.xml", ], "assets": { "web.assets_frontend": [ "/website_sale_product_detail_attribute_image/static/src/scss/style.scss", ], "web.assets_tests": [ "/website_sale_product_detail_attribute_image/static/src/js/" "website_sale_product_detail_attribute_image_tour.js", ], }, }
35.571429
996
3,962
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests.common import HttpCase class WebsiteSaleHttpCase(HttpCase): def setUp(self): super().setUp() self.ProductAttribute = self.env["product.attribute"] self.ProductAttributeValue = self.env["product.attribute.value"] self.ProductAttributeLine = self.env["product.template.attribute.line"] detail_image = "R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" attribute_dangerous = self.ProductAttribute.create( { "name": "Dangerousness", "create_variant": "no_variant", "website_product_detail_image_published": False, "website_product_detail_image": detail_image, } ) product_attribute_image_high = self.ProductAttributeValue.create( {"name": "High dangerousness", "attribute_id": attribute_dangerous.id} ) self.ProductAttributeValue.create( {"name": "Low dangerousness", "attribute_id": attribute_dangerous.id} ) self.product_template = self.env.ref( "product.product_product_4_product_template" ) attribute_line = self.ProductAttributeLine.create( { "product_tmpl_id": self.product_template.id, "attribute_id": attribute_dangerous.id, "value_ids": [(6, 0, product_attribute_image_high.ids)], } ) self.product_template.write({"attribute_line_ids": [(4, attribute_line.id)]}) attribute_image_policy_one = self.ProductAttribute.create( { "name": "Policy One", "website_name": "Website Policy One", "create_variant": "no_variant", "website_product_detail_image_published": True, "website_product_detail_image": detail_image, } ) value_image_policy_one_1 = self.ProductAttributeValue.create( { "name": "Policy One Value 1", "website_name": "Policy One Value 1 for website", "attribute_id": attribute_image_policy_one.id, } ) attribute_line = self.ProductAttributeLine.create( { "product_tmpl_id": self.product_template.id, "attribute_id": attribute_image_policy_one.id, "value_ids": [(6, 0, value_image_policy_one_1.ids)], } ) self.product_template.write({"attribute_line_ids": [(4, attribute_line.id)]}) attribute_image_policy_two = self.ProductAttribute.create( { "name": "Policy Two", "create_variant": "no_variant", "website_product_detail_image_published": True, "website_product_detail_image": detail_image, } ) value_image_policy_two_1 = self.ProductAttributeValue.create( { "name": "Policy Two Value 1", "attribute_id": attribute_image_policy_two.id, } ) attribute_line = self.ProductAttributeLine.create( { "product_tmpl_id": self.product_template.id, "attribute_id": attribute_image_policy_two.id, "value_ids": [(6, 0, value_image_policy_two_1.ids)], } ) self.product_template.write({"attribute_line_ids": [(4, attribute_line.id)]}) def test_ui_website(self): """Test frontend tour.""" tour = ( "odoo.__DEBUG__.services['web_tour.tour']", "website_sale_product_detail_attribute_image", ) self.browser_js( url_path="/", code="%s.run('%s')" % tour, ready="%s.tours['%s'].ready" % tour, login="admin", )
40.020202
3,962
786
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import fields, models class ProductAttribute(models.Model): _inherit = "product.attribute" website_product_detail_image = fields.Binary( string="Website detail image", attachment=True, help="Image of the attribute for shop online product detail.", ) website_product_detail_image_published = fields.Boolean( string="Publish in website", help="Display attribute image in shop online product detail", ) website_name = fields.Char(translate=True) class ProductAttributevalue(models.Model): _inherit = "product.attribute.value" website_name = fields.Char(string="Website value", translate=True)
32.75
786
657
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import http from odoo.addons.website_sale.controllers.main import WebsiteSale class WebsiteSaleProductDetailAttributeImage(WebsiteSale): @http.route() def product(self, product, category="", search="", **kwargs): res = super().product(product, category=category, search=search, **kwargs) attributes_detail = product.attribute_line_ids.filtered( lambda x: x.attribute_id.website_product_detail_image_published ) res.qcontext["attributes_detail"] = attributes_detail return res
41.0625
657
677
py
PYTHON
15.0
# Copyright 2017 LasLabs Inc. <https://laslabs.com/> # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). { "name": "Website Sale - Hide Empty Categories", "summary": "Hide any Product Categories that are empty", "version": "15.0.1.0.0", "category": "Website", "website": "https://github.com/OCA/e-commerce", "author": "LasLabs, Odoo Community Association (OCA)", "license": "LGPL-3", "application": False, "installable": True, "depends": ["website_sale"], "data": ["views/website_sale_templates.xml"], "assets": { "web.assets_tests": ["/website_sale_hide_empty_category/static/src/js/tour.js"], }, }
37.611111
677
1,132
py
PYTHON
15.0
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests.common import HttpCase class UICase(HttpCase): def setUp(self): super().setUp() category_posted = self.env["product.public.category"].create( {"name": "Category Test Posted"} ) self.env["product.public.category"].create({"name": "Category Test Not Posted"}) self.env["product.template"].create( { "name": "Test Product 1", "is_published": True, "website_sequence": 1, "type": "consu", "public_categ_ids": [category_posted.id], } ) self.env.ref("website_sale.products_categories").active = True def test_ui_website(self): """Test frontend tour.""" tour = ( "odoo.__DEBUG__.services['web_tour.tour']", "website_sale_hide_empty_category", ) self.browser_js( url_path="/shop", code="%s.run('%s')" % tour, ready="%s.tours['%s'].ready" % tour, login="admin", )
32.342857
1,132
730
py
PYTHON
15.0
from odoo.tests import common class TestPublicCategory(common.TransactionCase): def test_has_product_recursive(self): category_1 = self.env["product.public.category"].create({"name": "Category 1"}) self.assertFalse(category_1.has_product_recursive) category_2 = self.env["product.public.category"].create( {"name": "Category 2", "parent_id": category_1.id} ) self.assertFalse(category_2.has_product_recursive) self.env["product.template"].create( {"name": "Product Test", "public_categ_ids": [(4, category_2.id, None)]} ) self.assertTrue(category_1.has_product_recursive) self.assertTrue(category_2.has_product_recursive)
33.181818
730
754
py
PYTHON
15.0
# Copyright 2017 LasLabs Inc. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). from odoo import api, fields, models class ProductPublicCategory(models.Model): _inherit = "product.public.category" has_product_recursive = fields.Boolean( string="This category or one of its children has products", compute="_compute_has_product_recursive", recursive=True, ) @api.depends("product_tmpl_ids", "child_id.has_product_recursive") def _compute_has_product_recursive(self): for category in self: category.has_product_recursive = bool( category.product_tmpl_ids or any(child.has_product_recursive for child in category.child_id) )
34.272727
754
927
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website Sale Tax Toggle", "summary": "Allow display price in Shop with or without taxes", "version": "15.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"], "data": ["views/templates.xml"], "assets": { "web.assets_frontend": [ "/website_sale_tax_toggle/static/src/js/website_sale_tax_toggle.js", "/website_sale_tax_toggle/static/src/scss/website_sale_tax_toggle.scss", ], "web.assets_tests": [ "/website_sale_tax_toggle/static/src/js/website_sale_tax_toggle_tour.js" ], }, }
37.08
927
1,729
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests.common import HttpCase class WebsiteSaleTaxesToggleHttpCase(HttpCase): def setUp(self): super().setUp() # Get company for Mitchel Admin user self.user_admin = self.env.ref("base.user_admin") user_company = self.user_admin.company_id self.tax = self.env["account.tax"].create( { "name": "Taxes toggle test tax", "amount_type": "percent", "amount": 15, "type_tax_use": "sale", "company_id": user_company.id, } ) self.product_template = self.env["product.template"].create( { "name": "Product test tax toggle", "list_price": 750.00, "taxes_id": [(6, 0, self.tax.ids)], "website_published": True, "website_sequence": 9999, } ) pricelist = self.env["product.pricelist"].create( {"name": "Price list for tests", "currency_id": user_company.currency_id.id} ) self.env.user.partner_id.property_product_pricelist = pricelist # To avoid currency converter self.env["res.currency.rate"].search([]).write({"rate": 1}) def test_ui_website(self): """Test frontend tour.""" tour = ( "odoo.__DEBUG__.services['web_tour.tour']", "website_sale_tax_toggle", ) self.browser_js( url_path="/shop", code="%s.run('%s')" % tour, ready="%s.tours['%s'].ready" % tour, login="admin", )
36.020833
1,729
1,265
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, models from odoo.http import request from odoo.tools import ormcache class ResUsers(models.Model): _inherit = "res.users" @api.model def has_group(self, group_ext_id): tax_included = "account.group_show_line_subtotals_tax_included" tax_excluded = "account.group_show_line_subtotals_tax_excluded" if ( self.env.context.get("website_id") and group_ext_id in [tax_included, tax_excluded] and not self.env.context.get("skip_tax_toggle_check") ): taxed = request.session.get( "tax_toggle_taxed", self.env.user.with_context(skip_tax_toggle_check=True).has_group( tax_included ), ) return group_ext_id != (tax_excluded if taxed else tax_included) return super().has_group(group_ext_id) # HACK: To clear cache called from res.users write method @api.model @ormcache("self._uid", "group_ext_id") def _has_group(self, group_ext_id): return super()._has_group(group_ext_id) has_group.clear_cache = _has_group.clear_cache
36.142857
1,265
586
py
PYTHON
15.0
# Copyright 2020 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 WebsiteSaleTaxToggle(WebsiteSale): @http.route(["/website/tax_toggle"], type="json", auth="public", website=True) def tax_toggle(self): # Create a session variable request.session["tax_toggle_taxed"] = not request.session.get( "tax_toggle_taxed", False ) return request.session["tax_toggle_taxed"]
34.470588
586
1,008
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Alexandre Díaz # License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl). { "name": "Website Snippet Product Category", "category": "Website", "summary": "Adds a new snippet to show e-commerce categories", "version": "15.0.1.0.0", "license": "LGPL-3", "website": "https://github.com/OCA/e-commerce", "author": "Tecnativa, Odoo Community Association (OCA)", "depends": ["website_sale"], "data": [ "templates/snippets.xml", "views/product_public_category.xml", ], "assets": { "web.assets_frontend": [ "/website_snippet_product_category/static/src/scss/snippet.scss", "/website_snippet_product_category/static/src/js/frontend.js", ], "website.assets_editor": [ "/website_snippet_product_category/static/src/js/snippet.options.js", ], }, "demo": ["demo/demo.xml", "demo/pages.xml"], "maintainers": ["Tardo"], "installable": True, }
35.964286
1,007
354
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import fields, models class ProductPublicCategory(models.Model): _inherit = "product.public.category" published_in_product_category_snippet = fields.Boolean( "Published in product category snippet", copy=False )
32.090909
353
834
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Alexandre Díaz # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import http from odoo.http import request from odoo.addons.website.controllers.main import QueryURL class Website(http.Controller): @http.route( ["/website_sale/render_product_category"], type="json", auth="public", website=True, ) def render_product_category(self, template, **kwargs): categories = request.env["product.public.category"].search( [ ("parent_id", "=", False), ("published_in_product_category_snippet", "=", True), ] ) keep = QueryURL("/shop", category=0) return request.website.viewref(template)._render( {"object": categories, "keep": keep} )
32.038462
833
832
py
PYTHON
15.0
# Copyright 2021 Camptocamp (http://www.camptocamp.com). # @author Iván Todorovich <[email protected]> # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Website Sale Cart Expire", "summary": "Cancel carts without activity after a configurable time", "version": "15.0.1.1.0", "author": "Camptocamp, Odoo Community Association (OCA)", "maintainers": ["ivantodorovich"], "website": "https://github.com/OCA/e-commerce", "license": "AGPL-3", "category": "Website", "depends": ["website_sale"], "data": [ "data/ir_cron.xml", "views/res_config_settings.xml", "views/templates.xml", ], "assets": { "web.assets_frontend": [ "website_sale_cart_expire/static/src/js/website_sale_cart_expire.js", ], }, }
33.24
831
538
py
PYTHON
15.0
# Copyright 2022 Camptocamp SA (https://www.camptocamp.com). # @author Iván Todorovich <[email protected]> # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import SUPERUSER_ID, api def migrate(cr, version): if not version: return env = api.Environment(cr, SUPERUSER_ID, {}) cron = env.ref( "website_sale_cart_expire.ir_cron_cart_expire", raise_if_not_found=False, ) if cron: cron.code = "model._scheduler_website_expire_cart(autocommit=True)"
31.588235
537
5,312
py
PYTHON
15.0
# Copyright 2021 Camptocamp (http://www.camptocamp.com). # @author Iván Todorovich <[email protected]> # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from datetime import datetime, timedelta from freezegun import freeze_time from odoo import fields from odoo.tests import TransactionCase class TestWebsiteSaleCartExpire(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() cls.tx_counter = 0 # Websites cls.website_1 = cls.env.ref("website.default_website") cls.website_2 = cls.env.ref("website.website2") cls.website_1.cart_expire_delay = 0.00 # hours (= disabled) cls.website_2.cart_expire_delay = 2.00 # hours # Orders cls.order_1 = cls.env.ref("website_sale.website_sale_order_1") cls.order_2 = cls.env.ref("website_sale.website_sale_order_2") cls.order_3 = cls.env.ref("website_sale.website_sale_order_3") cls.order_4 = cls.env.ref("website_sale.website_sale_order_4") cls.orders = cls.order_1 + cls.order_2 + cls.order_3 + cls.order_4 # Set to draft and assign all to website_2 # (this also updates write_date to now()) cls.orders.write({"state": "draft", "website_id": cls.website_2.id}) def _create_payment_transaction(self, order): self.tx_counter += 1 acquirer = self.env.ref("payment.payment_acquirer_test") return self.env["payment.transaction"].create( { "acquirer_id": acquirer.id, "reference": f"{order.name}-{self.tx_counter}", "amount": order.amount_total, "currency_id": order.currency_id.id, "partner_id": order.partner_id.id, "operation": "online_direct", "sale_order_ids": [fields.Command.set([order.id])], } ) def test_expire_dates(self): # Expire Date is set in the future self.assertTrue(self.order_1.cart_expire_date) # Changing to a website without expire delay should remove it self.order_1.website_id = self.website_1 self.assertFalse(self.order_1.cart_expire_date) def test_expire_scheduler(self): # Case 1: We haven't reached the expire date yet self.env["website"]._scheduler_website_expire_cart() for order in self.orders: self.assertEqual(order.state, "draft") # Case 2: We have reached website 2 expire date with freeze_time(datetime.now() + timedelta(hours=3)): self.env["website"]._scheduler_website_expire_cart() for order in self.orders: self.assertEqual(order.state, "cancel") def test_expire_scheduler_multi_website(self): # For this test, we split the orders among the 2 websites (self.order_1 + self.order_2).write({"website_id": self.website_1.id}) with freeze_time(datetime.now() + timedelta(hours=3)): self.env["website"]._scheduler_website_expire_cart() self.assertEqual(self.order_1.state, "draft", "No expire delay on website 1") self.assertEqual(self.order_2.state, "draft", "No expire delay on website 1") self.assertEqual(self.order_3.state, "cancel", "Should've been cancelled") self.assertEqual(self.order_4.state, "cancel", "Should've been cancelled") @freeze_time(datetime.now() + timedelta(hours=3)) def test_expire_scheduler_ignore_sent_quotation(self): """Test that sent quotations aren't cancelled Quotations can be sent manually or automatically when using wire transfer as payment. They shouldn't be cancelled. """ self.order_1.action_quotation_sent() self.env["website"]._scheduler_website_expire_cart() self.assertNotEqual(self.order_1.state, "cancel") @freeze_time(datetime.now() + timedelta(hours=3)) def test_expire_scheduler_ignore_in_payment(self): """Carts with a payment transaction in progress shouldn't expire""" self._create_payment_transaction(self.order_1) tx_2 = self._create_payment_transaction(self.order_2) tx_2._set_pending() tx_3 = self._create_payment_transaction(self.order_3) tx_3._set_canceled() tx_4 = self._create_payment_transaction(self.order_4) tx_4._set_error("Something went wrong") # Carts with transactions in progress are not canceled # Even those with 'draft' or 'error' transactions, because # the timer is reseted whenever a tx state changes. self.env["website"]._scheduler_website_expire_cart() self.assertNotEqual(self.order_1.state, "cancel") self.assertNotEqual(self.order_2.state, "cancel") self.assertNotEqual(self.order_3.state, "cancel") self.assertNotEqual(self.order_4.state, "cancel") # In case of error, another transaction can be initialized # However for order_1, no more activity was detected, so it's canceled with freeze_time(datetime.now() + timedelta(hours=3)): self._create_payment_transaction(self.order_4) self.env["website"]._scheduler_website_expire_cart() self.assertEqual(self.order_1.state, "cancel") self.assertNotEqual(self.order_4.state, "cancel")
47.846847
5,311
1,802
py
PYTHON
15.0
# Copyright 2021 Camptocamp (http://www.camptocamp.com). # @author Iván Todorovich <[email protected]> # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from datetime import timedelta from odoo import api, fields, models class SaleOrder(models.Model): _inherit = "sale.order" cart_expire_date = fields.Datetime( compute="_compute_cart_expire_date", help="Technical field: The date this cart will automatically expire", ) def _should_bypass_cart_expiration(self): """Hook method to prevent a cart from expiring""" self.ensure_one() # We don't want to cancel carts that are already in payment. return any( tx.state in ["pending", "authorized", "done"] for tx in self.transaction_ids ) @api.depends( "write_date", "website_id.cart_expire_delay", "transaction_ids.last_state_change", ) def _compute_cart_expire_date(self): for rec in self: if ( rec.state == "draft" and rec.website_id.cart_expire_delay and not rec._should_bypass_cart_expiration() ): # In case of draft records, use current date from_date = rec.write_date or fields.Datetime.now() # In case or records with transactions, consider last tx date if rec.transaction_ids: last_tx_date = max(rec.transaction_ids.mapped("last_state_change")) from_date = max(from_date, last_tx_date) expire_delta = timedelta(hours=rec.website_id.cart_expire_delay) rec.cart_expire_date = from_date + expire_delta elif rec.cart_expire_date: rec.cart_expire_date = False
38.319149
1,801
404
py
PYTHON
15.0
# Copyright 2021 Camptocamp (http://www.camptocamp.com). # @author Iván Todorovich <[email protected]> # 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" cart_expire_delay = fields.Float( related="website_id.cart_expire_delay", readonly=False )
31
403
2,113
py
PYTHON
15.0
# Copyright 2021 Camptocamp (http://www.camptocamp.com). # @author Iván Todorovich <[email protected]> # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). import logging from datetime import timedelta from odoo import _, api, fields, models from odoo.osv import expression _logger = logging.getLogger(__name__) class Website(models.Model): _inherit = "website" cart_expire_delay = fields.Float( string="Expire Delay", default=0.0, help="Automatically cancel website orders after the given time.\n" "Set to 0 to disable this feature.", ) def _get_cart_expire_delay_domain(self): self.ensure_one() expire_date = fields.Datetime.now() - timedelta(hours=self.cart_expire_delay) return [ ("website_id", "=", self.id), ("state", "=", "draft"), ("write_date", "<=", expire_date), # We don't want to cancel carts that are already in payment. "|", ("transaction_ids", "=", False), "!", ("transaction_ids.state", "in", ["pending", "authorized", "done"]), ] @api.model def _scheduler_website_expire_cart(self, autocommit=False): websites = self.search([("cart_expire_delay", ">", 0)]) if not websites: return True carts = self.env["sale.order"].search( expression.OR( [website._get_cart_expire_delay_domain() for website in websites] ) ) now = fields.Datetime.now() for cart in carts: if not cart.cart_expire_date or cart.cart_expire_date > now: continue try: with self.env.cr.savepoint(): cart.message_post(body=_("Cart expired")) cart.action_cancel() except Exception as e: _logger.exception("Unable to cancel expired cart %s: %s", cart, e) else: if autocommit: self.env.cr.commit() # pylint: disable=invalid-commit return True
34.622951
2,112
649
py
PYTHON
15.0
# Copyright 2022 Camptocamp SA (https://www.camptocamp.com). # @author Iván Todorovich <[email protected]> # 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 WebsiteSaleCartExpire(WebsiteSale): @http.route( ["/shop/cart/get_expire_date"], type="json", auth="public", methods=["POST"], website=True, csrf=False, ) def get_expire_date(self, **kw): order = request.website.sale_get_order() return order.cart_expire_date
29.454545
648
945
py
PYTHON
15.0
# Copyright 2015, 2017, 2021 Tecnativa - Jairo Llopis # Copyright 2016 Tecnativa - Vicent Cubells # Copyright 2019 Tecnativa - Cristina Martin R. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Require accepting legal terms to checkout", "summary": "Force the user to accept legal tems to buy in the web shop", "version": "15.0.2.0.0", "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"], "data": ["templates/website_sale.xml"], "assets": { "web.assets_frontend": [ "//website_sale_require_legal/static/src/scss/website_sale_require_legal.scss", ], "web.assets_tests": [ "/website_sale_require_legal/static/tests/tours/tour.js", ], }, }
37.8
945
2,176
py
PYTHON
15.0
# Copyright 2017 Jairo Llopis <[email protected]> # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests import new_test_user, tagged from odoo.tests.common import HttpCase @tagged("post_install", "-at_install") class UICase(HttpCase): """Test checkout flow with legal terms acceptance required. It would be nice to check also that the workflow isn't interrupted when the acceptance requirement views are disabled, but that's what upstream tests do, so we don't need to repeat them. We can assume that, if other tests in the same integrated environment don't fail because of lack of legal terms acceptance, then the flow is fine. """ def setUp(self): """Ensure website lang is en_US.""" super().setUp() website = self.env["website"].get_current_website() wiz = self.env["base.language.install"].create({"lang": "en_US"}) wiz.website_ids = website wiz.lang_install() website.default_lang_id = self.env.ref("base.lang_en") # Activate Accept Terms & Conditions views, as explained in CONFIGURE.rst website.viewref( "website_sale_require_legal.address_require_legal" ).active = True website.viewref("website_sale.payment_sale_note").active = True new_test_user(self.env, login="portal_user", groups="base.group_portal") def test_ui_website(self): """Test frontend tour.""" self.start_tour("/shop", "website_sale_require_legal", login="portal_user") order = self.env["sale.order"].search( [ ("partner_id", "=", "Super Mario"), ("website_id", "!=", "False"), ] ) partner = order.partner_id # Assert that the sale order and partner have metadata logs self.assertTrue( order.message_ids.filtered( lambda one: "Website legal terms acceptance metadata" in one.body ) ) self.assertTrue( partner.message_ids.filtered( lambda one: "Website legal terms acceptance metadata" in one.body ) )
41.056604
2,176
3,565
py
PYTHON
15.0
# Copyright 2015-2017 Tecnativa - Jairo Llopis # Copyright 2016 Tecnativa - Vicent Cubells # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import _, http from odoo.http import request from odoo.addons.website_sale.controllers import main class WebsiteSale(main.WebsiteSale): def _get_mandatory_fields_billing(self, country_id=False): result = super()._get_mandatory_fields_billing(country_id) return result + self._mandatory_legal_terms() def _get_mandatory_fields_shipping(self, country_id=False): result = super()._get_mandatory_fields_shipping(country_id) return result + self._mandatory_legal_terms() def _mandatory_legal_terms(self): """Require ``accepted_legal_terms`` only if we are validating.""" result = [] if request.context.get("needs_legal"): result.append("accepted_legal_terms") return result def checkout_form_validate(self, mode, all_form_values, data): """Require accepting legal terms to validate form.""" # Patch context old_context = request.context request.context = dict( request.context, needs_legal=request.website.viewref( "website_sale_require_legal.address_require_legal" ).active, ) result = super().checkout_form_validate(mode, all_form_values, data) # Unpatch context request.context = old_context return result def _checkout_form_save(self, mode, checkout, all_values): res = super()._checkout_form_save(mode, checkout, all_values) if all_values.get("submitted") and all_values.get("accepted_legal_terms"): partner = request.env["res.partner"].browse(res) self._log_acceptance_metadata(partner) return res def _log_acceptance_metadata(self, record): """Log legal terms acceptance metadata.""" environ = request.httprequest.headers.environ message = _("Website legal terms acceptance metadata: %s") metadata = "<br/>".join( "{}: {}".format(val, environ.get(val)) for val in ( "REMOTE_ADDR", "HTTP_USER_AGENT", "HTTP_ACCEPT_LANGUAGE", ) ) record.sudo().message_post(body=message % metadata, message_type="notification") class PaymentPortal(main.PaymentPortal): @http.route() def shop_payment_transaction(self, order_id, access_token, **kwargs): """Record sale order payment legal terms acceptance. If the "Accept Terms & Conditions" upstream view is enabled in the website, to get here, user must have accepted legal terms. """ result = super().shop_payment_transaction(order_id, access_token, **kwargs) # If the "Accept Terms & Conditions" view is disabled, we log nothing if not request.website.viewref("website_sale.payment_sale_note").active: return result # Retrieve the sale order if order_id: sale_obj = request.env["sale.order"] domain = [("id", "=", order_id)] if access_token: sale_obj = sale_obj.sudo() domain.append(("access_token", "=", access_token)) order = sale_obj.search(domain, limit=1) else: order = request.website.sale_get_order() # Log metadata in the sale order if order: WebsiteSale._log_acceptance_metadata(self, order) return result
40.05618
3,565
821
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Victor M.M. Torres # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). { "name": "Website Sale Attribute Value Existing", "summary": "Allow hide attributes values not used in variants", "version": "15.0.1.0.0", "development_status": "Production/Stable", "category": "Website", "website": "https://github.com/OCA/e-commerce", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "LGPL-3", "application": False, "installable": True, "depends": ["website_sale"], "data": ["views/templates.xml"], "assets": { "web.assets_tests": [ "/website_sale_product_attribute_value_filter_existing/static/src/js/" "website_sale_product_attribute_value_filter_existing_tour.js", ] }, }
37.318182
821
3,209
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). from odoo.tests.common import HttpCase class WebsiteSaleHttpCase(HttpCase): def setUp(self): super().setUp() # Models ProductAttribute = self.env["product.attribute"] ProductAttributeValue = self.env["product.attribute.value"] ProductAttributeLine = self.env["product.template.attribute.line"] self.product_attribute = ProductAttribute.create( {"name": "Test Special Color", "create_variant": "no_variant"} ) self.product_attribute_value_red = ProductAttributeValue.create( {"name": "Test red", "attribute_id": self.product_attribute.id} ) self.product_attribute_value_green = ProductAttributeValue.create( {"name": "Test green", "attribute_id": self.product_attribute.id} ) self.product_attribute_value_blue = ProductAttributeValue.create( {"name": "Test blue", "attribute_id": self.product_attribute.id} ) self.product_template = self.env.ref( "product.product_product_4_product_template" ) self.product_attribute_line = ProductAttributeLine.create( { "product_tmpl_id": self.product_template.id, "attribute_id": self.product_attribute.id, "value_ids": [ ( 6, 0, [ self.product_attribute_value_red.id, self.product_attribute_value_green.id, ], ) ], } ) self.product_template.write( {"attribute_line_ids": [(4, self.product_attribute_line.id)]} ) self.product_template_27 = self.env.ref( "product.product_product_27_product_template" ) self.product_attribute_line_27 = ProductAttributeLine.create( { "product_tmpl_id": self.product_template_27.id, "attribute_id": self.product_attribute.id, "value_ids": [ ( 6, 0, [ self.product_attribute_value_red.id, self.product_attribute_value_blue.id, ], ) ], } ) self.product_template_27.write( {"attribute_line_ids": [(4, self.product_attribute_line_27.id)]} ) # Active attribute's filter in /shop. By default it's disabled. self.env.ref("website_sale.products_attributes").active = True def test_ui_website(self): """Test frontend tour.""" tour = ( "odoo.__DEBUG__.services['web_tour.tour']", "website_sale_product_attribute_value_filter_existing", ) self.browser_js( url_path="/", code="%s.run('%s')" % tour, ready="%s.tours['%s'].ready" % tour, login="admin", )
38.662651
3,209
1,452
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). from odoo import http from odoo.http import request from odoo.addons.website_sale.controllers.main import WebsiteSale class ProductAttributeValues(WebsiteSale): def _get_search_domain( self, search, category, attrib_values, search_in_description=True ): # Store used domain in context to be reused after domain = super()._get_search_domain( search, category, attrib_values, search_in_description=search_in_description ) new_context = dict(request.env.context, shop_search_domain=domain) request.context = new_context return domain @http.route() def shop(self, page=0, category=None, search="", ppg=False, **post): res = super().shop(page=page, category=category, search=search, ppg=ppg, **post) domain = request.env.context.get("shop_search_domain", []) # Load all products without limit for the filter check on # attribute values templates = request.env["product.template"].search(domain, limit=False) ProductTemplateAttributeLine = request.env["product.template.attribute.line"] attribute_values = ProductTemplateAttributeLine.search( [("product_tmpl_id", "in", templates.ids)] ) res.qcontext["attr_values_used"] = attribute_values.mapped("value_ids") return res
44
1,452
781
py
PYTHON
15.0
# Copyright 2023 Tecnativa - Pilar Vargas # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website Sale Attribute Filter Collapse", "summary": "Allows the attributes of the categories to be folded", "version": "15.0.1.1.1", "category": "Website", "website": "https://github.com/OCA/e-commerce", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "depends": ["website_sale"], "data": [ "views/templates.xml", ], "assets": { "web.assets_frontend": [ "website_sale_product_attribute_filter_collapse/static/src/scss/*", ], "web.assets_tests": [ "website_sale_product_attribute_filter_collapse/static/src/js/*", ], }, }
33.956522
781
2,526
py
PYTHON
15.0
# Copyright 2023 Tecnativa - Pilar Vargas # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests import new_test_user, tagged from odoo.tests.common import HttpCase @tagged("post_install", "-at_install") class WebsiteSaleProductAttributeFilterCollapseHttpCase(HttpCase): def setUp(self): super().setUp() self.attribute_category = self.env["product.attribute.category"].create( {"name": "Test category"} ) self.product_attribute = self.env["product.attribute"].create( { "name": "Test a1", "create_variant": "no_variant", "category_id": self.attribute_category.id, } ) self.product_attribute_value_1 = self.env["product.attribute.value"].create( {"name": "Test v1", "attribute_id": self.product_attribute.id} ) self.product_attribute_value_2 = self.env["product.attribute.value"].create( {"name": "Test v2", "attribute_id": self.product_attribute.id} ) self.product_template = self.env.ref( "product.product_product_4_product_template" ) self.product_attribute_line = self.env[ "product.template.attribute.line" ].create( { "product_tmpl_id": self.product_template.id, "attribute_id": self.product_attribute.id, "value_ids": [ ( 6, 0, [ self.product_attribute_value_1.id, self.product_attribute_value_2.id, ], ) ], } ) self.product_template.write( { "attribute_line_ids": [(4, self.product_attribute_line.id)], "is_published": True, } ) # Active filter in /shop. self.env.ref("website_sale.products_attributes").active = True self.env.ref( "website_sale_product_attribute_filter_collapse.products_attributes_collapsible" ).active = True # Create new user new_test_user(self.env, login="portal_user", groups="base.group_portal") def test_tour(self): """Test frontend tour.""" self.start_tour( "/shop", "website_sale_product_attribute_filter_collapse", login="portal_user", )
37.147059
2,526
915
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Carlos Roca # Copyright 2020 Tecnativa - Sergio Teruel # Copyright 2020 Tecnativa - Carlos Dauden # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website Sale Stock List Preview", "summary": "Show the stock of products on the product previews", "version": "15.0.1.0.0", "category": "Website", "website": "https://github.com/OCA/e-commerce", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "installable": True, "depends": ["website_sale_stock"], "data": ["views/templates.xml"], "assets": { "web.assets_frontend": [ "/website_sale_stock_list_preview/static/src/js/*", "/website_sale_stock_list_preview/static/src/scss/*", ], "web.assets_tests": [ "/website_sale_stock_list_preview/static/src/tests/*.js", ], }, }
36.6
915
4,076
py
PYTHON
15.0
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests.common import HttpCase, tagged @tagged("post_install", "-at_install") class UICase(HttpCase): def setUp(self): super().setUp() product1 = self.env["product.template"].create( { "name": "Test Product 1", "is_published": True, "website_sequence": 1, "type": "product", "allow_out_of_stock_order": True, "show_availability": True, "available_threshold": 99999, } ) product2 = self.env["product.template"].create( { "name": "Test Product 2", "is_published": True, "website_sequence": 1, "type": "product", "allow_out_of_stock_order": False, "show_availability": True, } ) product3 = self.env["product.template"].create( { "name": "Test Product 3", "is_published": True, "website_sequence": 1, "type": "product", "allow_out_of_stock_order": False, "show_availability": True, "available_threshold": 5, } ) self.env["product.template"].create( { "name": "Test Product 4", "is_published": True, "website_sequence": 1, "type": "product", "out_of_stock_message": "test message", } ) self.env["product.template"].create( { "name": "Test Product 5", "is_published": True, "website_sequence": 1, "type": "product", } ) self.env["product.template"].create( { "name": "Test Product 6", "is_published": True, "website_sequence": 1, "type": "product", "allow_out_of_stock_order": True, "show_availability": True, "out_of_stock_message": "Out of stock", } ) self.env["product.template"].create( { "name": "Test Product 7", "is_published": True, "website_sequence": 1, "type": "product", "allow_out_of_stock_order": False, "show_availability": True, } ) self.env["stock.quant"].create( [ { "product_id": product1.product_variant_id.id, "location_id": self.env.ref("stock.stock_location_stock").id, "quantity": 30.0, }, { "product_id": product2.product_variant_id.id, "location_id": self.env.ref("stock.stock_location_stock").id, "quantity": 30.0, }, { "product_id": product3.product_variant_id.id, "location_id": self.env.ref("stock.stock_location_stock").id, "quantity": 5.0, }, ] ) self.env.ref("website_sale.products_add_to_cart").active = True # Ensure website lang is en_US. website = self.env["website"].get_current_website() wiz = self.env["base.language.install"].create({"lang": "en_US"}) wiz.website_ids = website wiz.lang_install() website.default_lang_id = self.env.ref("base.lang_en") def test_ui_website(self): """Test frontend tour.""" tour = ( "odoo.__DEBUG__.services['web_tour.tour']", "website_sale_stock_list_preview", ) self.browser_js( url_path="/shop", code="%s.run('%s')" % tour, ready="%s.tours['%s'].ready" % tour, login="admin", )
34.542373
4,076
1,902
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Carlos Roca # Copyright 2020 Tecnativa - Carlos Dauden # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import http from odoo.http import request from odoo.addons.sale.controllers.variant import VariantController class WebsiteSaleVariantController(VariantController): @http.route( ["/sale/get_combination_info_stock_preview"], type="json", auth="public", website=True, ) def get_combination_info_stock_preview(self, product_template_ids, **kw): """Special route to use website logic in get_combination_info override. This route is called in JS by appending _website to the base route. """ current_website = request.env["website"].get_current_website() res = [] templates = ( request.env["product.template"] .sudo() .with_context( warehouse=current_website.sudo().warehouse_id.id, website_sale_stock_available=True, ) .browse(product_template_ids) ) for template in templates.filtered(lambda t: t.is_published): variants = template.product_variant_ids res.append( { "product_template": template.id, "product_type": template.type, "free_qty": sum(variants.mapped("free_qty")), "cart_qty": sum(variants.mapped("cart_qty")), "out_of_stock_message": template.out_of_stock_message, "allow_out_of_stock_order": template.allow_out_of_stock_order, "show_availability": template.show_availability, "available_threshold": template.available_threshold, "uom_name": template.uom_name, } ) return res
39.625
1,902
416
py
PYTHON
15.0
# 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; """ )
26
416
1,251
py
PYTHON
15.0
# 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": "15.0.1.1.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" ], }, }
37.909091
1,251
1,686
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests.common import HttpCase class WebsiteSaleSecondaryUnitHttpCase(HttpCase): def setUp(self): super().setUp() # Models ProductSecondaryUnit = self.env["product.secondary.unit"] product_uom_unit = self.env.ref("uom.product_uom_unit") self.product_template = self.env["product.template"].create( { "name": "Test product", "is_published": True, "website_sequence": 1, "type": "consu", } ) vals = { "name": "Box", "uom_id": product_uom_unit.id, "factor": 5.0, "product_tmpl_id": self.product_template.id, "website_published": True, } self.secondary_unit_box_5 = ProductSecondaryUnit.create(vals) self.secondary_unit_box_10 = ProductSecondaryUnit.create( dict(vals, factor=10.0) ) self.product_template.write( { "secondary_uom_ids": [ ( 6, 0, [self.secondary_unit_box_5.id, self.secondary_unit_box_10.id], ), ], } ) # Add group "Manage Multiple Units of Measure" to admin admin = self.env.ref("base.user_admin") admin.groups_id |= self.browse_ref("uom.group_uom") def test_ui_website(self): """Test frontend tour.""" self.start_tour("/shop", "website_sale_secondary_unit", login="admin")
35.125
1,686
5,187
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import api, models from odoo.http import request from odoo.tools.float_utils import float_round class SaleOrder(models.Model): _inherit = "sale.order" def _cart_find_product_line(self, product_id=None, line_id=None, **kwargs): """ Search sale order lines with secondary units """ so_lines = super()._cart_find_product_line( product_id=product_id, line_id=line_id, **kwargs ) if so_lines: if line_id: sol = self.env["sale.order.line"].browse(line_id) secondary_uom_id = sol.secondary_uom_id.id else: secondary_uom_id = self.env.context.get("secondary_uom_id", False) so_lines = so_lines.filtered( lambda x: x.secondary_uom_id.id == secondary_uom_id ) return so_lines def _website_product_id_change(self, order_id, product_id, qty=0, **kwargs): res = super()._website_product_id_change( order_id, product_id, qty=qty, **kwargs ) secondary_uom_id = self.env.context.get("secondary_uom_id", False) res["secondary_uom_id"] = secondary_uom_id return res def _cart_update( self, product_id=None, line_id=None, add_qty=0, set_qty=0, attributes=None, **kwargs ): if line_id: sol = self.env["sale.order.line"].browse(line_id) secondary_uom_id = sol.secondary_uom_id.id else: secondary_uom_id = request.session.get("secondary_uom_id", False) self.env.context.copy() if not secondary_uom_id: # Check the default value for secondary uom or is a product can # not allow to sell in base unit, so the default secondary uom # will be the first secondary uom record. product = self.env["product.product"].browse(product_id) if not product.allow_uom_sell: secondary_uom = ( product.sale_secondary_uom_id or product.secondary_uom_ids[:1] ) if secondary_uom and add_qty: add_qty = float_round( float(add_qty) * secondary_uom.factor, precision_rounding=secondary_uom.uom_id.rounding, ) secondary_uom_id = secondary_uom.id return super( SaleOrder, self.with_context(secondary_uom_id=secondary_uom_id) )._cart_update( product_id=product_id, line_id=line_id, add_qty=add_qty, set_qty=set_qty, attributes=attributes, **kwargs ) def _compute_cart_info(self): res = super()._compute_cart_info() for order in self: secondary_unit_lines = order.website_order_line.filtered("secondary_uom_id") if secondary_unit_lines: cart_secondary_quantity = int( sum(secondary_unit_lines.mapped("secondary_uom_qty")) ) so_lines = order.website_order_line - secondary_unit_lines cart_quantity = int(sum(so_lines.mapped("product_uom_qty"))) order.cart_quantity = cart_quantity + cart_secondary_quantity return res class SaleOrderLine(models.Model): _inherit = "sale.order.line" @api.model_create_multi def create(self, vals_list): SecondaryUom = self.env["product.secondary.unit"] Uom = self.env["uom.uom"] for vals in vals_list: secondary_uom = SecondaryUom.browse(vals.get("secondary_uom_id", False)) uom = Uom.browse(vals.get("product_uom", False)) if secondary_uom: factor = secondary_uom.factor * (uom.factor or 1.0) vals["secondary_uom_qty"] = float_round( vals["product_uom_qty"] / (factor or 1.0), precision_rounding=secondary_uom.uom_id.rounding, ) return super().create(vals_list) def write(self, vals): SecondaryUom = self.env["product.secondary.unit"] Uom = self.env["uom.uom"] for line in self: secondary_uom = ( "secondary_uom_id" in vals and SecondaryUom.browse(vals["secondary_uom_id"]) or line.secondary_uom_id ) uom = ( "product_uom" in vals and Uom.browse(vals["product_uom"]) or line.product_uom ) if ( "product_uom_qty" in vals and secondary_uom and secondary_uom.dependency_type == "dependent" ): factor = secondary_uom.factor * uom.factor vals["secondary_uom_qty"] = float_round( vals["product_uom_qty"] / (factor or 1.0), precision_rounding=secondary_uom.uom_id.rounding, ) return super().write(vals)
38.708955
5,187
339
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import fields, models class ProductSecondaryUnit(models.Model): _inherit = ["product.secondary.unit", "website.published.mixin"] _name = "product.secondary.unit" is_published = fields.Boolean(default=True)
33.9
339
330
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Sergio Teruel # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import fields, models class ProductTemplate(models.Model): _inherit = "product.template" allow_uom_sell = fields.Boolean( string="Allow to sell in unit of measure", default=True, )
27.5
330
1,929
py
PYTHON
15.0
# 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
40.1875
1,929
578
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website Sale Stock Available", "summary": "Display 'Available to promise' in shop online instead " "of 'Free To Use Quantity'", "version": "15.0.1.0.0", "category": "Website", "website": "https://github.com/OCA/e-commerce", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "depends": [ "stock_available", "website_sale_stock", ], "data": [], "installable": True, }
32.111111
578
3,494
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo.tests.common import TransactionCase class SaleStockAvailableInfoPopup(TransactionCase): @classmethod def setUpClass(cls): super(SaleStockAvailableInfoPopup, cls).setUpClass() user_group_stock_user = cls.env.ref("stock.group_stock_user") cls.user_stock_user = cls.env["res.users"].create( { "name": "Pauline Poivraisselle", "login": "pauline", "email": "[email protected]", "notification_type": "inbox", "groups_id": [(6, 0, [user_group_stock_user.id])], } ) cls.product = cls.env["product.product"].create( { "name": "Storable product", "type": "product", } ) cls.stock_location = cls.env.ref("stock.stock_location_stock") cls.customers_location = cls.env.ref("stock.stock_location_customers") cls.suppliers_location = cls.env.ref("stock.stock_location_suppliers") cls.env["stock.quant"].create( { "product_id": cls.product.id, "location_id": cls.stock_location.id, "quantity": 40.0, } ) cls.picking_out = cls.env["stock.picking"].create( { "picking_type_id": cls.env.ref("stock.picking_type_out").id, "location_id": cls.stock_location.id, "location_dest_id": cls.customers_location.id, } ) cls.env["stock.move"].create( { "name": "a move", "product_id": cls.product.id, "product_uom_qty": 3.0, "product_uom": cls.product.uom_id.id, "picking_id": cls.picking_out.id, "location_id": cls.stock_location.id, "location_dest_id": cls.customers_location.id, } ) cls.picking_in = cls.env["stock.picking"].create( { "picking_type_id": cls.env.ref("stock.picking_type_in").id, "location_id": cls.suppliers_location.id, "location_dest_id": cls.stock_location.id, } ) cls.env["stock.move"].create( { "restrict_partner_id": cls.user_stock_user.partner_id.id, "name": "another move", "product_id": cls.product.id, "product_uom_qty": 5.0, "product_uom": cls.product.uom_id.id, "picking_id": cls.picking_in.id, "location_id": cls.suppliers_location.id, "location_dest_id": cls.stock_location.id, } ) def test_get_combination_info(self): product_tmpl = self.product.product_tmpl_id combination_info = product_tmpl.with_context( website_sale_stock_get_quantity=True, )._get_combination_info() self.assertEqual( combination_info["free_qty"], 40, ) self.picking_out.action_confirm() self.picking_in.action_assign() combination_info = product_tmpl.with_context( website_sale_stock_get_quantity=True, )._get_combination_info() self.assertEqual( combination_info["free_qty"], self.product.immediately_usable_qty )
38.395604
3,494
493
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import models class SaleOrder(models.Model): _inherit = "sale.order" def _cart_update( self, product_id=None, line_id=None, add_qty=0, set_qty=0, **kwargs ): order = self.with_context(website_sale_stock_available=True) return super(SaleOrder, order)._cart_update( product_id, line_id, add_qty, set_qty, **kwargs )
30.8125
493
724
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Ernesto Tejeda # 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_combination_info( self, combination=False, product_id=False, add_qty=1, pricelist=False, parent_combination=False, only_template=False, ): template = self.with_context(website_sale_stock_available=True) return super(ProductTemplate, template)._get_combination_info( combination, product_id, add_qty, pricelist, parent_combination, only_template, )
26.814815
724
718
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Ernesto Tejeda # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import models class Product(models.Model): _inherit = "product.product" def _compute_quantities_dict( self, lot_id, owner_id, package_id, from_date=False, to_date=False ): res = super()._compute_quantities_dict( lot_id, owner_id, package_id, from_date, to_date ) if self.env.context.get("website_sale_stock_available"): for product in self.with_context(website_sale_stock_available=False): immediately = product.immediately_usable_qty res[product.id]["free_qty"] = immediately return res
35.9
718
573
py
PYTHON
15.0
# Copyright 2020 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo.http import request, route from odoo.addons.website_sale_stock.controllers.main import PaymentPortal class PaymentPortal(PaymentPortal): @route() def shop_payment_transaction(self, *args, **kwargs): """Inject a context when potencial or promised stock is set""" request.website = request.website.with_context( website_sale_stock_available=True ) return super().shop_payment_transaction(*args, **kwargs)
38.2
573
702
py
PYTHON
15.0
# Copyright 2021 Tecnativa - Carlos Roca # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). { "name": "Website Sale Wishlist Keep", "category": "Website", "summary": 'Allows to add products to my cart but keep it in my wishlist"', "development_status": "Production/Stable", "version": "15.0.1.0.0", "license": "LGPL-3", "depends": ["website_sale_wishlist"], "website": "https://github.com/OCA/e-commerce", "data": ["views/website_sale_wishlist_template.xml"], "author": "Tecnativa, Odoo Community Association (OCA)", "installable": True, "assets": { "web.assets_tests": ["/website_sale_wishlist_keep/static/src/js/tour.js"] }, }
39
702
691
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Carlos Roca # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo.tests.common import HttpCase class TestUi(HttpCase): def setUp(self): super().setUp() self.env["product.template"].create( { "name": "Test Product", "website_published": True, "website_sequence": 5000, "type": "consu", } ) self.env.ref("website_sale_wishlist_keep.default_active_b2b_wish").active = True def test_ui_wishlist(self): """Test frontend tour.""" self.start_tour("/shop", "website_sale_wishlist_keep", login="admin")
32.904762
691
1,031
py
PYTHON
15.0
# Copyright 2019 Tecnativa - Alexandre D. Díaz # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "Website Sale Product Detail Attribute Value Image", "summary": "Display attributes values images in shop product detail", "version": "15.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"], "data": [ "views/product_attribute_value_views.xml", "templates/shop_product.xml", ], "assets": { "web.assets_frontend": [ "/website_sale_product_detail_attribute_value_image/static/src/scss/style.scss" ], "web.assets_tests": [ "/website_sale_product_detail_attribute_value_image/static/src/js/" "website_sale_product_detail_attribute_value_image_tour.js", ], }, }
36.785714
1,030
3,846
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Alexandre D. Díaz # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). import odoo.tests @odoo.tests.tagged("post_install", "-at_install") class WebsiteSaleHttpCase(odoo.tests.HttpCase): def setUp(self): super().setUp() self.ProductAttribute = self.env["product.attribute"] self.ProductAttributeValue = self.env["product.attribute.value"] self.ProductAttributeLine = self.env["product.template.attribute.line"] attribute_dangerous = self.ProductAttribute.create( {"name": "Dangerousness", "create_variant": "no_variant"} ) product_attribute_image_high = self.ProductAttributeValue.create( { "name": "High dangerousness", "attribute_id": attribute_dangerous.id, "website_product_detail_image_published": False, "website_product_detail_image": ( "R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" ), } ) self.ProductAttributeValue.create( {"name": "Low dangerousness", "attribute_id": attribute_dangerous.id} ) self.product_template = self.env.ref( "product.product_product_4_product_template" ) attribute_line = self.ProductAttributeLine.create( { "product_tmpl_id": self.product_template.id, "attribute_id": attribute_dangerous.id, "value_ids": [(6, 0, product_attribute_image_high.ids)], } ) self.product_template.write({"attribute_line_ids": [(4, attribute_line.id)]}) attribute_image_policy_one = self.ProductAttribute.create( {"name": "Policy One", "create_variant": "no_variant"} ) value_image_policy_one_1 = self.ProductAttributeValue.create( { "name": "Policy One Value 1", "website_name": "Policy One Value 1 for website", "attribute_id": attribute_image_policy_one.id, "website_product_detail_image_published": True, "website_product_detail_image": ( "R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" ), } ) attribute_line = self.ProductAttributeLine.create( { "product_tmpl_id": self.product_template.id, "attribute_id": attribute_image_policy_one.id, "value_ids": [(6, 0, value_image_policy_one_1.ids)], } ) self.product_template.write({"attribute_line_ids": [(4, attribute_line.id)]}) attribute_image_policy_two = self.ProductAttribute.create( {"name": "Policy Two", "create_variant": "no_variant"} ) value_image_policy_two_1 = self.ProductAttributeValue.create( { "name": "Policy Two Value 1", "attribute_id": attribute_image_policy_two.id, "website_product_detail_image_published": True, "website_product_detail_image": ( "R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" ), } ) attribute_line = self.ProductAttributeLine.create( { "product_tmpl_id": self.product_template.id, "attribute_id": attribute_image_policy_two.id, "value_ids": [(6, 0, value_image_policy_two_1.ids)], } ) self.product_template.write({"attribute_line_ids": [(4, attribute_line.id)]}) def test_ui_website(self): """Test frontend tour.""" self.start_tour( "/shop", "website_sale_product_detail_attribute_value_image", login="admin" )
42.722222
3,845
669
py
PYTHON
15.0
# Copyright 2020 Tecnativa - Alexandre D. Díaz # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from odoo import fields, models class ProductAttributeValue(models.Model): _inherit = "product.attribute.value" website_product_detail_image = fields.Binary( string="Website detail image", attachment=True, help="Image of the attribute value for shop online product detail.", ) website_product_detail_image_published = fields.Boolean( string="Publish detail image in website", help="Display attribute value image in shop online product detail", ) website_name = fields.Char(translate=True)
37.111111
668
475
py
PYTHON
15.0
# Copyright (C) 2020 Alexandre Díaz - Tecnativa S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import SUPERUSER_ID, api from odoo.tools import config def post_init_hook(cr, registry): if config["test_enable"] or config["test_file"]: env = api.Environment(cr, SUPERUSER_ID, {}) env.ref("website_sale_require_login.cart").active = False env.ref("website_sale_require_login.short_cart_summary").active = False
43.090909
474
740
py
PYTHON
15.0
# Copyright 2015 Antiun Ingeniería, S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Require login to checkout", "summary": "Force users to login for buying", "version": "15.0.1.0.1", "category": "Website", "website": "https://github.com/OCA/e-commerce", "author": "Tecnativa, " "LasLabs, " "Odoo Community Association (OCA)", "license": "AGPL-3", "installable": True, "depends": ["website_sale_suggest_create_account", "web_tour"], "data": ["views/website_sale.xml"], "assets": { "web.assets_tests": [ "website_sale_require_login/static/tests/tours/checkout.js", ], }, "post_init_hook": "post_init_hook", }
36.95
739
613
py
PYTHON
15.0
# Copyright (C) 2020 Alexandre Díaz - Tecnativa S.L. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). import odoo.tests @odoo.tests.tagged("post_install", "-at_install") class TestUi(odoo.tests.HttpCase): def test_01_shop_buy(self): current_website = self.env["website"].get_current_website() current_website.auth_signup_uninvited = "b2b" self.env.ref("website_sale_require_login.cart").active = True self.env.ref("website_sale_require_login.short_cart_summary").active = True self.start_tour("/shop", "shop_buy_checkout_required_login_website")
47.076923
612
362
py
PYTHON
15.0
# Copyright 2015 Antiun Ingeniería, S.L. - Jairo Llopis # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import http from odoo.addons.website_sale.controllers.main import WebsiteSale class RequireLoginToCheckout(WebsiteSale): @http.route(auth="user") def checkout(self, **post): return super().checkout(**post)
30.083333
361
1,146
py
PYTHON
15.0
# Copyright 2021 Tecnativa - Carlos Roca # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). { "name": "eCommerce product assortment", "summary": "Use product assortments to display products available on e-commerce.", "version": "15.0.1.0.0", "development_status": "Beta", "license": "AGPL-3", "category": "Website", "website": "https://github.com/OCA/e-commerce", "author": "Tecnativa, Odoo Community Association (OCA)", "maintainers": ["CarlosRoca13"], "installable": True, "depends": ["product_assortment", "website_sale"], "data": ["views/ir_filters_views.xml"], "assets": { "web.assets_frontend": [ "website_sale_product_assortment/static/src/js/variant_mixin.js", "website_sale_product_assortment/static/src/js/assortment_list_preview.js", ], "web.assets_tests": [ "website_sale_product_assortment/static/src/js/no_purchase_tour.js", "website_sale_product_assortment/static/src/js/no_restriction_tour.js", "website_sale_product_assortment/static/src/js/no_show_tour.js", ], }, }
42.444444
1,146