Initial commit: Sale packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:49 +02:00
commit 14e3d26998
6469 changed files with 2479670 additions and 0 deletions

View file

@ -0,0 +1,5 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import ir_cron_trigger
from . import product
from . import res_config_settings

View file

@ -0,0 +1,41 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import _, api, models
from odoo.exceptions import ValidationError
class IrCronTrigger(models.Model):
_inherit = 'ir.cron.trigger'
@api.constrains('cron_id')
def _check_image_cron_is_not_already_triggered(self):
""" Ensure that there is a maximum of one trigger at a time for `ir_cron_fetch_image`.
This cron is triggered in an optimal way to retrieve fastly the images without blocking a
worker for a long amount of time. It fetches images in multiples batches to allow other
crons to run in between. The cron also schedules itself if there are remaining products to
be processed or if it encounters errors like a rate limit reached, a ConnectionTimeout, or
service unavailable. Multiple triggers at the same will trouble the rate limit management
and/or errors handling. More information in `product_fetch_image_wizard.py`.
:return: None
:raise ValidationError: If the maximum number of coexisting triggers for
`ir_cron_fetch_image` is reached
"""
ir_cron_fetch_image = self.env.ref(
'product_images.ir_cron_fetch_image', raise_if_not_found=False
)
if ir_cron_fetch_image and self.cron_id.id != ir_cron_fetch_image.id:
return
cron_triggers_count = self.env['ir.cron.trigger'].search_count(
[('cron_id', '=', ir_cron_fetch_image.id)]
)
# When the cron is automatically triggered, we must allow two triggers to exists at the same
# time: the one that triggered the cron and the one that will schedule another cron run. We
# check whether the cron was automatically triggered rather than manually triggered to cover
# the case where the admin would create an ir.cron.trigger manually.
max_coexisting_cron_triggers = 2 if self.env.context.get('automatically_triggered') else 1
if cron_triggers_count > max_coexisting_cron_triggers:
raise ValidationError(_("This action is already scheduled. Please try again later."))

View file

@ -0,0 +1,11 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class ProductProduct(models.Model):
_inherit = "product.product"
image_fetch_pending = fields.Boolean(
help="Whether an image must be fetched for this product. Handled by a cron.",
)

View file

@ -0,0 +1,16 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
google_custom_search_key = fields.Char(
string="Google Custom Search API Key",
config_parameter='google.custom_search.key',
)
google_pse_id = fields.Char(
string="The identifier of the Google Programmable Search Engine",
config_parameter='google.pse.id',
)