Files
Odoo-18.0-20251222/sale_stock_picking_invoicing/models/sale_order.py
tocmo0nlord adbe430761
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
Initial commit: Odoo 18.0-20251222 extra-addons
2026-03-13 20:43:25 +00:00

38 lines
1.3 KiB
Python

# Copyright (C) 2020-TODAY Akretion
# @author Magno Costa <magno.costa@akretion.com.br>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
from odoo.exceptions import UserError
class SaleOrder(models.Model):
_inherit = "sale.order"
def _get_invoiceable_lines(self, final=False):
"""Return the invoiceable lines for order `self`."""
lines = super()._get_invoiceable_lines(final)
model = self.env.context.get("active_model")
if (
self.company_id.sale_invoicing_policy == "stock_picking"
and model != "stock.picking"
):
new_lines = lines.filtered(
lambda ln: not ln.product_id.is_storable and not ln.is_downpayment
)
if new_lines:
# Case lines with Product Type 'service'
lines = new_lines
else:
# Case only Products Type 'product'
raise UserError(
self.env._(
"When 'Sale Invoicing Policy' is defined as"
"'Stock Picking' the Invoice can only be created"
" from the Stock Picking, if necessary you can change"
" in the Company or Sale Settings."
)
)
return lines