Initial commit: OCA Technical packages (595 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:03 +02:00
commit 2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions

View file

@ -0,0 +1,3 @@
from . import pos_config
from . import pos_order
from . import res_config_settings

View file

@ -0,0 +1,16 @@
# Copyright 2018 - Today Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class PosConfig(models.Model):
_inherit = "pos.config"
picking_creation_delayed = fields.Boolean(
default=True,
help="Check this box if you want to delay the creation of the picking"
" created by the PoS orders. If checked, the pickings will"
" be created later, by a cron task.",
)

View file

@ -0,0 +1,62 @@
# Copyright 2018 - Today Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class PosOrder(models.Model):
_inherit = "pos.order"
has_picking_delayed = fields.Boolean(
default=False,
help="This checkbox is checked if the generation of"
" the picking has been delayed. The picking will be created by cron.",
)
# Overload Section
@api.model
def create_from_ui(self, orders, draft=False):
PosSession = self.env["pos.session"]
for order_data in orders:
session_id = order_data.get("data").get("pos_session_id")
session = PosSession.browse(session_id)
order_data["data"]["has_picking_delayed"] = (
session.config_id.picking_creation_delayed
and not session.update_stock_at_closing
)
return super(PosOrder, self.with_context(create_from_ui=True)).create_from_ui(
orders, draft=draft
)
@api.model
def _delayed_picking_job_kwargs(self):
return {}
def _create_order_picking(self):
if self.env.context.get("create_from_ui", False):
orders = self.filtered(lambda x: not x.has_picking_delayed)
delayed_orders = self.filtered(lambda x: x.has_picking_delayed)
if delayed_orders:
kw = self._delayed_picking_job_kwargs()
delayed_orders.with_delay(**kw)._create_delayed_picking()
else:
orders = self
if not orders:
return
super(PosOrder, orders)._create_order_picking()
orders.write({"has_picking_delayed": False})
@api.model
def _order_fields(self, ui_order):
res = super(PosOrder, self)._order_fields(ui_order)
res["has_picking_delayed"] = ui_order["has_picking_delayed"]
return res
# Custom Section
def _create_delayed_picking(self): # pylint: disable=missing-return
# make the function idempotent
orders = self.filtered(lambda x: x.has_picking_delayed)
super(PosOrder, orders)._create_order_picking()
orders.write({"has_picking_delayed": False})

View file

@ -0,0 +1,13 @@
# Copyright 2024 Eugene Molotov (https://github.com/em230418)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
picking_creation_delayed = fields.Boolean(
related="pos_config_id.picking_creation_delayed", readonly=False
)