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,7 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import sale_order
from . import sale_order_line
from . import sale_stock_picking_blocking_reason
from . import res_partner
from . import account_payment_term

View File

@@ -0,0 +1,16 @@
# Copyright 2024 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class AccountPaymentTerm(models.Model):
_inherit = "account.payment.term"
default_delivery_block_reason_id = fields.Many2one(
comodel_name="sale.delivery.block.reason",
string="Default Delivery Block Reason",
help="Set a reason to block by default the deliveries in this "
"payment term sales orders.",
)

View File

@@ -0,0 +1,22 @@
# Copyright 2024 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class Partner(models.Model):
_inherit = "res.partner"
default_delivery_block = fields.Many2one(
comodel_name="sale.delivery.block.reason",
string="Default Delivery Block Reason",
help="Set a reason to block by default the deliveries in this "
"customer sales orders.",
)
@api.model
def _commercial_fields(self):
commercial_fields = super()._commercial_fields()
commercial_fields.append("default_delivery_block")
return commercial_fields

View File

@@ -0,0 +1,61 @@
# Copyright 2024 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class SaleOrder(models.Model):
_inherit = "sale.order"
delivery_block_id = fields.Many2one(
comodel_name="sale.delivery.block.reason",
tracking=True,
string="Delivery Block Reason",
compute="_compute_delivery_block_id",
store=True,
)
@api.constrains("delivery_block_id")
def _check_not_auto_done(self):
auto_done = self.env.user.has_group("sale.group_auto_done_setting")
if auto_done and any(so.delivery_block_id for so in self):
raise ValidationError(
_('You cannot block a sale order with "auto_done_setting" active.')
)
@api.depends("partner_id", "payment_term_id")
def _compute_delivery_block_id(self):
"""Add the 'Default Delivery Block Reason' if set in the partner
or in the payment term."""
for so in self:
if so.partner_id.default_delivery_block:
so.delivery_block_id = so.partner_id.default_delivery_block
else:
so.delivery_block_id = (
so.payment_term_id.default_delivery_block_reason_id or False
)
def action_remove_delivery_block(self):
"""Remove the delivery block and create procurements as usual."""
order_to_unblock = self.filtered(
lambda so: so.state == "sale" or not so.delivery_block_id
)
order_to_unblock.write({"delivery_block_id": False})
order_to_unblock.order_line._action_launch_stock_rule()
return True
def copy(self, default=None):
new_so = super().copy(default=default)
for so in new_so:
if so.partner_id.default_delivery_block and not so.delivery_block_id:
so.delivery_block_id = so.partner_id.default_delivery_block
elif (
so.payment_term_id.default_delivery_block_reason_id
and not so.delivery_block_id
):
so.delivery_block_id = (
so.payment_term_id.default_delivery_block_reason_id
)
return new_so

View File

@@ -0,0 +1,15 @@
# Copyright 2024 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
def _action_launch_stock_rule(self, previous_product_uom_qty=False):
return super(
SaleOrderLine,
self.filtered(lambda line: not line.order_id.delivery_block_id),
)._action_launch_stock_rule(previous_product_uom_qty=previous_product_uom_qty)

View File

@@ -0,0 +1,19 @@
# Copyright 2024 ForgeFlow S.L.
# (http://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class SaleDeliveryBlockReason(models.Model):
_name = "sale.delivery.block.reason"
_description = "Sale Delivery Block Reason"
name = fields.Char(required=True)
description = fields.Text()
sale_order_ids = fields.One2many(
comodel_name="sale.order",
inverse_name="delivery_block_id",
string="Sale Orders",
readonly=True,
)