I forgot a small detail: I import the bank statements, so the origin lines are created automatically.
Yes, but the account_statement_rule doesn’t do anything with that. It tries to find the party again based on account number or party name, but neither of those exists in the keywords. And if there is no party, the rule-system stops.
When you want to create origin lines with an account where party is required and the rule-system doesn’t find a party, the rule-system should try to get the party from the origin line. If it then fails, that’s no problem.
In this way, users are able to automatically generate almost all the statement lines, which is a big win, when you have a lot of origin lines with a party. Those lines are then automatically generated.
How could you not have the party on the statement line but on the origin? The origin is created first and lines are created based on the origin so they should have party filled.
During importing the statement, the party is searched based on bank account number. So most of the origin lines have a party based on that. However the account_statement_rule doesn’t do anything with that. Instead it tries to find the party again. See modules/account_statement_rule: b976dc52ba2d account.py and modules/account_statement_rule: b976dc52ba2d account.py. It would be a nice if the module also checks if a party exists on the origin.
OK it is when the rule creates a new line based on the origin. So I agree that it will be better to use the party of origin if set but only after trying to find it from the keywords rule.
No using the origin party should be fallback after the rules not before. Because it is the point of the rule to fill those field using expression. For example the same bank account can be used by different parties.