[14.0][IMP] base_exception: Better general Handling of Sub-Exceptions
Hi,
I moved the new def _get_sub_exception_field_names from PR https://github.com/OCA/server-tools/pull/3354 to here.
This here uses the commits of the other PR. I will do a rebase after the other was merged.
I implemented a way to add exceptions to the record on which the exceptions where detected on in case _get_main_records returns something else than self, like self.order_id.
~That commit breaks sale_exception because I added _get_main_records to detect_exceptions so that it is not necessary anymore to do this in an overridden _detect_exceptions.~
EDIT: I checked sale_exception again to update PR https://github.com/OCA/sale-workflow/pull/3861. Seems that it is not breaking the module. The overridden _detect_exceptions in sale.order.line returns the same as the overridden _get_main_records. After that _get_main_records is called again on the returned sales orders. So only one useless _get_main_records call.
I removed the comment in detect_exceptions because it refered to the _reverse_field and the Many2many field on the exception rule. As this does not exist anymore, the comment is also not needed anymore
Hi @sebastienbeau, @hparfr, some modules you are maintaining are being modified, check this out!
Will add the 2nd commit after the tests for the 1st commit are done to be sure I committed the right things
@hparfr and @lmignon, did a rebase. Can you check this here please?
@hparfr, if a model inherits from base.exception.method, it must implement field ignore_exception because that class uses the field in _get_base_domain when it tries to find the records on which the rule needs to be applied on. If this field is not implemented, an error is raised.
That's why I want to move it from base.exception to base.exception.method to have it automatically implemented through inheritance. Is this ok?
If models need a special implementation for this field, it needs to be implemented anyway manually. Like in sale.order.line so that the field is related to order_id.ignore_exception.
For other models the field will always be False and never changed. But this would be the case anyway if you have to implement it eventhough you wouldn't use it