|
@@ -14,7 +14,7 @@ from sqlalchemy.orm import relationship, backref, sessionmaker
|
|
|
from sqlalchemy.ext.declarative import declarative_base, DeferredReflection
|
|
|
|
|
|
from sqlalchemy import create_engine, MetaData, select, join
|
|
|
-
|
|
|
+
|
|
|
Base = declarative_base(cls=DeferredReflection)
|
|
|
|
|
|
|
|
@@ -24,7 +24,7 @@ class Bank(Base):
|
|
|
|
|
|
fk_account = Column('fk_account', Integer, ForeignKey('llx_bank_account.rowid'))
|
|
|
account = relationship("BankAccount", backref="entries", lazy="subquery")
|
|
|
-
|
|
|
+
|
|
|
url_company = relationship(
|
|
|
"BankUrl", uselist=False, backref="bank_company", innerjoin=True,
|
|
|
primaryjoin="and_(Bank.id==BankUrl.fk_bank, " "BankUrl.type=='company')",
|
|
@@ -153,6 +153,7 @@ class PaiementFacture(Base):
|
|
|
paiement = relationship(
|
|
|
"Paiement",
|
|
|
lazy="subquery",
|
|
|
+ order_by="Paiement.datep,Paiement.id",
|
|
|
)
|
|
|
|
|
|
|
|
@@ -219,7 +220,7 @@ class FactureFourn(Base):
|
|
|
backref="factures_fournisseurs",
|
|
|
lazy="subquery",
|
|
|
)
|
|
|
-
|
|
|
+
|
|
|
details = relationship(
|
|
|
'FactureFournDet',
|
|
|
lazy="subquery",
|
|
@@ -374,12 +375,12 @@ MYSQL_QUERIES = {
|
|
|
p.ref as p_ref,
|
|
|
p.label as p_label,
|
|
|
p.accountancy_code_sell as p_accountancy_code_sell,
|
|
|
- a.account_number as a_account_number
|
|
|
- FROM llx_societe as s
|
|
|
- LEFT JOIN llx_c_pays as c on s.fk_pays = c.rowid, llx_facture as f
|
|
|
- LEFT JOIN llx_facture_extrafields as extra ON f.rowid = extra.fk_object , llx_facturedet as fd
|
|
|
- LEFT JOIN llx_product as p on (fd.fk_product = p.rowid)
|
|
|
- LEFT JOIN llx_accountingaccount as a ON fd.fk_code_ventilation = a.rowid
|
|
|
+ a.account_number as a_account_number
|
|
|
+ FROM llx_societe as s
|
|
|
+ LEFT JOIN llx_c_pays as c on s.fk_pays = c.rowid, llx_facture as f
|
|
|
+ LEFT JOIN llx_facture_extrafields as extra ON f.rowid = extra.fk_object , llx_facturedet as fd
|
|
|
+ LEFT JOIN llx_product as p on (fd.fk_product = p.rowid)
|
|
|
+ LEFT JOIN llx_accountingaccount as a ON fd.fk_code_ventilation = a.rowid
|
|
|
WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture AND f.entity = 1""",
|
|
|
|
|
|
"suppliers": """SELECT DISTINCT s.rowid as s_rowid,
|
|
@@ -466,7 +467,7 @@ class DolibarrSQLAlchemy(object):
|
|
|
self.metadata = MetaData(bind=self.engine)
|
|
|
|
|
|
Base.prepare(self.engine)
|
|
|
-
|
|
|
+
|
|
|
# create a configured "Session" class
|
|
|
Session = sessionmaker(bind=self.engine)
|
|
|
|
|
@@ -475,5 +476,3 @@ class DolibarrSQLAlchemy(object):
|
|
|
|
|
|
def disconnect(self):
|
|
|
self.session.close()
|
|
|
-
|
|
|
-
|