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,6 @@
from . import sale_order_line
from . import stock_move
from . import sale_order
from . import stock_picking
from . import res_company
from . import res_config_settings

View File

@@ -0,0 +1,34 @@
# Copyright (C) 2021-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 api, fields, models
class ResCompany(models.Model):
_inherit = "res.company"
@api.model
def _default_sale_invoicing_policy(self):
# In order to avoid errors in the CI tests environment when Created
# Invoice from Sale Order using sale.advance.payment.inv object
# is necessary let default policy as sale_order
# TODO: Is there other form to avoid this problem?
result = "stock_picking"
module_base = self.env["ir.module.module"].search([("name", "=", "base")])
if module_base.demo:
result = "sale_order"
return result
sale_invoicing_policy = fields.Selection(
selection=[
("sale_order", "Sale Order"),
("stock_picking", "Stock Picking"),
],
help="If set to Sale Order, keep native Odoo behaviour for creation of"
" invoices from Sale Orders.\n"
"If set to Stock Picking, disallow creation of Invoices from Sale Orders"
" for the cases where Product Type are 'Product', in case of 'Service'"
" still will be possible create from Sale Order.",
default=_default_sale_invoicing_policy,
)

View File

@@ -0,0 +1,13 @@
# Copyright (C) 2021-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 fields, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
sale_invoicing_policy = fields.Selection(
related="company_id.sale_invoicing_policy", readonly=False
)

View File

@@ -0,0 +1,37 @@
# 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

View File

@@ -0,0 +1,18 @@
# Copyright (C) 2013-Today - Akretion (<http://www.akretion.com>).
# @author Renato Lima <renato.lima@akretion.com.br>
# @author Raphael Valyi <raphael.valyi@akretion.com>
# @author Magno Costa <magno.costa@akretion.com.br>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
def _prepare_procurement_values(self, group_id=False):
values = super()._prepare_procurement_values(group_id)
if self.order_id.company_id.sale_invoicing_policy == "stock_picking":
values["invoice_state"] = "2binvoiced"
return values

View File

@@ -0,0 +1,29 @@
# Copyright (C) 2020-TODAY KMEE
# @author Gabriel Cardoso de Faria <gabriel.cardoso@kmee.com.br>
# Copyright (C) 2021-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 fields, models
class StockMove(models.Model):
_inherit = "stock.move"
def _get_price_unit_invoice(self, inv_type, partner, qty=1):
result = super()._get_price_unit_invoice(inv_type, partner, qty)
move = fields.first(self)
if move.sale_line_id and move.sale_line_id.price_unit != result:
result = move.sale_line_id.price_unit
return result
def _get_new_picking_values(self):
values = super()._get_new_picking_values()
move = fields.first(self)
if move.sale_line_id:
company = move.sale_line_id.order_id.company_id
if company.sale_invoicing_policy == "stock_picking":
values["invoice_state"] = "2binvoiced"
return values

View File

@@ -0,0 +1,16 @@
# Copyright (C) 2021-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
class StockPicking(models.Model):
_inherit = "stock.picking"
def _get_partner_to_invoice(self):
partner_id = super()._get_partner_to_invoice()
if self.sale_id:
partner_id = self.sale_id.partner_invoice_id.id
return partner_id