1010
1111from odoo import api , fields , models
1212from odoo .exceptions import UserError , ValidationError
13+ from odoo .fields import Domain
1314
1415from .aep import AccountingExpressionProcessor as AEP
1516from .expression_evaluator import ExpressionEvaluator
@@ -289,19 +290,20 @@ def _compute_dates(self):
289290
290291 _order = "sequence, id"
291292
292- _sql_constraints = [
293- ("duration" , "CHECK (duration>0)" , "Wrong duration, it must be positive!" ),
294- (
295- "normalize_factor" ,
296- "CHECK (normalize_factor>0)" ,
297- "Wrong normalize factor, it must be positive!" ,
298- ),
299- (
300- "name_unique" ,
301- "unique(name, report_instance_id)" ,
302- "Period name should be unique by report" ,
303- ),
304- ]
293+ _duration = models .Constraint (
294+ "CHECK(duration > 0)" ,
295+ "Wrong duration, it must be positive!" ,
296+ )
297+
298+ _normalize_factor = models .Constraint (
299+ "CHECK(normalize_factor > 0)" ,
300+ "Wrong normalize factor, it must be positive!" ,
301+ )
302+
303+ _name_unique = models .Constraint (
304+ "unique(name, report_instance_id)" ,
305+ "Period name should be unique by report" ,
306+ )
305307
306308 @api .depends ("source" , "report_instance_id.report_id.move_lines_source" )
307309 def _compute_source_aml_model_id (self ):
@@ -423,17 +425,15 @@ def _check_mode_source(self):
423425 if rec .mode == MODE_NONE :
424426 raise DateFilterRequired (
425427 self .env ._ (
426- "A date filter is mandatory for this source "
427- "in column %s." ,
428+ "A date filter is mandatory for this source in column %s." ,
428429 rec .name ,
429430 )
430431 )
431432 elif rec .source in (SRC_SUMCOL , SRC_CMPCOL ):
432433 if rec .mode != MODE_NONE :
433434 raise DateFilterForbidden (
434435 self .env ._ (
435- "No date filter is allowed for this source "
436- "in column %s." ,
436+ "No date filter is allowed for this source in column %s." ,
437437 rec .name ,
438438 )
439439 )
@@ -460,8 +460,7 @@ def _check_source_cmpcol(self):
460460 ):
461461 raise ValidationError (
462462 self .env ._ (
463- "Columns to compare must belong to the same report "
464- "in %s" ,
463+ "Columns to compare must belong to the same report in %s" ,
465464 rec .name ,
466465 )
467466 )
@@ -499,7 +498,7 @@ def _compute_pivot_date(self):
499498 sequence = fields .Integer (default = 10 )
500499 description = fields .Char (related = "report_id.description" )
501500 date = fields .Date (
502- string = "Base date" , help = "Report base date " " (leave empty to use current date)"
501+ string = "Base date" , help = "Report base date (leave empty to use current date)"
503502 )
504503 pivot_date = fields .Date (compute = "_compute_pivot_date" )
505504 report_id = fields .Many2one ("mis.report" , required = True , string = "Report" )
@@ -765,9 +764,7 @@ def get_views(self, views, options=None):
765764 context .get ("from_dashboard" )
766765 and context .get ("active_model" ) == "mis.report.instance"
767766 ):
768- view_id = self .env .ref (
769- "mis_builder." "mis_report_instance_result_view_form"
770- )
767+ view_id = self .env .ref ("mis_builder.mis_report_instance_result_view_form" )
771768 mis_report_form_view = view_id and [view_id .id , "form" ]
772769 for view in views :
773770 if view and view [1 ] == "form" :
@@ -778,7 +775,7 @@ def get_views(self, views, options=None):
778775
779776 def preview (self ):
780777 self .ensure_one ()
781- view_id = self .env .ref ("mis_builder." " mis_report_instance_result_view_form" )
778+ view_id = self .env .ref ("mis_builder.mis_report_instance_result_view_form" )
782779 return {
783780 "type" : "ir.actions.act_window" ,
784781 "res_model" : "mis.report.instance" ,
@@ -980,7 +977,9 @@ def drilldown(self, arg):
980977 period .date_to ,
981978 account_id ,
982979 )
983- domain .extend (period ._get_additional_move_line_filter ())
980+ additional_domain = period ._get_additional_move_line_filter ()
981+ if additional_domain :
982+ domain = Domain .AND ([domain , additional_domain ])
984983 views = self ._get_drilldown_model_views (period .source_aml_model_name )
985984 return {
986985 "name" : self ._get_drilldown_action_name (arg ),
0 commit comments