A co-op can run the plain shop on one website and the group orders on another, but routes are registered process-wide: every /eskaera page answered on every website of the database, and Odoo had already copied the Eskaera menu to all of them. `website.eskaera_enabled` decides which websites serve it, on by default so installing changes nothing. It reaches the settings screen through `website_id`, so it follows the website selector there. Where it is off the routes raise NotFound and the menu is hidden. The menu is hidden rather than deleted, by extending `_compute_visible`. That keeps the record and any manual rename or reordering, so switching the feature back on restores it as it was. Note that a JSON route reports the 404 inside the JSON-RPC payload and still answers HTTP 200; that is the transport, not a hole in the guard, and a test pins it so the next reader does not take it for one. The three remaining settings (lazy loading, products per page, low stock threshold) are still `config_parameter`, so they stay global to the database. Two websites share their values. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
from odoo import fields
|
|
from odoo import models
|
|
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
|
|
|
|
|
|
class ResConfigSettings(models.TransientModel):
|
|
_inherit = "res.config.settings"
|
|
|
|
# Per website: a co-op can run the plain shop on one and Eskaera on
|
|
# another. The settings below are still global to the database.
|
|
eskaera_enabled = fields.Boolean(
|
|
related="website_id.eskaera_enabled",
|
|
readonly=False,
|
|
)
|
|
|
|
eskaera_lazy_loading_enabled = fields.Boolean(
|
|
string="Enable Lazy Loading",
|
|
config_parameter="website_sale_aplicoop.lazy_loading_enabled",
|
|
default=True,
|
|
help="Enable lazy loading of products in group order shop. Products will be paginated.",
|
|
)
|
|
|
|
eskaera_products_per_page = fields.Integer(
|
|
string="Products Per Page",
|
|
config_parameter="website_sale_aplicoop.products_per_page",
|
|
default=20,
|
|
help="Number of products to load per page in group order shop. Minimum 5, Maximum 100.",
|
|
)
|
|
|
|
low_stock_threshold = fields.Float(
|
|
string="Low Stock Threshold",
|
|
config_parameter="website_sale_aplicoop.low_stock_threshold",
|
|
default=5.0,
|
|
help="Products with stock below or equal to this value will show 'Low Stock' ribbon. "
|
|
"Products with stock = 0 will show 'Out of Stock' ribbon and cannot be added to cart.",
|
|
)
|