Initial commit: Odoo 18.0-20251222 extra-addons
Some checks failed
pre-commit / pre-commit (push) Has been cancelled
tests / Detect unreleased dependencies (push) Has been cancelled
tests / test with OCB (push) Has been cancelled
tests / test with Odoo (push) Has been cancelled

This commit is contained in:
tocmo0nlord
2026-03-13 20:43:25 +00:00
parent 36e847a7df
commit adbe430761
9472 changed files with 1265727 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
from . import res_company
from . import res_config_settings
from . import sale_order

View File

@@ -0,0 +1,33 @@
# Copyright 2024 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo import fields, models
class ResCompany(models.Model):
_inherit = "res.company"
sale_line_field_block = fields.Many2one(
comodel_name="ir.model.fields",
string="Field to compare quantities on Sale Order Lines",
help="This field will be checked to block the Sale Order Lines "
"if the quantity is not enough",
domain=[
("model_id.model", "=", "sale.order.line"),
(
"name",
"in",
(
"free_qty_today",
"qty_available_today",
"virtual_available_at_date",
),
),
],
)
sale_line_block_allowed_groups = fields.Many2many(
comodel_name="res.groups",
string="Allowed Groups to bypass the block",
help="These groups will be able to bypass the block on the Sale Order Lines "
"if the quantity is not enough",
)

View File

@@ -0,0 +1,22 @@
# Copyright 2024 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
sale_line_field_block = fields.Many2one(
related="company_id.sale_line_field_block",
help="This field will be checked to block the Sale Order Lines "
"if the quantity is not enough",
readonly=False,
)
sale_line_block_allowed_groups = fields.Many2many(
related="company_id.sale_line_block_allowed_groups",
help="These groups will be able to bypass the block on the Sale Order Lines "
"if the quantity is not enough",
readonly=False,
)

View File

@@ -0,0 +1,41 @@
# Copyright 2024 Moduon Team S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)
from odoo import models
class SaleOrder(models.Model):
_inherit = "sale.order"
def action_confirm(self):
"""Check the stock of the products before confirming the sale order."""
if self.env.context.get("skip_block_no_stock_check") and all(
self.env.user in company.sale_line_block_allowed_groups.users
for company in self.mapped("company_id")
):
return super().action_confirm()
for record in self:
field_to_check = record.sudo().company_id.sale_line_field_block
if not field_to_check:
continue
blocked_lines = self.env["sale.order.line"].browse()
lines = record.order_line.filtered_domain(
[("product_type", "=", "consu"), ("is_storable", "=", True)]
)
for line in lines:
if line.product_uom_qty > line[field_to_check.name]:
blocked_lines |= line
if blocked_lines:
action = self.env["ir.actions.actions"]._for_xml_id(
"sale_block_no_stock.sale_order_block_wizard_action"
)
action["context"] = {
"default_sale_line_block_ids": [
(0, 0, {"sale_line_id": line.id}) for line in blocked_lines
]
}
return action
return super().action_confirm()