# HG changeset patch # User Etienne Ferriere <etienne.ferriere@xcg-consulting.fr> # Date 1682414259 0 # Tue Apr 25 09:17:39 2023 +0000 # Branch 15.0 # Node ID 0acdbaf4ba83c88cbb5768a0478e9a46f8652df9 # Parent 60237a779bcc2dbc4b8c7d0ac07a4f5d62d7e65f In the converter of Many2one relations, the model name must be a keyword argument, optional and not compulsory, as in Odoo 11. Moreover, when the Many2one is empty and a value has to be returned, the converter tries to return the class of the Many2one model. The converter must be able to automatically identify the model name from the Many2one definition, without requiring the model name to be given in arguments. diff --git a/NEWS.rst b/NEWS.rst --- a/NEWS.rst +++ b/NEWS.rst @@ -1,6 +1,16 @@ Changelog ========= +15.0.3.3.1 +---------- + +* In the converter of Many2one relations, the model name must be a keyword + argument, optional and not compulsory, as in Odoo 11. Moreover, when the + Many2one is empty and a value has to be returned, the converter tries to + return the class of the Many2one model. The converter must be able to + automatically identify the model name from the Many2one definition, without + requiring the model name to be given in arguments. + 15.0.3.3.0 ---------- diff --git a/__manifest__.py b/__manifest__.py --- a/__manifest__.py +++ b/__manifest__.py @@ -22,7 +22,7 @@ "name": "Converter", "license": "AGPL-3", "summary": "Convert odoo records to/from plain data structures.", - "version": "15.0.3.3.0", + "version": "15.0.3.3.1", "category": "Hidden", "author": "XCG Consulting", "website": "https://orbeet.io/", diff --git a/doc/autotodo.py b/doc/autotodo.py --- a/doc/autotodo.py +++ b/doc/autotodo.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2014, 2018, 2022 XCG Consulting +# Copyright © 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 diff --git a/doc/conf.py b/doc/conf.py --- a/doc/conf.py +++ b/doc/conf.py @@ -11,7 +11,6 @@ import configparser import os import sys -from importlib.metadata import version from odoo_scripts.config import Configuration @@ -35,7 +34,7 @@ "sphinx.ext.coverage", "sphinx.ext.graphviz", "sphinx.ext.viewcode", - "sphinxodoo.ext.autodoc", + "sphinxodooautodoc.ext.autodoc", ] # Add any paths that contain templates here, relative to this directory. @@ -51,19 +50,18 @@ # 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. - -# The full version, including alpha/beta/rc tags. -release = version("odoo-addon-converter") -# The short X.Y version. -version = ".".join(release.split(".")[:2]) - +# 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 = "2020, 2022 XCG Consulting" +copyright = "2021, 2022 XCG Consulting" author = d["author"] module_nospace = project.replace(" ", "") module_description = d.get("summary", "") @@ -172,7 +170,7 @@ c.read(setup_path) if c.has_section("odoo_scripts"): # reload with odoo_scripts - c = Configuration(os.path.dirname(setup_path)) + c = Configuration(directory) else: c = None if not c: diff --git a/relation.py b/relation.py --- a/relation.py +++ b/relation.py @@ -33,7 +33,7 @@ def __init__( self, field_name: str, - model_name: str, + model_name: Optional[str], converter: Converter, send_empty: bool = True, context: Optional[ContextBuilder] = None, @@ -54,6 +54,8 @@ if not self._send_empty: return Skip else: + if not self.model_name: + self.model_name = instance._fields[self.field_name].comodel_name relation_instance = instance.env[self.model_name] return self.converter.odoo_to_message(relation_instance, ctx)