@ -60,7 +60,7 @@ class BveView(models.Model):
line_ids = self . _sync_lines_and_data ( bve_view . data )
line_ids = self . _sync_lines_and_data ( bve_view . data )
bve_view . write ( { " line_ids " : line_ids } )
bve_view . write ( { " line_ids " : line_ids } )
name = fields . Char ( required = True , copy = False )
name = fields . Char ( required = True , copy = False , default = " " )
model_name = fields . Char ( compute = " _compute_model_name " , store = True )
model_name = fields . Char ( compute = " _compute_model_name " , store = True )
note = fields . Text ( string = " Notes " )
note = fields . Text ( string = " Notes " )
state = fields . Selection (
state = fields . Selection (
@ -100,7 +100,7 @@ class BveView(models.Model):
)
)
query = fields . Text ( compute = " _compute_sql_query " )
query = fields . Text ( compute = " _compute_sql_query " )
over_condition = fields . Text (
over_condition = fields . Text (
states = { " draft " : [ ( " readonly " , False ) , ] , } ,
states = { " draft " : [ ( " readonly " , False ) ] } ,
readonly = True ,
readonly = True ,
help = " Condition to be inserted in the OVER part "
help = " Condition to be inserted in the OVER part "
" of the ID ' s row_number function. \n "
" of the ID ' s row_number function. \n "
@ -169,7 +169,7 @@ class BveView(models.Model):
try :
try :
png_base64_image = base64 . b64encode ( graph . create_png ( ) )
png_base64_image = base64 . b64encode ( graph . create_png ( ) )
bve_view . er_diagram_image = png_base64_image
bve_view . er_diagram_image = png_base64_image
except :
except Exception :
bve_view . er_diagram_image = False
bve_view . er_diagram_image = False
def _create_view_arch ( self ) :
def _create_view_arch ( self ) :
@ -191,7 +191,7 @@ class BveView(models.Model):
return ' <field name= " {} " {} /> ' . format ( line . name , res )
return ' <field name= " {} " {} /> ' . format ( line . name , res )
bve_field_lines = self . field_ids . filtered ( lambda l : l . in_list )
bve_field_lines = self . field_ids . filtered ( lambda l : l . in_list )
return list ( map ( _get_field_attrs , bve_field_lines ) )
return list ( map ( _get_field_attrs , bve_field_lines . sorted ( " sequence " ) ) )
def _create_bve_view ( self ) :
def _create_bve_view ( self ) :
self . ensure_one ( )
self . ensure_one ( )
@ -236,7 +236,7 @@ class BveView(models.Model):
" model " : self . model_name ,
" model " : self . model_name ,
" priority " : 16 ,
" priority " : 16 ,
" arch " : """ <?xml version= " 1.0 " ?>
" arch " : """ <?xml version= " 1.0 " ?>
< search string = " Search BI View " >
< search >
{ }
{ }
< / search >
< / search >
""" .format(
""" .format(
@ -254,7 +254,7 @@ class BveView(models.Model):
" model " : self . model_name ,
" model " : self . model_name ,
" priority " : 16 ,
" priority " : 16 ,
" arch " : """ <?xml version= " 1.0 " ?>
" arch " : """ <?xml version= " 1.0 " ?>
< tree string = " List Analysis " create = " false " >
< tree create = " false " >
{ }
{ }
< / tree >
< / tree >
""" .format(
""" .format(
@ -272,7 +272,6 @@ class BveView(models.Model):
" name " : self . name ,
" name " : self . name ,
" res_model " : self . model_name ,
" res_model " : self . model_name ,
" type " : " ir.actions.act_window " ,
" type " : " ir.actions.act_window " ,
" view_type " : " form " ,
" view_mode " : " tree,graph,pivot " ,
" view_mode " : " tree,graph,pivot " ,
" view_id " : tree_view . id ,
" view_id " : tree_view . id ,
" context " : " { ' service_name ' : ' %s ' } " % self . name ,
" context " : " { ' service_name ' : ' %s ' } " % self . name ,
@ -475,7 +474,7 @@ class BveView(models.Model):
self . env [ " ir.model.access " ]
self . env [ " ir.model.access " ]
. sudo ( )
. sudo ( )
. search (
. search (
[ ( " model_id " , " = " , line_model . id ) , ( " perm_read " , " = " , True ) , ]
[ ( " model_id " , " = " , line_model . id ) , ( " perm_read " , " = " , True ) ]
)
)
)
)
group_list = " "
group_list = " "
@ -495,20 +494,18 @@ class BveView(models.Model):
if not self . line_ids :
if not self . line_ids :
raise ValidationError ( _ ( " No data to process. " ) )
raise ValidationError ( _ ( " No data to process. " ) )
if any ( not line . model_id for line in self . line_ids ) :
invalid_lines = self . line_ids . filtered ( lambda l : not l . model_id )
missing_models = set ( invalid_lines . mapped ( " model_name " ) )
missing_models = " , " . join ( missing_models )
invalid_lines = self . line_ids . filtered ( lambda l : not l . model_id )
if invalid_lines :
missing_models = " , " . join ( set ( invalid_lines . mapped ( " model_name " ) ) )
raise ValidationError (
raise ValidationError (
_ (
_ (
" Following models are missing: %s . \n "
" Following models are missing: %s . \n "
" Probably some modules were uninstalled. " % ( missing_models , )
" Probably some modules were uninstalled. " % ( missing_models , )
)
)
)
)
if any ( not line . field_id for line in self . line_ids ) :
invalid_lines = self . line_ids . filtered ( lambda l : not l . field_id )
missing_fields = set ( invalid_lines . mapped ( " field_name " ) )
missing_fields = " , " . join ( missing_fields )
invalid_lines = self . line_ids . filtered ( lambda l : not l . field_id )
if invalid_lines :
missing_fields = " , " . join ( set ( invalid_lines . mapped ( " field_name " ) ) )
raise ValidationError (
raise ValidationError (
_ ( " Following fields are missing: {}. " . format ( missing_fields ) )
_ ( " Following fields are missing: {}. " . format ( missing_fields ) )
)
)
@ -520,7 +517,6 @@ class BveView(models.Model):
action [ " display_name " ] = _ ( " BI View " )
action [ " display_name " ] = _ ( " BI View " )
return action
return action
@api.multi
def copy ( self , default = None ) :
def copy ( self , default = None ) :
self . ensure_one ( )
self . ensure_one ( )
default = dict ( default or { } , name = _ ( " %s (copy) " ) % self . name )
default = dict ( default or { } , name = _ ( " %s (copy) " ) % self . name )
@ -623,7 +619,9 @@ class BveView(models.Model):
@api.model
@api.model
def get_clean_list ( self , data_dict ) :
def get_clean_list ( self , data_dict ) :
serialized_data = json . loads ( data_dict )
serialized_data = data_dict
if type ( data_dict ) == str :
serialized_data = json . loads ( data_dict )
table_alias_list = set ( )
table_alias_list = set ( )
for item in serialized_data :
for item in serialized_data :
if item . get ( " join_node " , - 1 ) in [ - 1 , False ] :
if item . get ( " join_node " , - 1 ) in [ - 1 , False ] :