diff --git a/document_page_product/README.rst b/document_page_product/README.rst new file mode 100644 index 00000000000..7484f4c8fc9 --- /dev/null +++ b/document_page_product/README.rst @@ -0,0 +1,97 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +===================== +Document Page Product +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:24bfb08a2814a39d1ce0d895e679d9022656764cd01706ef7e5bf3aed92fb064 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github + :target: https://github.com/OCA/knowledge/tree/19.0/document_page_product + :alt: OCA/knowledge +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/knowledge-19-0/knowledge-19-0-document_page_product + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/knowledge&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allow to link document pages to products. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +- Go to to a product and click on "Wiki Pages" to see linked documents + or to create new ones. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Tecnativa + +Contributors +------------ + +- \`Tecnativa \`: + + - Víctor Martínez + - Pedro M. Baeza + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-victoralmau| image:: https://github.com/victoralmau.png?size=40px + :target: https://github.com/victoralmau + :alt: victoralmau + +Current `maintainer `__: + +|maintainer-victoralmau| + +This module is part of the `OCA/knowledge `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/document_page_product/__init__.py b/document_page_product/__init__.py new file mode 100644 index 00000000000..c32fd62b78d --- /dev/null +++ b/document_page_product/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import models diff --git a/document_page_product/__manifest__.py b/document_page_product/__manifest__.py new file mode 100644 index 00000000000..220ae648b60 --- /dev/null +++ b/document_page_product/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2026 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +{ + "name": "Document Page Product", + "summary": "This module links document pages to products", + "version": "19.0.1.0.0", + "category": "Product", + "author": "Tecnativa, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/knowledge", + "license": "AGPL-3", + "depends": ["product", "document_page"], + "data": [ + "views/document_page_views.xml", + "views/product_product_views.xml", + "views/product_template_views.xml", + ], + "installable": True, + "maintainers": ["victoralmau"], +} diff --git a/document_page_product/i18n/document_page_product.pot b/document_page_product/i18n/document_page_product.pot new file mode 100644 index 00000000000..8f1315f2490 --- /dev/null +++ b/document_page_product/i18n/document_page_product.pot @@ -0,0 +1,68 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_product +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: document_page_product +#: model_terms:ir.actions.act_window,help:document_page_product.action_document_page_products +msgid "Click to create a new web page." +msgstr "" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_document_page +msgid "Document Page" +msgstr "" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_product_product__document_page_count +#: model:ir.model.fields,field_description:document_page_product.field_product_template__document_page_count +msgid "Document Page Count" +msgstr "" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_product_product__document_page_ids +#: model:ir.model.fields,field_description:document_page_product.field_product_template__document_page_ids +msgid "Document Pages" +msgstr "" + +#. module: document_page_product +#: model:ir.actions.act_window,name:document_page_product.action_document_page_products +#: model_terms:ir.ui.view,arch_db:document_page_product.product_normal_form_view +#: model_terms:ir.ui.view,arch_db:document_page_product.product_template_only_form_view +msgid "Knowledge" +msgstr "" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_product_template +msgid "Product" +msgstr "" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_document_page__product_template_count +msgid "Product Template Count" +msgstr "" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_document_page__product_tmpl_ids +msgid "Product Templates" +msgstr "" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: document_page_product +#: model_terms:ir.ui.view,arch_db:document_page_product.view_wiki_form +msgid "Products" +msgstr "" diff --git a/document_page_product/i18n/es.po b/document_page_product/i18n/es.po new file mode 100644 index 00000000000..e6da789bf34 --- /dev/null +++ b/document_page_product/i18n/es.po @@ -0,0 +1,72 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_product +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 17.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2026-04-06 07:49+0000\n" +"PO-Revision-Date: 2026-04-19 09:18+0000\n" +"Last-Translator: Ed-Spain \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: document_page_product +#: model_terms:ir.actions.act_window,help:document_page_product.action_document_page_products +msgid "Click to create a new web page." +msgstr "Click para crear una página web nueva." + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_document_page +msgid "Document Page" +msgstr "Página del documento" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_product_product__document_page_count +#: model:ir.model.fields,field_description:document_page_product.field_product_template__document_page_count +msgid "Document Page Count" +msgstr "Total de páginas de documento" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_product_product__document_page_ids +#: model:ir.model.fields,field_description:document_page_product.field_product_template__document_page_ids +msgid "Document Pages" +msgstr "Páginas de conocimiento" + +#. module: document_page_product +#: model:ir.actions.act_window,name:document_page_product.action_document_page_products +#: model_terms:ir.ui.view,arch_db:document_page_product.product_normal_form_view +#: model_terms:ir.ui.view,arch_db:document_page_product.product_template_only_form_view +msgid "Knowledge" +msgstr "Conocimiento" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_product_template +msgid "Product" +msgstr "Producto" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_document_page__product_template_count +msgid "Product Template Count" +msgstr "Número de plantillas de producto" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_document_page__product_tmpl_ids +msgid "Product Templates" +msgstr "Plantillas de producto" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_product_product +msgid "Product Variant" +msgstr "Variante de producto" + +#. module: document_page_product +#: model_terms:ir.ui.view,arch_db:document_page_product.view_wiki_form +msgid "Products" +msgstr "Productos" diff --git a/document_page_product/i18n/fr.po b/document_page_product/i18n/fr.po new file mode 100644 index 00000000000..3c66b848fa9 --- /dev/null +++ b/document_page_product/i18n/fr.po @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_product +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-06-09 14:32+0000\n" +"Last-Translator: Yann Papouin \n" +"Language-Team: none\n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: document_page_product +#: model_terms:ir.actions.act_window,help:document_page_product.action_document_page_products +msgid "Click to create a new web page." +msgstr "Cliquer pour créer une nouvelle page Web." + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_document_page +msgid "Document Page" +msgstr "Page" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_product_product__document_page_count +#: model:ir.model.fields,field_description:document_page_product.field_product_template__document_page_count +msgid "Document Page Count" +msgstr "Nombre de pages" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_product_product__document_page_ids +#: model:ir.model.fields,field_description:document_page_product.field_product_template__document_page_ids +msgid "Document Pages" +msgstr "Pages" + +#. module: document_page_product +#: model:ir.actions.act_window,name:document_page_product.action_document_page_products +#: model_terms:ir.ui.view,arch_db:document_page_product.product_normal_form_view +#: model_terms:ir.ui.view,arch_db:document_page_product.product_template_only_form_view +msgid "Knowledge" +msgstr "Connaissances" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_product_template +msgid "Product" +msgstr "Article" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_document_page__product_template_count +msgid "Product Template Count" +msgstr "Nombre de modèles de produits" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_document_page__product_tmpl_ids +msgid "Product Templates" +msgstr "Modèles d'article" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_product_product +msgid "Product Variant" +msgstr "Variante d'article" + +#. module: document_page_product +#: model_terms:ir.ui.view,arch_db:document_page_product.view_wiki_form +msgid "Products" +msgstr "Articles" diff --git a/document_page_product/i18n/it.po b/document_page_product/i18n/it.po new file mode 100644 index 00000000000..f823f92fc90 --- /dev/null +++ b/document_page_product/i18n/it.po @@ -0,0 +1,71 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_product +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-04-14 12:45+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: document_page_product +#: model_terms:ir.actions.act_window,help:document_page_product.action_document_page_products +msgid "Click to create a new web page." +msgstr "Fare clic per creare una nuova pagina web." + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_document_page +msgid "Document Page" +msgstr "Pagina documento" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_product_product__document_page_count +#: model:ir.model.fields,field_description:document_page_product.field_product_template__document_page_count +msgid "Document Page Count" +msgstr "Conteggio pagina documento" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_product_product__document_page_ids +#: model:ir.model.fields,field_description:document_page_product.field_product_template__document_page_ids +msgid "Document Pages" +msgstr "Pagine documento" + +#. module: document_page_product +#: model:ir.actions.act_window,name:document_page_product.action_document_page_products +#: model_terms:ir.ui.view,arch_db:document_page_product.product_normal_form_view +#: model_terms:ir.ui.view,arch_db:document_page_product.product_template_only_form_view +msgid "Knowledge" +msgstr "Know how" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_product_template +msgid "Product" +msgstr "Prodotto" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_document_page__product_template_count +msgid "Product Template Count" +msgstr "Conteggio modelli prodotto" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_document_page__product_tmpl_ids +msgid "Product Templates" +msgstr "Modelli prodotto" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_product_product +msgid "Product Variant" +msgstr "Variante prodotto" + +#. module: document_page_product +#: model_terms:ir.ui.view,arch_db:document_page_product.view_wiki_form +msgid "Products" +msgstr "Prodotti" diff --git a/document_page_product/i18n/sl.po b/document_page_product/i18n/sl.po new file mode 100644 index 00000000000..4ef8d69596e --- /dev/null +++ b/document_page_product/i18n/sl.po @@ -0,0 +1,72 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * document_page_product +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 18.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2026-06-07 17:07+0000\n" +"Last-Translator: Matjaz Mozetic \n" +"Language-Team: none\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || " +"n%100==4 ? 2 : 3;\n" +"X-Generator: Weblate 5.15.2\n" + +#. module: document_page_product +#: model_terms:ir.actions.act_window,help:document_page_product.action_document_page_products +msgid "Click to create a new web page." +msgstr "Ustvari novo stran." + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_document_page +msgid "Document Page" +msgstr "Stran dokumenta" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_product_product__document_page_count +#: model:ir.model.fields,field_description:document_page_product.field_product_template__document_page_count +msgid "Document Page Count" +msgstr "Število dokumentov" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_product_product__document_page_ids +#: model:ir.model.fields,field_description:document_page_product.field_product_template__document_page_ids +msgid "Document Pages" +msgstr "Strani dokumentov" + +#. module: document_page_product +#: model:ir.actions.act_window,name:document_page_product.action_document_page_products +#: model_terms:ir.ui.view,arch_db:document_page_product.product_normal_form_view +#: model_terms:ir.ui.view,arch_db:document_page_product.product_template_only_form_view +msgid "Knowledge" +msgstr "Baza znanja" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_product_template +msgid "Product" +msgstr "Proizvod" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_document_page__product_template_count +msgid "Product Template Count" +msgstr "Št. predlog proizvodov" + +#. module: document_page_product +#: model:ir.model.fields,field_description:document_page_product.field_document_page__product_tmpl_ids +msgid "Product Templates" +msgstr "Predloge proizvodov" + +#. module: document_page_product +#: model:ir.model,name:document_page_product.model_product_product +msgid "Product Variant" +msgstr "Različica proizvoda" + +#. module: document_page_product +#: model_terms:ir.ui.view,arch_db:document_page_product.view_wiki_form +msgid "Products" +msgstr "Proizvodi" diff --git a/document_page_product/models/__init__.py b/document_page_product/models/__init__.py new file mode 100644 index 00000000000..76e925f30e9 --- /dev/null +++ b/document_page_product/models/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from . import document_page +from . import product diff --git a/document_page_product/models/document_page.py b/document_page_product/models/document_page.py new file mode 100644 index 00000000000..e3fa2c2a312 --- /dev/null +++ b/document_page_product/models/document_page.py @@ -0,0 +1,31 @@ +# Copyright 2026 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class DocumentPage(models.Model): + _inherit = "document.page" + + product_tmpl_ids = fields.Many2many( + comodel_name="product.template", + relation="document_page_product_rel", + column1="page_id", + column2="product_tmpl_id", + string="Product Templates", + ) + product_template_count = fields.Integer(compute="_compute_product_template_count") + + @api.depends("product_tmpl_ids") + def _compute_product_template_count(self): + for item in self: + item.product_template_count = len(item.product_tmpl_ids) + + def action_product_templates(self): + self.ensure_one() + action = self.env["ir.actions.actions"]._for_xml_id( + "product.product_template_action" + ) + action["domain"] = [("id", "in", self.product_tmpl_ids.ids)] + action["context"] = {} + return action diff --git a/document_page_product/models/product.py b/document_page_product/models/product.py new file mode 100644 index 00000000000..adfebe40639 --- /dev/null +++ b/document_page_product/models/product.py @@ -0,0 +1,48 @@ +# Copyright 2026 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + document_page_ids = fields.Many2many( + comodel_name="document.page", + relation="document_page_product_rel", + column1="product_tmpl_id", + column2="page_id", + string="Document Pages", + ) + document_page_count = fields.Integer(compute="_compute_document_page_count") + + @api.depends("document_page_ids") + def _compute_document_page_count(self): + for rec in self: + rec.document_page_count = len(rec.document_page_ids) + + +class ProductProduct(models.Model): + _inherit = "product.product" + + document_page_count = fields.Integer(compute="_compute_document_page_count") + + @api.depends("product_tmpl_id.document_page_count") + def _compute_document_page_count(self): + for rec in self: + rec.document_page_count = rec.product_tmpl_id.document_page_count + + def action_document_page_products(self): + self.ensure_one() + action = self.env["ir.actions.actions"]._for_xml_id( + "document_page_product.action_document_page_products" + ) + action["domain"] = [ + ("type", "=", "content"), + ("product_tmpl_ids", "in", self.product_tmpl_id.ids), + ] + action["context"] = { + "default_type": "content", + "default_product_tmpl_ids": self.product_tmpl_id.ids, + } + return action diff --git a/document_page_product/pyproject.toml b/document_page_product/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/document_page_product/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/document_page_product/readme/CONTRIBUTORS.md b/document_page_product/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..53764902262 --- /dev/null +++ b/document_page_product/readme/CONTRIBUTORS.md @@ -0,0 +1,3 @@ +- \`Tecnativa \<\>\`: + - Víctor Martínez + - Pedro M. Baeza diff --git a/document_page_product/readme/DESCRIPTION.md b/document_page_product/readme/DESCRIPTION.md new file mode 100644 index 00000000000..706e8e812eb --- /dev/null +++ b/document_page_product/readme/DESCRIPTION.md @@ -0,0 +1 @@ +This module allow to link document pages to products. diff --git a/document_page_product/readme/USAGE.md b/document_page_product/readme/USAGE.md new file mode 100644 index 00000000000..887128294fa --- /dev/null +++ b/document_page_product/readme/USAGE.md @@ -0,0 +1,2 @@ +- Go to to a product and click on "Wiki Pages" to see linked documents + or to create new ones. diff --git a/document_page_product/static/description/icon.png b/document_page_product/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/document_page_product/static/description/icon.png differ diff --git a/document_page_product/static/description/index.html b/document_page_product/static/description/index.html new file mode 100644 index 00000000000..0b12b7120f6 --- /dev/null +++ b/document_page_product/static/description/index.html @@ -0,0 +1,443 @@ + + + + + +README.rst + + + +
+ + + +Odoo Community Association + +
+

