diff options
| author | Djamel (otd) <otd@odoo.com> | 2021-04-02 08:16:53 +0000 |
|---|---|---|
| committer | Djamel (otd) <otd@odoo.com> | 2021-04-02 13:15:08 +0000 |
| commit | cd9c071c9357cef14635ef094a9f14fc5431956c (patch) | |
| tree | ba426b588d8fffa7ccfa6f4227dd44b15a90e8a8 /addons | |
| parent | 72b7fb15db4df1a3336bc6e90fe60f49877c52f8 (diff) | |
[FIX] account: added a regex verification when adding a partner mapping
Steps to reproduce the bug :
- Go to accounting > Configuration > Reconciliation Models
- Create a new reconciliation model
- Select the “Match existing invoices/bills” type
- In the field “Match Invoice/bill with” choose “Label”
- Add a new partner mapping > encode in "Find text in label" an erroneous regex like “*test” > choose any partner
- Go to accounting Dashboard > click on “Bank”
- Create a new Bank statement> add new transaction without selecting “Partner”
- Post the created bank statements > Reconcile it
Problem :
An error is triggered because the regex is wrong.
opw-2473973
closes odoo/odoo#68683
Signed-off-by: William André (wan) <wan@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/account/i18n/account.pot | 7 | ||||
| -rw-r--r-- | addons/account/models/account_reconcile_model.py | 10 |
2 files changed, 16 insertions, 1 deletions
diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index c846b360ea4..c01eaeab42c 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -11772,6 +11772,13 @@ msgid "" msgstr "" #. module: account +#: code:addons/account/models/account_reconcile_model.py:0 +#, python-format +msgid "" +"The following regular expression is invalid to create a partner mapping: %s" +msgstr "" + +#. module: account #: code:addons/account/models/chart_template.py:0 #, python-format msgid "" diff --git a/addons/account/models/account_reconcile_model.py b/addons/account/models/account_reconcile_model.py index 757702a1612..50b7ea8d219 100644 --- a/addons/account/models/account_reconcile_model.py +++ b/addons/account/models/account_reconcile_model.py @@ -24,7 +24,15 @@ class AccountReconcileModelPartnerMapping(models.Model): for record in self: if not (record.narration_regex or record.payment_ref_regex): raise ValidationError(_("Please set at least one of the match texts to create a partner mapping.")) - + try: + if record.payment_ref_regex: + current_regex = record.payment_ref_regex + re.compile(record.payment_ref_regex) + if record.narration_regex: + current_regex = record.narration_regex + re.compile(record.narration_regex) + except re.error: + raise ValidationError(_("The following regular expression is invalid to create a partner mapping: %s") % current_regex) class AccountReconcileModelLine(models.Model): _name = 'account.reconcile.model.line' |
