4
4
class AccountMove (models .Model ):
5
5
_inherit = "account.move"
6
6
7
- @api .depends ("company_id" , "invoice_filter_type_domain" , "move_type" )
7
+ @api .depends ("company_id" , "invoice_filter_type_domain" )
8
8
def _compute_suitable_journal_ids (self ):
9
9
res = super ()._compute_suitable_journal_ids ()
10
- for m in self :
11
- dedicated_journals = m .suitable_journal_ids .filtered (
12
- lambda j : j .receipts == m .move_type in {"out_receipt" , "in_receipt" }
10
+ for move in self :
11
+ if move .move_type in {"in_receipt" , "out_receipt" }:
12
+ move .suitable_journal_ids = move .suitable_journal_ids .filtered (
13
+ "receipts"
14
+ )
15
+ continue
16
+ move .suitable_journal_ids = move .suitable_journal_ids .filtered (
17
+ lambda x : not x .receipts
13
18
)
14
- # Suitable journals dedicated to receipts if exists
15
- m .suitable_journal_ids = dedicated_journals or m .suitable_journal_ids
16
19
return res
17
20
18
21
@api .model
@@ -34,13 +37,14 @@ def _search_default_receipt_journal(self, journal_types):
34
37
return journal
35
38
36
39
@api .model
37
- def _search_default_journal (self , journal_types ):
38
- journal = super ()._search_default_journal (journal_types )
40
+ def _search_default_journal (self ):
41
+ journal = super ()._search_default_journal ()
39
42
move_type = self .env .context .get ("default_move_type" )
40
43
# We can assume that if move_type is not in receipts, a journal without
41
44
# receipts it's coming because of the Journal constraint
42
45
if move_type not in {"in_receipt" , "out_receipt" } or journal .receipts :
43
46
return journal
47
+ journal_types = self ._get_valid_journal_types ()
44
48
return self ._search_default_receipt_journal (journal_types ) or journal
45
49
46
50
def _get_journal_types (self , move_type ):
0 commit comments