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,4 @@
from . import account_move
from . import purchase_order_line
from . import stock_move
from . import purchase_order

View File

@@ -0,0 +1,39 @@
# Copyright 2019 ForgeFlow S.L.
# (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class AccountMoveLine(models.Model):
_inherit = "account.move.line"
# Set related None, to make it compute and avoid base related to purchase_line_id
purchase_order_id = fields.Many2one(
comodel_name="purchase.order",
related=None,
store=True,
index=True,
compute="_compute_purchase_id",
)
oca_purchase_line_id = fields.Many2one(
comodel_name="purchase.order.line",
string="OCA Purchase Line",
store=True,
index=True,
compute="_compute_oca_purchase_line_id",
)
@api.depends("purchase_line_id")
def _compute_oca_purchase_line_id(self):
for rec in self:
if rec.purchase_line_id:
rec.oca_purchase_line_id = rec.purchase_line_id
@api.depends("purchase_line_id", "oca_purchase_line_id")
def _compute_purchase_id(self):
for rec in self:
rec.purchase_order_id = (
rec.purchase_line_id.order_id.id or rec.oca_purchase_line_id.order_id.id
)

View File

@@ -0,0 +1,52 @@
from odoo import api, fields, models
class PurchaseOrder(models.Model):
_inherit = "purchase.order"
@api.depends("order_line.stock_invoice_lines.move_id")
def _compute_journal_entries(self):
for order in self:
journal_entries = order.mapped(
"order_line.stock_invoice_lines.move_id"
).filtered(lambda r: r.move_type == "entry")
order.journal_entry_ids = journal_entries
order.journal_entries_count = len(journal_entries)
journal_entries_count = fields.Integer(compute="_compute_journal_entries")
journal_entry_ids = fields.Many2many(
comodel_name="account.move",
relation="journal_entries_ids_purchase_order",
compute="_compute_journal_entries",
string="Journal Entries",
)
def action_view_journal_entries(self, invoices=False):
"""This function returns an action that display existing journal entries of
given purchase order ids. When only one found, show the journal entry
immediately.
"""
if not invoices:
self.sudo().read(["journal_entry_ids"])
invoices = self.journal_entry_ids
result = self.env["ir.actions.act_window"]._for_xml_id(
"account.action_move_journal_line"
)
# choose the view_mode accordingly
if len(invoices) > 1:
result["domain"] = [("id", "in", invoices.ids)]
elif len(invoices) == 1:
res = self.env.ref("account.view_move_form", False)
form_view = [(res and res.id or False, "form")]
if "views" in result:
result["views"] = form_view + [
(state, view) for state, view in result["views"] if view != "form"
]
else:
result["views"] = form_view
result["res_id"] = invoices.id
else:
result = {"type": "ir.actions.act_window_close"}
return result

View File

@@ -0,0 +1,22 @@
# Copyright 2019-2020 ForgeFlow S.L.
# (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"
stock_invoice_lines = fields.One2many(
"account.move.line", "oca_purchase_line_id", readonly=True, copy=False
)
@api.depends("name", "order_id.name", "order_id.state")
@api.depends_context("po_line_info")
def _compute_display_name(self):
if not self.env.context.get("po_line_info", False):
return super()._compute_display_name()
for line in self:
line.display_name = (
f"[{line.order_id.name}] {line.name} ({line.order_id.state})"
)

View File

@@ -0,0 +1,19 @@
# Copyright 2019 ForgeFlow S.L.
# (https://www.forgeflow.com)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models
class StockMove(models.Model):
_inherit = "stock.move"
def _prepare_account_move_line(
self, qty, cost, credit_account_id, debit_account_id, svl_id, description
):
res = super()._prepare_account_move_line(
qty, cost, credit_account_id, debit_account_id, svl_id, description
)
for line in res:
line[2]["oca_purchase_line_id"] = self.purchase_line_id.id
return res