# HG changeset patch # User Houzefa Abbasbhay <houzefa.abba@xcg-consulting.fr> # Date 1674660547 -3600 # Wed Jan 25 16:29:07 2023 +0100 # Branch 13.0 # Node ID bc4a32eb10ad712d229fed2017dde115cdb1d432 # Parent 463b620e40e7dc8398901a7dc8dc563aee3ac475 Code formatting, add license / docs / badges diff --git a/.badges/code_style-black-000000.svg b/.badges/code_style-black-000000.svg new file mode 100644 --- /dev/null +++ b/.badges/code_style-black-000000.svg @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<svg xmlns="http://www.w3.org/2000/svg" width="114" height="20"> + <linearGradient id="b" x2="0" y2="100%"> + <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> + <stop offset="1" stop-opacity=".1" /> + </linearGradient> + <mask id="anybadge_1"> + <rect width="114" height="20" rx="3" fill="#fff" /> + </mask> + <g mask="url(#anybadge_1)"> + <path fill="#555" d="M0 0h72v20H0z" /> + <path fill="#000000" d="M72 0h42v20H72z" /> + <path fill="url(#b)" d="M0 0h114v20H0z" /> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="37.0" y="15" fill="#010101" fill-opacity=".3">code style</text> + <text x="36.0" y="14">code style</text> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="94.0" y="15" fill="#010101" fill-opacity=".3">black</text> + <text x="93.0" y="14">black</text> + </g> +</svg> diff --git a/.badges/code_style-prettier-ff69b4.svg b/.badges/code_style-prettier-ff69b4.svg new file mode 100644 --- /dev/null +++ b/.badges/code_style-prettier-ff69b4.svg @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<svg xmlns="http://www.w3.org/2000/svg" width="129" height="20"> + <linearGradient id="b" x2="0" y2="100%"> + <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> + <stop offset="1" stop-opacity=".1" /> + </linearGradient> + <mask id="anybadge_1"> + <rect width="129" height="20" rx="3" fill="#fff" /> + </mask> + <g mask="url(#anybadge_1)"> + <path fill="#555" d="M0 0h72v20H0z" /> + <path fill="#ff69b4" d="M72 0h57v20H72z" /> + <path fill="url(#b)" d="M0 0h129v20H0z" /> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="37.0" y="15" fill="#010101" fill-opacity=".3">code style</text> + <text x="36.0" y="14">code style</text> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="101.5" y="15" fill="#010101" fill-opacity=".3">prettier</text> + <text x="100.5" y="14">prettier</text> + </g> +</svg> diff --git a/.badges/coverage.svg b/.badges/coverage.svg new file mode 100644 --- /dev/null +++ b/.badges/coverage.svg @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<svg xmlns="http://www.w3.org/2000/svg" width="124" height="20"> + <linearGradient id="b" x2="0" y2="100%"> + <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> + <stop offset="1" stop-opacity=".1" /> + </linearGradient> + <mask id="anybadge_1"> + <rect width="124" height="20" rx="3" fill="#fff" /> + </mask> + <g mask="url(#anybadge_1)"> + <path fill="#555" d="M0 0h65v20H0z" /> + <path fill="#808080" d="M65 0h59v20H65z" /> + <path fill="url(#b)" d="M0 0h124v20H0z" /> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="33.5" y="15" fill="#010101" fill-opacity=".3">coverage</text> + <text x="32.5" y="14">coverage</text> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="95.5" y="15" fill="#010101" fill-opacity=".3">unknown</text> + <text x="94.5" y="14">unknown</text> + </g> +</svg> diff --git a/.badges/licence-AGPL--3-blue.svg b/.badges/licence-AGPL--3-blue.svg new file mode 100644 --- /dev/null +++ b/.badges/licence-AGPL--3-blue.svg @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<svg xmlns="http://www.w3.org/2000/svg" width="107" height="20"> + <linearGradient id="b" x2="0" y2="100%"> + <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> + <stop offset="1" stop-opacity=".1" /> + </linearGradient> + <mask id="anybadge_1"> + <rect width="107" height="20" rx="3" fill="#fff" /> + </mask> + <g mask="url(#anybadge_1)"> + <path fill="#555" d="M0 0h53v20H0z" /> + <path fill="#0000FF" d="M53 0h54v20H53z" /> + <path fill="url(#b)" d="M0 0h107v20H0z" /> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="27.5" y="15" fill="#010101" fill-opacity=".3">licence</text> + <text x="26.5" y="14">licence</text> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="81.0" y="15" fill="#010101" fill-opacity=".3">AGPL-3</text> + <text x="80.0" y="14">AGPL-3</text> + </g> +</svg> diff --git a/.badges/maturity.svg b/.badges/maturity.svg new file mode 100644 --- /dev/null +++ b/.badges/maturity.svg @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<svg xmlns="http://www.w3.org/2000/svg" width="103" height="20"> + <linearGradient id="b" x2="0" y2="100%"> + <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> + <stop offset="1" stop-opacity=".1" /> + </linearGradient> + <mask id="anybadge_1"> + <rect width="103" height="20" rx="3" fill="#fff" /> + </mask> + <g mask="url(#anybadge_1)"> + <path fill="#555" d="M0 0h61v20H0z" /> + <path fill="#e05d44" d="M61 0h42v20H61z" /> + <path fill="url(#b)" d="M0 0h103v20H0z" /> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="31.5" y="15" fill="#010101" fill-opacity=".3">maturity</text> + <text x="30.5" y="14">maturity</text> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="83.0" y="15" fill="#010101" fill-opacity=".3">Alpha</text> + <text x="82.0" y="14">Alpha</text> + </g> +</svg> diff --git a/.badges/pylint.svg b/.badges/pylint.svg new file mode 100644 --- /dev/null +++ b/.badges/pylint.svg @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<svg xmlns="http://www.w3.org/2000/svg" width="103" height="20"> + <linearGradient id="b" x2="0" y2="100%"> + <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> + <stop offset="1" stop-opacity=".1" /> + </linearGradient> + <mask id="anybadge_1"> + <rect width="103" height="20" rx="3" fill="#fff" /> + </mask> + <g mask="url(#anybadge_1)"> + <path fill="#555" d="M0 0h44v20H0z" /> + <path fill="#808080" d="M44 0h59v20H44z" /> + <path fill="url(#b)" d="M0 0h103v20H0z" /> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="23.0" y="15" fill="#010101" fill-opacity=".3">pylint</text> + <text x="22.0" y="14">pylint</text> + </g> + <g + fill="#fff" + text-anchor="middle" + font-family="DejaVu Sans,Verdana,Geneva,sans-serif" + font-size="11" + > + <text x="74.5" y="15" fill="#010101" fill-opacity=".3">unknown</text> + <text x="73.5" y="14">unknown</text> + </g> +</svg> diff --git a/.editorconfig b/.editorconfig --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,5 @@ # Configuration for known file extensions -[*.{css,js,json,less,md,py,rst,sass,scss,xml,yaml,yml}] +[*.{css,htm,html,js,json,jsx,less,markdown,md,py,rst,sass,scss,toml,xml,yaml,yml}] charset = utf-8 end_of_line = lf indent_size = 4 @@ -7,11 +7,11 @@ insert_final_newline = true trim_trailing_whitespace = true -[*.{json,yml,yaml,rst,md}] +[*.{json,yml,yaml,rst,markdown,md,toml}] indent_size = 2 -# Do not configure editor for libs and autogenerated content -[{*/static/{lib,src/lib}/**,*/static/description/index.html,*/readme/../README.rst}] +# Do not configure editor for libs +[{*/static/{lib,src/lib}/**}] charset = unset end_of_line = unset indent_size = unset diff --git a/.flake8 b/.flake8 new file mode 100644 --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +per-file-ignores= + __init__.py:F401 diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,4 @@ +rules: + document-start: disable + indentation: + indent-sequences: true diff --git a/NEWS.rst b/NEWS.rst --- a/NEWS.rst +++ b/NEWS.rst @@ -5,6 +5,8 @@ 13.0.3.1.0 ========== +* Code formatting, add license / docs / badges. + (port from 11.0.1.2.0) * MailTemplate converter: Allow multiple records. diff --git a/README.rst b/README.rst --- a/README.rst +++ b/README.rst @@ -2,4 +2,25 @@ Converter ========= +.. |coverage| image:: .badges/coverage.svg + :target: https://orus.io/xcg/odoo-modules/converter/-/pipelines?ref=branch/13.0 + :alt: Coverage report +.. |pylint| image:: .badges/pylint.svg + :target: https://orus.io/xcg/odoo-modules/converter/-/pipelines?ref=branch/13.0 + :alt: pylint score +.. |maturity| image:: .badges/maturity.svg + :target: https://odoo-community.org/page/development-status + :alt: Stable +.. |license| image:: .badges/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |black| image:: .badges/code_style-black-000000.svg + :target: https://github.com/psf/black + :alt: Black +.. |prettier| image:: .badges/code_style-prettier-ff69b4.svg + :target: https://github.com/prettier/prettier + :alt: Prettier + +|coverage| |pylint| |maturity| |license| |black| |prettier| + Convert odoo records to/from plain data structures. diff --git a/__init__.py b/__init__.py --- a/__init__.py +++ b/__init__.py @@ -1,23 +1,52 @@ -from . import models # noqa: F401 -from .base import * # noqa: F401,F403 -from .exception import InternalError # noqa: F401 -from .field import Field, TranslatedSelection # noqa: F401 -from .keyfield import FirstKeyField, KeyField # noqa: F401 -from .list import List # noqa: F401 -from .mail_template import MailTemplate # noqa: F401 -from .model import Model # noqa: F401 -from .relation import ( # noqa: F401 +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from . import models +from .base import ( + Computed, + Constant, + ContextBuilder, + Converter, + Newinstance, + Readonly, + Skip, + message_to_odoo, +) +from .exception import InternalError +from .field import Field, TranslatedSelection +from .keyfield import FirstKeyField, KeyField +from .list import List +from .mail_template import MailTemplate +from .model import Model +from .relation import ( RelationToMany, RelationToManyMap, RelationToOne, relation, ) -from .switch import Switch # noqa: F401 -from .validate import ( # noqa: F401 +from .switch import Switch +from .validate import ( VALIDATION_SKIP, VALIDATION_SOFT, VALIDATION_STRICT, NotInitialized, Validator, ) -from .xref import Xref # noqa: F401 +from .xref import Xref diff --git a/__manifest__.py b/__manifest__.py --- a/__manifest__.py +++ b/__manifest__.py @@ -1,7 +1,7 @@ ############################################################################## # -# Converter for Odoo -# Copyright (C) 2020 XCG Consulting <http://odoo.consulting> +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,16 +17,17 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## + { "name": "Converter", "license": "AGPL-3", - "summary": "Convert odoo records to/from plain data structures.", "version": "13.0.3.1.0", "category": "Hidden", "author": "XCG Consulting", "website": "https://odoo.consulting/", "depends": ["base", "mail"], "data": [], + "installable": True, + # These dependencies are in the "requirements" file. "external_dependencies": {"python": ["jsonschema"]}, - "installable": True, } diff --git a/base.py b/base.py --- a/base.py +++ b/base.py @@ -1,7 +1,7 @@ ############################################################################## # -# Converter for Odoo -# Copyright (C) 2020, 2022 XCG Consulting <http://odoo.consulting> +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as diff --git a/doc/.badges b/doc/.badges new file mode 120000 --- /dev/null +++ b/doc/.badges @@ -0,0 +1,1 @@ +../.badges \ No newline at end of file diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,42 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = . +BUILDDIR = _build +LANGUAGE ?= en +BUILDDIRSUFFIX = + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +.PHONY: help Makefile gettext clean + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)/$(LANGUAGE)$(BUILDDIRSUFFIX)" $(SPHINXOPTS) $(O) + +clean: + rm -rf $(BUILDDIR)/* + rm -f autotodo + +# depends on autotodo.py but that does not work well with the catch-all below +autotodo: + @./autotodo.py ../ .py TODO,FIXME,XXX + +gettext: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)$(BUILDDIRSUFFIX)" $(SPHINXOPTS) $(O) + +# Use to update *.po files +update_locale: Makefile gettext + @sphinx-intl update -p "$(BUILDDIR)$(BUILDDIRSUFFIX)/gettext" -l $(LANGUAGE) + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile autotodo + @$(SPHINXBUILD) -b $@ "$(SOURCEDIR)" "$(BUILDDIR)/$@/$(LANGUAGE)$(BUILDDIRSUFFIX)" -d "$(BUILDDIR)$(BUILDDIRSUFFIX)/doctrees/$(LANGUAGE)" $(SPHINXOPTS) -D language=$(LANGUAGE) $(O) diff --git a/doc/NEWS.rst b/doc/NEWS.rst new file mode 120000 --- /dev/null +++ b/doc/NEWS.rst @@ -0,0 +1,1 @@ +../NEWS.rst \ No newline at end of file diff --git a/doc/README.rst b/doc/README.rst new file mode 120000 --- /dev/null +++ b/doc/README.rst @@ -0,0 +1,1 @@ +../README.rst \ No newline at end of file diff --git a/doc/TODO.rst b/doc/TODO.rst new file mode 100644 --- /dev/null +++ b/doc/TODO.rst @@ -0,0 +1,7 @@ +==== +TODO +==== + +.. todolist:: + +.. include:: autotodo diff --git a/doc/autotodo.py b/doc/autotodo.py new file mode 100755 --- /dev/null +++ b/doc/autotodo.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2014, 2018, 2022 XCG Consulting +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +import os +import os.path +import sys + + +def main(): + if len(sys.argv) != 4: + print("usage: autotodo.py <folder> <exts> <tags>") + sys.exit(1) + + folder = sys.argv[1] + exts = sys.argv[2].split(",") + tags = sys.argv[3].split(",") + todolist = {tag: [] for tag in tags} + + for root, _dirs, files in os.walk(folder): + scan_folder((exts, tags, todolist), root, files) + create_autotodo(folder, todolist) + + +def write_info(f, infos, folder): + # Check sphinx version for lineno-start support + + import sphinx + + if sphinx.version_info < (1, 3): + lineno_start = False + else: + lineno_start = True + + for i in infos: + path = i[0] + line = i[1] + lines = (line - 3, line + 4) + class_name = ":class:`%s`" % os.path.basename( + os.path.splitext(path)[0] + ) + f.write( + "%s\n" + "%s\n\n" + "Line %s\n" + "\t.. literalinclude:: %s\n" + "\t\t:language: python\n" + "\t\t:lines: %s-%s\n" + "\t\t:emphasize-lines: %s\n" + % ( + class_name, + "-" * len(class_name), + line, + path, + lines[0], + lines[1], + line, + ) + ) + if lineno_start: + f.write("\t\t:lineno-start: %s\n" % lines[0]) + f.write("\n") + + +def create_autotodo(folder, todolist): + with open("autotodo", "w+") as f: + for tag, info in list(todolist.items()): + f.write("%s\n%s\n\n" % (tag, "=" * len(tag))) + write_info(f, info, folder) + + +def scan_folder(data_tuple, dirname, names): + (exts, tags, res) = data_tuple + file_info = {} + for name in names: + (root, ext) = os.path.splitext(name) + if ext in exts: + file_info = scan_file(os.path.join(dirname, name), tags) + for tag, info in list(file_info.items()): + if info: + res[tag].extend(info) + + +def scan_file(filename, tags): + res = {tag: [] for tag in tags} + with open(filename, "r") as f: + for line_num, line in enumerate(f): + for tag in tags: + if tag in line: + res[tag].append((filename, line_num, line[:-1].strip())) + return res + + +if __name__ == "__main__": + main() diff --git a/doc/conf.py b/doc/conf.py new file mode 100644 --- /dev/null +++ b/doc/conf.py @@ -0,0 +1,198 @@ +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import ast +import configparser +import os +import sys + +from odoo_scripts.config import Configuration + +import odoo + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath(".")) + +# -- General configuration ------------------------------------------------ + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.doctest", + "sphinx.ext.intersphinx", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.graphviz", + "sphinxodoo.ext.autodoc", +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +source_suffix = ".rst" + +# The master toctree document. +master_doc = "index" + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +with open(os.path.join("..", "__manifest__.py"), "r") as f: + read_data = f.read() +d = ast.literal_eval(read_data) +# The full version, including alpha/beta/rc tags. +release = d["version"] +# The short X.Y version. +version = ".".join(release.split(".")[:4]) + +# General information about the project. +project = d["name"] +copyright = "2021 XCG Consulting" +author = d["author"] +module_nospace = project.replace(" ", "") +module_description = d.get("summary", "") +module_lowercase = module_nospace.lower() + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +locale_dirs = ["locale"] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["_build"] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = True + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = "default" + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +# Output file base name for HTML help builder. +htmlhelp_basename = "%sdoc" % module_nospace + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = {} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ( + master_doc, + "%s.tex" % module_nospace, + "%s Documentation" % project, + author, + "manual", + ) +] + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, module_lowercase, "%s Documentation" % project, [author], 1) +] + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + module_nospace, + "%s Documentation" % project, + author, + module_nospace, + module_description, + "Miscellaneous", + ) +] + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {"https://docs.python.org/3/": None} + + +# +# odoo-sphinx-autodoc +# + +# sphinxodoo_addons: List of addons name to load (if empty, no addon will be +# loaded) +this_module = os.path.basename( + os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +) +sphinxodoo_addons = [this_module] +# sphinxodoo_root_path : Path of the Odoo root directory +sphinxodoo_root_path = os.path.dirname( + os.path.dirname(os.path.abspath(odoo.__file__)) +) +# sphinxodoo_addons_path : List of paths were Odoo addons to load are located +c = None +# find setup file of superproject, if any +directory = os.path.dirname(os.getenv("PWD")) +while not c and directory: + setup_path = os.path.join(directory, "setup.cfg") + if os.path.isfile(setup_path): + c = configparser.ConfigParser() + c.read(setup_path) + if c.has_section("odoo_scripts"): + # reload with odoo_scripts + c = Configuration(setup_path) + else: + c = None + if not c: + if os.path.dirname(directory) != directory: + directory = os.path.dirname(directory) + else: + directory = None + +sphinxodoo_addons_path = [] + +if c: + addon_dirs = set(os.path.dirname(path) for path in c.modules) + + for line in addon_dirs: + sphinxodoo_addons_path.append(os.path.join(directory, line)) +else: + # add this directory top dir + sphinxodoo_addons_path.append( + os.path.dirname(os.path.dirname(os.getenv("PWD"))) + ) + other_addons = os.getenv("ODOO_ADDONS_PATH", default=None) + if other_addons: + for addon_path in other_addons.split(","): + sphinxodoo_addons_path.append(addon_path) diff --git a/doc/index.rst b/doc/index.rst new file mode 100644 --- /dev/null +++ b/doc/index.rst @@ -0,0 +1,18 @@ +.. include:: README.rst + +Contents: + +.. toctree:: + :maxdepth: 2 + + modules + NEWS + TODO + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/exception.py b/exception.py --- a/exception.py +++ b/exception.py @@ -1,7 +1,7 @@ ############################################################################## # -# Converter for Odoo -# Copyright (C) 2022 XCG Consulting <https://xcg-consulting.fr/> +# Converter Odoo module +# Copyright (C) 2022 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,5 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## + + class InternalError(Exception): pass diff --git a/field.py b/field.py --- a/field.py +++ b/field.py @@ -1,12 +1,32 @@ +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + import datetime from typing import Any, Callable, Dict, Optional +import pytz + from odoo import api, models from .base import PHASE_POSTCREATE, Converter, Newinstance, Skip -import pytz - class Field(Converter): """Converter linked to a single field""" diff --git a/keyfield.py b/keyfield.py --- a/keyfield.py +++ b/keyfield.py @@ -1,3 +1,23 @@ +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + import warnings from typing import Any, Dict, Optional diff --git a/legacy.py b/legacy.py --- a/legacy.py +++ b/legacy.py @@ -1,7 +1,28 @@ +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + """ .. deprecated:: 1.0 Use the other converter instead, kept for ease of porting. """ + import warnings from typing import Any, Dict, Optional diff --git a/list.py b/list.py --- a/list.py +++ b/list.py @@ -1,3 +1,23 @@ +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + from typing import Any, Dict, List as TypingList, Optional from odoo import models diff --git a/mail_template.py b/mail_template.py --- a/mail_template.py +++ b/mail_template.py @@ -1,3 +1,23 @@ +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + import ast from typing import Any, Dict, Optional diff --git a/model.py b/model.py --- a/model.py +++ b/model.py @@ -1,3 +1,23 @@ +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + import logging from collections import OrderedDict from typing import Any, Dict, Iterable, List, Mapping, Optional, Set, Union diff --git a/models/__init__.py b/models/__init__.py --- a/models/__init__.py +++ b/models/__init__.py @@ -1,1 +1,1 @@ -from . import ir_model_data # noqa: F401 +from . import ir_model_data diff --git a/models/ir_model_data.py b/models/ir_model_data.py --- a/models/ir_model_data.py +++ b/models/ir_model_data.py @@ -1,7 +1,7 @@ ############################################################################## # -# Converter for Odoo -# Copyright (C) 2021, 2022 XCG Consulting <https://xcg-consulting.fr/> +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,6 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## + import uuid from odoo import api, models diff --git a/relation.py b/relation.py --- a/relation.py +++ b/relation.py @@ -1,3 +1,23 @@ +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + import logging import warnings from typing import Any, Callable, Dict, Optional, Union diff --git a/switch.py b/switch.py --- a/switch.py +++ b/switch.py @@ -1,3 +1,23 @@ +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + from typing import Any, Callable, Dict, List, Mapping, Optional, Set, Tuple from odoo import api, models diff --git a/tests/__init__.py b/tests/__init__.py --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,7 +1,9 @@ -from . import test_base # noqa: F401 -from . import test_converters # noqa: F401 -from . import test_field # noqa: F401 -from . import test_ir_model # noqa: F401 -from . import test_mail_template # noqa: F401 -from . import test_relation # noqa: F401 -from . import test_switch # noqa: F401 +from . import ( + test_base, + test_converters, + test_field, + test_ir_model, + test_mail_template, + test_relation, + test_switch, +) diff --git a/tests/test_base.py b/tests/test_base.py --- a/tests/test_base.py +++ b/tests/test_base.py @@ -1,7 +1,7 @@ ############################################################################## # -# Converter for Odoo -# Copyright (C) 2021, 2022 XCG Consulting <https://xcg-consulting.fr/> +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,6 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## + from odoo import tests from odoo.addons.converter import Constant, Field, Model, Xref, message_to_odoo diff --git a/tests/test_converters.py b/tests/test_converters.py --- a/tests/test_converters.py +++ b/tests/test_converters.py @@ -1,7 +1,7 @@ ############################################################################## # -# Converter for Odoo -# Copyright (C) 2020, 2022 XCG Consulting <https://xcg-consulting.fr/> +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as diff --git a/tests/test_field.py b/tests/test_field.py --- a/tests/test_field.py +++ b/tests/test_field.py @@ -1,7 +1,7 @@ ############################################################################## # -# Converter for Odoo -# Copyright (C) 2021, 2022 XCG Consulting <https://xcg-consulting.fr/> +# Converter Odoo module +# Copyright (C) 2021 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,6 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## + from typing import Any from odoo import tests diff --git a/tests/test_ir_model.py b/tests/test_ir_model.py --- a/tests/test_ir_model.py +++ b/tests/test_ir_model.py @@ -1,7 +1,7 @@ -############################################################################### +############################################################################## # -# Converter for Odoo -# Copyright (C) 2018, 2022 XCG Consulting (https://xcg-consulting.fr/) +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -16,7 +16,8 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################### +############################################################################## + from odoo.tests import TransactionCase, tagged diff --git a/tests/test_mail_template.py b/tests/test_mail_template.py --- a/tests/test_mail_template.py +++ b/tests/test_mail_template.py @@ -1,4 +1,22 @@ -# TODO Copyright notice coming up in further commits. +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2023 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## from odoo import tests diff --git a/tests/test_relation.py b/tests/test_relation.py --- a/tests/test_relation.py +++ b/tests/test_relation.py @@ -1,7 +1,7 @@ ############################################################################## # -# Converter for Odoo -# Copyright (C) 2021, 2022 XCG Consulting <https://xcg-consulting.fr/> +# Converter Odoo module +# Copyright (C) 2021 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,6 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## + from odoo import tests from odoo.addons.converter import ( diff --git a/tests/test_switch.py b/tests/test_switch.py --- a/tests/test_switch.py +++ b/tests/test_switch.py @@ -1,7 +1,7 @@ ############################################################################## # -# Converter for Odoo -# Copyright (C) 2021, 2022 XCG Consulting <https://xcg-consulting.fr/> +# Converter Odoo module +# Copyright (C) 2021 XCG Consulting <https://xcg-consulting.fr> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -17,6 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## + from odoo import tests from .. import Field, Model, Switch diff --git a/validate.py b/validate.py --- a/validate.py +++ b/validate.py @@ -1,3 +1,23 @@ +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + import json import math import os diff --git a/xref.py b/xref.py --- a/xref.py +++ b/xref.py @@ -1,3 +1,23 @@ +############################################################################## +# +# Converter Odoo module +# Copyright (C) 2020 XCG Consulting <https://xcg-consulting.fr> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + from typing import Any, Dict, Optional, Union from odoo import models