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,2 @@
from . import product_template
from . import product_product

View File

@@ -0,0 +1,31 @@
# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class ProductProduct(models.Model):
_inherit = "product.product"
sale_lines_count = fields.Integer(compute="_compute_sale_lines_count")
def _compute_sale_lines_count(self):
if (
not self.env.user.has_group("sales_team.group_sale_salesman")
or not self.ids
):
self.sale_lines_count = 0.0
return
domain = [
("state", "in", ["sale", "done"]),
("product_id", "in", self.ids),
("company_id", "in", self.env.companies.ids),
]
sale_line_data = self.env["sale.order.line"].read_group(
domain, ["product_id"], ["product_id"]
)
mapped_data = {
m["product_id"][0]: m["product_id_count"] for m in sale_line_data
}
for product in self:
product.sale_lines_count = mapped_data.get(product.id, 0)

View File

@@ -0,0 +1,18 @@
# Copyright 2022 ForgeFlow S.L. (https://www.forgeflow.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class ProductTemplate(models.Model):
_inherit = "product.template"
sale_lines_count = fields.Float(compute="_compute_sale_lines_count")
@api.depends("product_variant_ids.sale_lines_count")
def _compute_sale_lines_count(self):
for product in self:
product.sale_lines_count = sum(
p.sale_lines_count
for p in product.with_context(active_test=False).product_variant_ids
)