Browse Source

Fix dolibarr version check

Fix #1
Philippe Le Brouster 6 years ago
parent
commit
d42d095f7b
3 changed files with 8 additions and 4 deletions
  1. 1 1
      README.md
  2. 6 2
      himport/dolibarrAlchemy.py
  3. 1 1
      setup.py

+ 1 - 1
README.md

@@ -3,7 +3,7 @@
 
 **Installation**
 
-    git clone https://code.ffdn.org/plb/himport.git
+    git clone https://code.ffdn.org/ffdn/himport.git
     cd himport
 
     virtualenv venv

+ 6 - 2
himport/dolibarrAlchemy.py

@@ -44,7 +44,11 @@ class DolibarrSQLAlchemy(object):
         self.session = Session(autocommit=True)
 
     def prepare(self):
-        version = self.engine.execute("SELECT value FROM llx_const WHERE name='MAIN_VERSION_LAST_UPGRADE'").fetchone()[0]
+        versions = self.engine.execute("""
+            SELECT value FROM llx_const
+            WHERE name='MAIN_VERSION_LAST_UPGRADE' OR name='MAIN_VERSION_LAST_INSTALL'
+        """).fetchall()
+        version = max([LooseVersion(v[0]) for v in versions])
         self.metadata = MetaData(bind=self.engine, info={'dolibarr_version': version})
 
         Base = declarative_base(bind=self.engine, metadata=self.metadata)
@@ -54,7 +58,7 @@ class DolibarrSQLAlchemy(object):
 
             @classmethod
             def after40(cls):
-                return LooseVersion(cls.metadata.info['dolibarr_version']) > LooseVersion("4.0")
+                return cls.metadata.info['dolibarr_version'] > LooseVersion("4.0")
 
         class Bank(DolibarrBase):
             __tablename__ = "llx_bank"

+ 1 - 1
setup.py

@@ -23,7 +23,7 @@ setup(
     # Versions should comply with PEP440.  For a discussion on single-sourcing
     # the version across setup.py and the project code, see
     # https://packaging.python.org/en/latest/single_source_version.html
-    version='0.1',
+    version='0.1.1',
 
     description='Himport project',
     long_description=long_description,