[PATCH 1 of 2 expense] Hide deactivated accounts when creating a new ExpenseLine

Philippe Pepiot philippe.pepiot at logilab.fr
Tue Oct 8 09:51:06 CEST 2019


# HG changeset patch
# User Philippe Pepiot <philippe.pepiot at logilab.fr>
# Date 1570520607 -7200
#      Tue Oct 08 09:43:27 2019 +0200
# Node ID 246b5809f2d09010782d633238965a882771c9fd
# Parent  422c6296ad678d2b7549e9cfa5f9d72bb479f1ab
# Available At https://hg.logilab.org/review/cubes/expense
#              hg pull https://hg.logilab.org/review/cubes/expense -r 246b5809f2d0
Hide deactivated accounts when creating a new ExpenseLine

diff --git a/cubicweb_expense/migration/0.10.0_Any.py b/cubicweb_expense/migration/0.10.0_Any.py
new file mode 100644
--- /dev/null
+++ b/cubicweb_expense/migration/0.10.0_Any.py
@@ -0,0 +1,1 @@
+sync_schema_props_perms('paid_by')
diff --git a/cubicweb_expense/schema.py b/cubicweb_expense/schema.py
--- a/cubicweb_expense/schema.py
+++ b/cubicweb_expense/schema.py
@@ -2,6 +2,7 @@ from yams.buildobjs import (EntityType, 
                             Float, Date, String, RichString)
 from cubicweb.schema import (WorkflowableEntityType,
                              RRQLExpression, ERQLExpression)
+from cubicweb.schema import RQLVocabularyConstraint
 
 from cubicweb import _
 from cubicweb.schemas.base import CWUser
@@ -42,7 +43,9 @@ class ExpenseLine(EntityType):
     taxes_currency = String(required=True, maxsize=10, default=u'EUR')
     taxes_exchange_rate = Float(required=True, default=1.0)
 
-    paid_by = SubjectRelation('PaidByAccount', cardinality='1*')
+    paid_by = SubjectRelation('PaidByAccount', cardinality='1*', constraints=[
+        RQLVocabularyConstraint('NOT (O associated_to A, A in_state ST, ST name "deactivated")'),
+    ])
     paid_for = SubjectRelation('PaidForAccount', cardinality='+*')
 
     currency = String(required=True, maxsize=30, default=u'EUR')



More information about the cubicweb-devel mailing list