Document Page Product

+ +

Beta License: AGPL-3 OCA/knowledge Translate me on Weblate Try me on Runboat

+

This module allow to link document pages to products.

+

Table of contents

+ +
+

Usage

+
    +
  • Go to to a product and click on “Wiki Pages” to see linked documents +or to create new ones.
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

victoralmau

+

This module is part of the OCA/knowledge project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/document_page_product/tests/__init__.py b/document_page_product/tests/__init__.py new file mode 100644 index 00000000000..f416293e396 --- /dev/null +++ b/document_page_product/tests/__init__.py @@ -0,0 +1 @@ +from . import test_document_page_product diff --git a/document_page_product/tests/test_document_page_product.py b/document_page_product/tests/test_document_page_product.py new file mode 100644 index 00000000000..33bac3c4b2c --- /dev/null +++ b/document_page_product/tests/test_document_page_product.py @@ -0,0 +1,47 @@ +# Copyright 2026 Tecnativa - Víctor Martínez +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo import Command + +from odoo.addons.base.tests.common import BaseCommon + + +class TestDesguaceparisCustom(BaseCommon): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.product_a = cls.env["product.product"].create({"name": "Test product A"}) + cls.product_tmpl_a = cls.product_a.product_tmpl_id + cls.product_b = cls.env["product.product"].create({"name": "Test product B"}) + cls.product_tmpl_b = cls.product_b.product_tmpl_id + cls.default_page = cls.env["document.page"].create({"name": "Test page"}) + + def test_page_count(self): + self.assertEqual(self.product_a.document_page_count, 0) + self.assertEqual(self.product_tmpl_a.document_page_count, 0) + self.assertEqual(self.product_b.document_page_count, 0) + self.assertEqual(self.product_tmpl_b.document_page_count, 0) + self.default_page.product_tmpl_ids = [Command.set(self.product_tmpl_a.ids)] + self.assertEqual(self.product_a.document_page_count, 1) + self.assertEqual(self.product_tmpl_a.document_page_count, 1) + self.assertEqual(self.product_b.document_page_count, 0) + self.assertEqual(self.product_tmpl_b.document_page_count, 0) + self.assertIn(self.default_page, self.product_tmpl_a.document_page_ids) + self.assertNotIn(self.default_page, self.product_tmpl_b.document_page_ids) + action = self.product_a.action_document_page_products() + self.assertEqual( + action["domain"], + [ + ("type", "=", "content"), + ("product_tmpl_ids", "in", self.product_tmpl_a.ids), + ], + ) + self.assertEqual( + action["context"], + { + "default_type": "content", + "default_product_tmpl_ids": self.product_tmpl_a.ids, + }, + ) + action = self.default_page.action_product_templates() + self.assertEqual(action["domain"], [("id", "in", self.product_tmpl_a.ids)]) + self.assertEqual(action["context"], {}) diff --git a/document_page_product/views/document_page_views.xml b/document_page_product/views/document_page_views.xml new file mode 100644 index 00000000000..4f179f1f4f1 --- /dev/null +++ b/document_page_product/views/document_page_views.xml @@ -0,0 +1,54 @@ + + + + document.page + + +
+ +
+ + + + +
+ + Knowledge + document.page + [('type','=','content'), ('product_tmpl_ids', 'in', [active_id])] + { + 'default_type': 'content', + 'default_product_tmpl_ids': [active_id]} + list,form + + + +

+ Click to create a new web page. +

+
+
+
diff --git a/document_page_product/views/product_product_views.xml b/document_page_product/views/product_product_views.xml new file mode 100644 index 00000000000..a21ae9cba00 --- /dev/null +++ b/document_page_product/views/product_product_views.xml @@ -0,0 +1,23 @@ + + + + product.product + + +
+ +
+
+
+
diff --git a/document_page_product/views/product_template_views.xml b/document_page_product/views/product_template_views.xml new file mode 100644 index 00000000000..6f35874d6e6 --- /dev/null +++ b/document_page_product/views/product_template_views.xml @@ -0,0 +1,23 @@ + + + + product.template + + +
+ +
+
+
+