[MIG] account_mass_reconcile: Migration to 15.0

pull/635/head
Miquel Raïch 2023-01-09 11:28:45 +01:00 committed by JasminSForgeFlow
parent dc1180b40e
commit bb2b35e25a
13 changed files with 59 additions and 93 deletions

View File

@ -14,13 +14,13 @@ Account Mass Reconcile
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github
:target: https://github.com/OCA/account-reconcile/tree/14.0/account_mass_reconcile :target: https://github.com/OCA/account-reconcile/tree/15.0/account_mass_reconcile
:alt: OCA/account-reconcile :alt: OCA/account-reconcile
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-reconcile-14-0/account-reconcile-14-0-account_mass_reconcile :target: https://translation.odoo-community.org/projects/account-reconcile-15-0/account-reconcile-15-0-account_mass_reconcile
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/98/14.0 :target: https://runbot.odoo-community.org/runbot/98/15.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -62,7 +62,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-reconcile/issues>`_. Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-reconcile/issues>`_.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_mass_reconcile%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. `feedback <https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_mass_reconcile%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -111,6 +111,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/account-reconcile <https://github.com/OCA/account-reconcile/tree/14.0/account_mass_reconcile>`_ project on GitHub. This module is part of the `OCA/account-reconcile <https://github.com/OCA/account-reconcile/tree/15.0/account_mass_reconcile>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -4,7 +4,7 @@
{ {
"name": "Account Mass Reconcile", "name": "Account Mass Reconcile",
"version": "14.0.1.1.1", "version": "15.0.1.0.0",
"depends": ["account"], "depends": ["account"],
"author": "Akretion,Camptocamp,Odoo Community Association (OCA)", "author": "Akretion,Camptocamp,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/account-reconcile", "website": "https://github.com/OCA/account-reconcile",

View File

@ -4,7 +4,7 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 14.0\n" "Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -25,7 +25,7 @@ msgstr ""
#: code:addons/account_mass_reconcile/models/base_advanced_reconciliation.py:0 #: code:addons/account_mass_reconcile/models/base_advanced_reconciliation.py:0
#, python-format #, python-format
msgid "" msgid ""
"A matcher %s is compared with a matcher %s, the _matchers and " "A matcher %(mkey)s is compared with a matcher %(omkey)s, the _matchers and "
"_opposite_matchers are probably wrong" "_opposite_matchers are probably wrong"
msgstr "" msgstr ""
@ -101,23 +101,15 @@ msgstr ""
#. module: account_mass_reconcile #. module: account_mass_reconcile
#: model_terms:ir.ui.view,arch_db:account_mass_reconcile.account_mass_reconcile_form #: model_terms:ir.ui.view,arch_db:account_mass_reconcile.account_mass_reconcile_form
#: model_terms:ir.ui.view,arch_db:account_mass_reconcile.account_mass_reconcile_tree
msgid "Automatic Mass Reconcile" msgid "Automatic Mass Reconcile"
msgstr "" msgstr ""
#. module: account_mass_reconcile #. module: account_mass_reconcile
#: model_terms:ir.ui.view,arch_db:account_mass_reconcile.account_mass_reconcile_form
#: model_terms:ir.ui.view,arch_db:account_mass_reconcile.mass_reconcile_history_form #: model_terms:ir.ui.view,arch_db:account_mass_reconcile.mass_reconcile_history_form
#: model_terms:ir.ui.view,arch_db:account_mass_reconcile.mass_reconcile_history_tree
#: model_terms:ir.ui.view,arch_db:account_mass_reconcile.view_mass_reconcile_history_search #: model_terms:ir.ui.view,arch_db:account_mass_reconcile.view_mass_reconcile_history_search
msgid "Automatic Mass Reconcile History" msgid "Automatic Mass Reconcile History"
msgstr "" msgstr ""
#. module: account_mass_reconcile
#: model_terms:ir.ui.view,arch_db:account_mass_reconcile.account_mass_reconcile_method_tree
msgid "Automatic Mass Reconcile Method"
msgstr ""
#. module: account_mass_reconcile #. module: account_mass_reconcile
#: code:addons/account_mass_reconcile/models/base_reconciliation.py:0 #: code:addons/account_mass_reconcile/models/base_reconciliation.py:0
#, python-format #, python-format
@ -203,18 +195,12 @@ msgstr ""
#. module: account_mass_reconcile #. module: account_mass_reconcile
#: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile__display_name #: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile_method__display_name #: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile_method__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_name__display_name #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_name__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_ref__display_name #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_ref__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_base__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_history__display_name #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_history__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_options__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_name__display_name #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_name__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_partner__display_name #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_partner__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_reference__display_name #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_reference__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_res_company__display_name
#: model:ir.model.fields,field_description:account_mass_reconcile.field_res_config_settings__display_name
msgid "Display Name" msgid "Display Name"
msgstr "" msgstr ""
@ -250,11 +236,6 @@ msgstr ""
msgid "Followers" msgid "Followers"
msgstr "" msgstr ""
#. module: account_mass_reconcile
#: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile__message_channel_ids
msgid "Followers (Channels)"
msgstr ""
#. module: account_mass_reconcile #. module: account_mass_reconcile
#: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile__message_partner_ids #: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile__message_partner_ids
msgid "Followers (Partners)" msgid "Followers (Partners)"
@ -282,6 +263,11 @@ msgstr ""
msgid "Group By..." msgid "Group By..."
msgstr "" msgstr ""
#. module: account_mass_reconcile
#: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile__has_message
msgid "Has Message"
msgstr ""
#. module: account_mass_reconcile #. module: account_mass_reconcile
#: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile__history_ids #: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile__history_ids
#: model_terms:ir.ui.view,arch_db:account_mass_reconcile.account_mass_reconcile_form #: model_terms:ir.ui.view,arch_db:account_mass_reconcile.account_mass_reconcile_form
@ -304,18 +290,12 @@ msgstr ""
#. module: account_mass_reconcile #. module: account_mass_reconcile
#: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile__id #: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile_method__id #: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile_method__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_name__id #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_name__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_ref__id #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_ref__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_base__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_history__id #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_history__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_options__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_name__id #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_name__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_partner__id #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_partner__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_reference__id #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_reference__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_res_company__id
#: model:ir.model.fields,field_description:account_mass_reconcile.field_res_config_settings__id
msgid "ID" msgid "ID"
msgstr "" msgstr ""
@ -358,18 +338,12 @@ msgstr ""
#. module: account_mass_reconcile #. module: account_mass_reconcile
#: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile____last_update #: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile_method____last_update #: model:ir.model.fields,field_description:account_mass_reconcile.field_account_mass_reconcile_method____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_name____last_update #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_name____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_ref____last_update #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_advanced_ref____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_base____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_history____last_update #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_history____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_options____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_name____last_update #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_name____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_partner____last_update #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_partner____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_reference____last_update #: model:ir.model.fields,field_description:account_mass_reconcile.field_mass_reconcile_simple_reference____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_res_company____last_update
#: model:ir.model.fields,field_description:account_mass_reconcile.field_res_config_settings____last_update
msgid "Last Modified on" msgid "Last Modified on"
msgstr "" msgstr ""

View File

@ -6,7 +6,6 @@ from odoo import models
class MassReconcileAdvancedRef(models.TransientModel): class MassReconcileAdvancedRef(models.TransientModel):
_name = "mass.reconcile.advanced.ref" _name = "mass.reconcile.advanced.ref"
_inherit = "mass.reconcile.advanced" _inherit = "mass.reconcile.advanced"
_description = "Mass Reconcile Advanced Ref" _description = "Mass Reconcile Advanced Ref"
@ -44,7 +43,7 @@ class MassReconcileAdvancedRef(models.TransientModel):
to consider them as "opposite" to consider them as "opposite"
The matchers will be evaluated in the same order as declared The matchers will be evaluated in the same order as declared
vs the the opposite matchers, so you can gain performance by vs the opposite matchers, so you can gain performance by
declaring first the partners with the less computation. declaring first the partners with the less computation.
All matchers should match with their opposite to be considered All matchers should match with their opposite to be considered
@ -54,9 +53,9 @@ class MassReconcileAdvancedRef(models.TransientModel):
:return: tuple of tuples (key, value) where the keys are :return: tuple of tuples (key, value) where the keys are
the matchers keys the matchers keys
(must be the same than `_opposite_matchers` returns, (They must be the same that `_opposite_matchers` returns,
and their values to match in the opposite lines. and their values to match in the opposite lines.
A matching key can have multiples values. A matching key can have multiples values.)
""" """
return ( return (
("partner_id", move_line["partner_id"]), ("partner_id", move_line["partner_id"]),
@ -97,7 +96,7 @@ class MassReconcileAdvancedRef(models.TransientModel):
yield ('ref', (move_line['ref'], move_line['name']) yield ('ref', (move_line['ref'], move_line['name'])
An OR is used between the values for the same key. An OR is used between the values for the same key.
An AND is used between the differents keys. An AND is used between the different keys.
:param dict move_line: values of the move_line :param dict move_line: values of the move_line
:yield: matchers as tuple ('matcher key', value(s)) :yield: matchers as tuple ('matcher key', value(s))
@ -151,7 +150,7 @@ class MassReconcileAdvancedName(models.TransientModel):
to consider them as "opposite" to consider them as "opposite"
The matchers will be evaluated in the same order as declared The matchers will be evaluated in the same order as declared
vs the the opposite matchers, so you can gain performance by vs the opposite matchers, so you can gain performance by
declaring first the partners with the less computation. declaring first the partners with the less computation.
All matchers should match with their opposite to be considered All matchers should match with their opposite to be considered
@ -161,9 +160,9 @@ class MassReconcileAdvancedName(models.TransientModel):
:return: tuple of tuples (key, value) where the keys are :return: tuple of tuples (key, value) where the keys are
the matchers keys the matchers keys
(must be the same than `_opposite_matchers` returns, (They must be the same that `_opposite_matchers` returns,
and their values to match in the opposite lines. and their values to match in the opposite lines.
A matching key can have multiples values. A matching key can have multiples values.)
""" """
return ( return (
("partner_id", move_line["partner_id"]), ("partner_id", move_line["partner_id"]),
@ -204,7 +203,7 @@ class MassReconcileAdvancedName(models.TransientModel):
yield ('ref', (move_line['ref'], move_line['name']) yield ('ref', (move_line['ref'], move_line['name'])
An OR is used between the values for the same key. An OR is used between the values for the same key.
An AND is used between the differents keys. An AND is used between the different keys.
:param dict move_line: values of the move_line :param dict move_line: values of the move_line
:yield: matchers as tuple ('matcher key', value(s)) :yield: matchers as tuple ('matcher key', value(s))

View File

@ -72,9 +72,9 @@ class MassReconcileAdvanced(models.AbstractModel):
:return: tuple of tuples (key, value) where the keys are :return: tuple of tuples (key, value) where the keys are
the matchers keys the matchers keys
(must be the same than `_opposite_matchers` returns, (They must be the same that `_opposite_matchers` returns,
and their values to match in the opposite lines. and their values to match in the opposite lines.
A matching key can have multiples values. A matching key can have multiples values.)
""" """
raise NotImplementedError raise NotImplementedError
@ -112,7 +112,7 @@ class MassReconcileAdvanced(models.AbstractModel):
yield ('ref', (move_line['ref'], move_line['name']) yield ('ref', (move_line['ref'], move_line['name'])
An OR is used between the values for the same key. An OR is used between the values for the same key.
An AND is used between the differents keys. An AND is used between the different keys.
:param dict move_line: values of the move_line :param dict move_line: values of the move_line
:yield: matchers as tuple ('matcher key', value(s)) :yield: matchers as tuple ('matcher key', value(s))
@ -137,7 +137,7 @@ class MassReconcileAdvanced(models.AbstractModel):
@classmethod @classmethod
def _compare_matcher_values(cls, key, values, opposite_values): def _compare_matcher_values(cls, key, values, opposite_values):
"""Compare every values from a matcher vs an opposite matcher """Compare every `values` from a matcher vs an opposite matcher
and return True if it matches and return True if it matches
""" """
for value, ovalue in product(values, opposite_values): for value, ovalue in product(values, opposite_values):
@ -155,9 +155,9 @@ class MassReconcileAdvanced(models.AbstractModel):
mkey, mvalue = matcher mkey, mvalue = matcher
omkey, omvalue = opposite_matcher omkey, omvalue = opposite_matcher
assert mkey == omkey, _( assert mkey == omkey, _(
"A matcher %s is compared with a matcher %s, the _matchers and " "A matcher %(mkey)s is compared with a matcher %(omkey)s, the _matchers and "
"_opposite_matchers are probably wrong" "_opposite_matchers are probably wrong"
) % (mkey, omkey) ) % {"mkey": mkey, "omkey": omkey}
if not isinstance(mvalue, (list, tuple)): if not isinstance(mvalue, (list, tuple)):
mvalue = (mvalue,) mvalue = (mvalue,)
if not isinstance(omvalue, (list, tuple)): if not isinstance(omvalue, (list, tuple)):
@ -175,10 +175,10 @@ class MassReconcileAdvanced(models.AbstractModel):
for matcher in matchers: for matcher in matchers:
try: try:
opp_matcher = next(opp_matchers) opp_matcher = next(opp_matchers)
except StopIteration: except StopIteration as e:
# if you fall here, you probably missed to put a `yield` # if you fall here, you probably missed to put a `yield`
# in `_opposite_matchers()` # in `_opposite_matchers()`
raise ValueError("Missing _opposite_matcher: %s" % matcher[0]) raise ValueError("Missing _opposite_matcher: %s" % matcher[0]) from e
if not self._compare_matchers(matcher, opp_matcher): if not self._compare_matchers(matcher, opp_matcher):
# if any of the matcher fails, the opposite line # if any of the matcher fails, the opposite line
@ -238,9 +238,9 @@ class MassReconcileAdvanced(models.AbstractModel):
def _rec_group_by_chunk(self, reconcile_groups, lines_by_id, chunk_size): def _rec_group_by_chunk(self, reconcile_groups, lines_by_id, chunk_size):
"""Commit after each chunk """Commit after each chunk
:param dict reconcile_grous: all groups to reconcile, will be splitted :param list reconcile_groups: all groups to reconcile, will be split
by chunk by chunk
:param list lines_by_id: list of dict of move lines values, :param dict lines_by_id: dict of move lines values,
the move lines we want to search for the move lines we want to search for
:return: list of reconciled lines :return: list of reconciled lines
""" """
@ -251,23 +251,19 @@ class MassReconcileAdvanced(models.AbstractModel):
# Copy and commit current transient model before creating a new cursor # Copy and commit current transient model before creating a new cursor
# This is required to avoid CacheMiss when using data from `self` # This is required to avoid CacheMiss when using data from `self`
# which is created during current transaction. # which is created during current transaction.
with api.Environment.manage(): with registry(self.env.cr.dbname).cursor() as new_cr:
with registry(self.env.cr.dbname).cursor() as new_cr: new_env = api.Environment(new_cr, self.env.uid, self.env.context)
new_env = api.Environment(new_cr, self.env.uid, self.env.context) self_env = self.with_env(new_env)
self_env = self.with_env(new_env) rec = self_env.create(self.copy_data())
rec = self_env.create(self.copy_data())
for i in range(0, len(reconcile_groups), chunk_size): for i in range(0, len(reconcile_groups), chunk_size):
chunk = reconcile_groups[i : i + chunk_size] chunk = reconcile_groups[i : i + chunk_size]
_logger.debug("Reconcile group chunk %s", chunk) _logger.debug("Reconcile group chunk %s", chunk)
try: try:
with api.Environment.manage(): with registry(self.env.cr.dbname).cursor() as new_cr:
with registry(self.env.cr.dbname).cursor() as new_cr: new_env = api.Environment(new_cr, self.env.uid, self.env.context)
new_env = api.Environment( # Re-use the committed transient we just committed
new_cr, self.env.uid, self.env.context self_env = self.with_env(new_env).browse(rec.id)
) reconciled_ids += self_env._rec_group(chunk, lines_by_id)
# Re-use the commited transient we just commited
self_env = self.with_env(new_env).browse(rec.id)
reconciled_ids += self_env._rec_group(chunk, lines_by_id)
except Exception as e: except Exception as e:
msg = "Reconciliation failed for group chunk %s with error:\n%s" msg = "Reconciliation failed for group chunk %s with error:\n%s"
_logger.exception(msg, chunk, e) _logger.exception(msg, chunk, e)

View File

@ -77,7 +77,7 @@ class MassReconcileBase(models.AbstractModel):
# it would be great to use dict for params # it would be great to use dict for params
# but as we use _where_calc in _get_filter # but as we use _where_calc in _get_filter
# which returns a list, we have to # which returns a list, we have to
# accomodate with that # accommodate with that
params = [self.account_id.id] params = [self.account_id.id]
if self.partner_ids: if self.partner_ids:
where += " AND account_move_line.partner_id IN %s" where += " AND account_move_line.partner_id IN %s"

View File

@ -64,7 +64,6 @@ class AccountMassReconcileMethod(models.Model):
name = fields.Selection("_selection_name", string="Type", required=True) name = fields.Selection("_selection_name", string="Type", required=True)
sequence = fields.Integer( sequence = fields.Integer(
string="Sequence",
default=1, default=1,
required=True, required=True,
help="The sequence field is used to order the reconcile method", help="The sequence field is used to order the reconcile method",
@ -110,8 +109,8 @@ class AccountMassReconcile(models.Model):
) )
rec.last_history = last_history_rs or False rec.last_history = last_history_rs or False
name = fields.Char(string="Name", required=True) name = fields.Char(required=True)
account = fields.Many2one("account.account", string="Account", required=True) account = fields.Many2one("account.account", required=True)
reconcile_method = fields.One2many( reconcile_method = fields.One2many(
"account.mass.reconcile.method", "task_id", string="Method" "account.mass.reconcile.method", "task_id", string="Method"
) )
@ -134,9 +133,9 @@ class AccountMassReconcile(models.Model):
return { return {
"account_id": rec_method.task_id.account.id, "account_id": rec_method.task_id.account.id,
"write_off": rec_method.write_off, "write_off": rec_method.write_off,
"account_lost_id": (rec_method.account_lost_id.id), "account_lost_id": rec_method.account_lost_id.id,
"account_profit_id": (rec_method.account_profit_id.id), "account_profit_id": rec_method.account_profit_id.id,
"journal_id": (rec_method.journal_id.id), "journal_id": rec_method.journal_id.id,
"date_base_on": rec_method.date_base_on, "date_base_on": rec_method.date_base_on,
"_filter": rec_method._filter, "_filter": rec_method._filter,
} }
@ -175,13 +174,13 @@ class AccountMassReconcile(models.Model):
" FOR UPDATE NOWAIT", " FOR UPDATE NOWAIT",
(rec.id,), (rec.id,),
) )
except psycopg2.OperationalError: except psycopg2.OperationalError as e:
raise exceptions.UserError( raise exceptions.UserError(
_( _(
"A mass reconcile is already ongoing for this account, " "A mass reconcile is already ongoing for this account, "
"please try again later." "please try again later."
) )
) ) from e
ctx = self.env.context.copy() ctx = self.env.context.copy()
ctx["commit_every"] = rec.account.company_id.reconciliation_commit_every ctx["commit_every"] = rec.account.company_id.reconciliation_commit_every
if ctx["commit_every"]: if ctx["commit_every"]:
@ -245,7 +244,6 @@ class AccountMassReconcile(models.Model):
"name": name, "name": name,
"view_mode": "tree,form", "view_mode": "tree,form",
"view_id": False, "view_id": False,
"view_type": "form",
"res_model": "account.move.line", "res_model": "account.move.line",
"type": "ir.actions.act_window", "type": "ir.actions.act_window",
"nodestroy": True, "nodestroy": True,
@ -280,7 +278,7 @@ class AccountMassReconcile(models.Model):
"""Launch the reconcile with the oldest run """Launch the reconcile with the oldest run
This function is mostly here to be used with cron task This function is mostly here to be used with cron task
:param run_all: if set it will ingore lookup and launch :param run_all: if set it will ignore lookup and launch
all reconciliation all reconciliation
:returns: True in case of success or raises an exception :returns: True in case of success or raises an exception

View File

@ -57,7 +57,6 @@ class MassReconcileHistory(models.Model):
"name": name, "name": name,
"view_mode": "tree,form", "view_mode": "tree,form",
"view_id": False, "view_id": False,
"view_type": "form",
"res_model": "account.move.line", "res_model": "account.move.line",
"type": "ir.actions.act_window", "type": "ir.actions.act_window",
"nodestroy": True, "nodestroy": True,

View File

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-reconcile/tree/14.0/account_mass_reconcile"><img alt="OCA/account-reconcile" src="https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-reconcile-14-0/account-reconcile-14-0-account_mass_reconcile"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/98/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/account-reconcile/tree/15.0/account_mass_reconcile"><img alt="OCA/account-reconcile" src="https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/account-reconcile-15-0/account-reconcile-15-0-account_mass_reconcile"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/98/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This is a shared work between Akretion and Camptocamp <p>This is a shared work between Akretion and Camptocamp
in order to provide:</p> in order to provide:</p>
<ul class="simple"> <ul class="simple">
@ -410,7 +410,7 @@ reconcile.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-reconcile/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/account-reconcile/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_mass_reconcile%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <a class="reference external" href="https://github.com/OCA/account-reconcile/issues/new?body=module:%20account_mass_reconcile%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -453,7 +453,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-reconcile/tree/14.0/account_mass_reconcile">OCA/account-reconcile</a> project on GitHub.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/account-reconcile/tree/15.0/account_mass_reconcile">OCA/account-reconcile</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

View File

@ -4,7 +4,7 @@
from odoo.tests import common from odoo.tests import common
class TestOnChange(common.SavepointCase): class TestOnChange(common.TransactionCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
super(TestOnChange, cls).setUpClass() super(TestOnChange, cls).setUpClass()

View File

@ -130,7 +130,7 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
"reconcile_method": [(0, 0, {"name": "mass.reconcile.simple.partner"})], "reconcile_method": [(0, 0, {"name": "mass.reconcile.simple.partner"})],
} }
) )
# call the automatic reconcilation method # call the automatic reconciliation method
mass_rec.run_reconcile() mass_rec.run_reconcile()
self.assertEqual("paid", invoice.payment_state) self.assertEqual("paid", invoice.payment_state)
@ -228,7 +228,7 @@ class TestScenarioReconcile(TestAccountReconciliationCommon):
], ],
} }
) )
# call the automatic reconcilation method # call the automatic reconciliation method
mass_rec.run_reconcile() mass_rec.run_reconcile()
self.assertEqual("not_paid", invoice.payment_state) self.assertEqual("not_paid", invoice.payment_state)
mass_rec.reconcile_method.write_off = 0.11 mass_rec.reconcile_method.write_off = 0.11

View File

@ -50,7 +50,7 @@
</page> </page>
<page name="history" string="History"> <page name="history" string="History">
<field name="history_ids" nolabel="1"> <field name="history_ids" nolabel="1">
<tree string="Automatic Mass Reconcile History"> <tree>
<field name="date" /> <field name="date" />
<button <button
icon="fa-share" icon="fa-share"
@ -116,7 +116,7 @@ The lines should have the same partner, and the credit entry ref. is matched wit
<field name="priority">20</field> <field name="priority">20</field>
<field name="model">account.mass.reconcile</field> <field name="model">account.mass.reconcile</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Automatic Mass Reconcile"> <tree>
<field name="name" /> <field name="name" />
<field name="account" /> <field name="account" />
<field name="company_id" groups="base.group_multi_company" /> <field name="company_id" groups="base.group_multi_company" />
@ -161,7 +161,7 @@ The lines should have the same partner, and the credit entry ref. is matched wit
<field name="priority">20</field> <field name="priority">20</field>
<field name="model">account.mass.reconcile.method</field> <field name="model">account.mass.reconcile.method</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree editable="top" string="Automatic Mass Reconcile Method"> <tree editable="top">
<field name="sequence" widget="handle" /> <field name="sequence" widget="handle" />
<field name="name" /> <field name="name" />
<field name="write_off" /> <field name="write_off" />

View File

@ -69,7 +69,7 @@
<field name="name">mass.reconcile.history.tree</field> <field name="name">mass.reconcile.history.tree</field>
<field name="model">mass.reconcile.history</field> <field name="model">mass.reconcile.history</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree string="Automatic Mass Reconcile History"> <tree>
<field name="mass_reconcile_id" /> <field name="mass_reconcile_id" />
<field name="date" /> <field name="date" />
<button <button