[MIG] account_mass_reconcile: Migration to 18.0

pull/817/head
Karthik, Sodexis 2025-03-26 18:51:13 +05:30
parent 5af8e4a8ab
commit 2b567a5307
9 changed files with 55 additions and 40 deletions

View File

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

View File

@ -178,7 +178,7 @@ class MassReconcileAdvanced(models.AbstractModel):
except StopIteration as e:
# if you fall here, you probably missed to put a `yield`
# in `_opposite_matchers()`
raise ValueError("Missing _opposite_matcher: %s" % matcher[0]) from e
raise ValueError(f"Missing _opposite_matcher: {matcher[0]}") from e
if not self._compare_matchers(matcher, opp_matcher):
# if any of the matcher fails, the opposite line
@ -273,7 +273,10 @@ class MassReconcileAdvanced(models.AbstractModel):
# pylint: disable=invalid-commit
reconciled_ids = []
for rec in self:
commit_every = rec.account_id.company_id.reconciliation_commit_every
company = rec.account_id.company_ids.filtered(
lambda c, rec=rec: c.id == rec.env.company.id
)
commit_every = company.reconciliation_commit_every if company else 0
reconcile_groups = []
_logger.info("%d credit lines to reconcile", len(credit_lines))
for idx, credit_line in enumerate(credit_lines, start=1):

View File

@ -62,7 +62,7 @@ class MassReconcileBase(models.AbstractModel):
return self._base_columns()
def _select_query(self, *args, **kwargs):
return "SELECT %s" % ", ".join(self._selection_columns())
return f"SELECT {', '.join(self._selection_columns())}"
def _from_query(self, *args, **kwargs):
return "FROM account_move_line "
@ -92,7 +92,7 @@ class MassReconcileBase(models.AbstractModel):
if self._filter:
dummy, where, params = ml_obj._where_calc(safe_eval(self._filter)).get_sql()
if where:
where = " AND %s" % where
where = f" AND {where}"
return where, params
def _below_writeoff_limit(self, lines, writeoff_limit):

View File

@ -186,7 +186,10 @@ class AccountMassReconcile(models.Model):
)
) from e
ctx = self.env.context.copy()
ctx["commit_every"] = rec.account.company_id.reconciliation_commit_every
company = rec.account.company_ids.filtered(
lambda c, rec=rec: c.id == rec.env.company.id
)
ctx["commit_every"] = company.reconciliation_commit_every if company else 0
if ctx["commit_every"]:
new_cr = sql_db.db_connect(self.env.cr.dbname).cursor()
new_env = api.Environment(new_cr, self.env.uid, ctx)
@ -246,7 +249,7 @@ class AccountMassReconcile(models.Model):
def _open_move_line_list(move_line_ids, name):
return {
"name": name,
"view_mode": "tree,form",
"view_mode": "list,form",
"view_id": False,
"res_model": "account.move.line",
"type": "ir.actions.act_window",

View File

@ -55,7 +55,7 @@ class MassReconcileHistory(models.Model):
name = _("Reconciliations")
return {
"name": name,
"view_mode": "tree,form",
"view_mode": "list,form",
"view_id": False,
"res_model": "account.move.line",
"type": "ir.actions.act_window",

View File

@ -58,7 +58,7 @@ class MassReconcileSimple(models.AbstractModel):
return res
def _simple_order(self, *args, **kwargs):
ret = "ORDER BY account_move_line.%s" % self._key_field
ret = f"ORDER BY account_move_line.{self._key_field}"
if self.date_base_on == "oldest":
ret += ", date"
elif self.date_base_on == "newest":
@ -68,9 +68,9 @@ class MassReconcileSimple(models.AbstractModel):
def _action_rec(self):
"""Match only 2 move lines, do not allow partial reconcile"""
select = self._select_query()
select += ", account_move_line.%s " % self._key_field
select += f", account_move_line.{self._key_field} "
where, params = self._where_query()
where += " AND account_move_line.%s IS NOT NULL " % self._key_field
where += f" AND account_move_line.{self._key_field} IS NOT NULL "
where2, params2 = self._get_filter()
query = " ".join(

View File

@ -231,13 +231,26 @@ class TestScenarioReconcile(AccountTestInvoicingCommon):
currency_rate = fields.first(currency_rate)
currency_rate.rate = 1.5
# create invoice
invoice = self.init_invoice(
move_type="out_invoice",
currency=self.env.ref("base.USD"),
amounts=[50],
invoice_date=fields.Date.today(),
post=True,
invoice = self.env["account.move"].create(
{
"move_type": "out_invoice",
"currency_id": self.env.ref("base.USD").id,
"partner_id": self.partner_a.id,
"invoice_date": fields.Date.today(),
"invoice_line_ids": [
(
0,
0,
{
"name": "Test",
"quantity": 1,
"price_unit": 50,
},
)
],
}
)
invoice.action_post()
self.assertEqual("posted", invoice.state)
self.env["res.currency.rate"].create(
@ -292,11 +305,11 @@ class TestScenarioReconcile(AccountTestInvoicingCommon):
"destination_account_id": receivable_account_id,
"amount": 500.0,
"journal_id": self.bank_journal.id,
"ref": "test ref",
"memo": "test ref",
}
)
payment.action_post()
line_payment = payment.line_ids.filtered(
line_payment = payment.move_id.line_ids.filtered(
lambda line: line.account_id.id == receivable_account_id
)
self.assertEqual(line_payment.reconciled, False)

View File

@ -37,6 +37,7 @@
<field name="unreconciled_count" />
<button
icon="fa-share"
class="oe_link"
name="open_unreconcile"
string="Go to unreconciled items"
type="object"
@ -50,7 +51,7 @@
</page>
<page name="history" string="History">
<field name="history_ids" nolabel="1">
<tree>
<list>
<field name="date" />
<button
icon="fa-share"
@ -58,7 +59,7 @@
string="Go to reconciled items"
type="object"
/>
</tree>
</list>
</field>
</page>
<page name="information" string="Information">
@ -104,19 +105,16 @@ The lines should have the same partner, and the credit entry ref. is matched wit
</page>
</notebook>
</sheet>
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" />
<field name="message_ids" widget="mail_thread" />
</div>
<chatter />
</form>
</field>
</record>
<record id="account_mass_reconcile_tree" model="ir.ui.view">
<field name="name">account.mass.reconcile.tree</field>
<field name="name">account.mass.reconcile.list</field>
<field name="priority">20</field>
<field name="model">account.mass.reconcile</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="name" />
<field name="account" />
<field name="company_id" groups="base.group_multi_company" />
@ -135,14 +133,14 @@ The lines should have the same partner, and the credit entry ref. is matched wit
string="Display items reconciled on the last run"
type="object"
/>
</tree>
</list>
</field>
</record>
<record id="action_account_mass_reconcile" model="ir.actions.act_window">
<field name="name">Mass Automatic Reconcile</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.mass.reconcile</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to add a reconciliation profile.
@ -157,11 +155,11 @@ The lines should have the same partner, and the credit entry ref. is matched wit
</record>
<!-- account.mass.reconcile.method view -->
<record id="account_mass_reconcile_method_tree" model="ir.ui.view">
<field name="name">account.mass.reconcile.method.tree</field>
<field name="name">account.mass.reconcile.method.list</field>
<field name="priority">20</field>
<field name="model">account.mass.reconcile.method</field>
<field name="arch" type="xml">
<tree editable="top">
<list editable="top">
<field name="sequence" widget="handle" />
<field name="name" />
<field name="write_off" />
@ -169,15 +167,15 @@ The lines should have the same partner, and the credit entry ref. is matched wit
<field name="account_profit_id" required="write_off &gt; 0" />
<field name="journal_id" required="write_off &gt; 0" />
<field name="date_base_on" />
</tree>
</list>
</field>
</record>
<!-- menu item -->
<menuitem
action="action_account_mass_reconcile"
id="menu_mass_reconcile"
sequence="30"
parent="account.menu_finance_entries_actions"
sequence="65"
parent="account.menu_finance_entries"
/>
<data noupdate="1">
<record forcecreate="True" id="ir_cron_run_reconciliations" model="ir.cron">
@ -190,8 +188,6 @@ The lines should have the same partner, and the credit entry ref. is matched wit
<field name="user_id" ref="base.user_root" />
<field name="interval_number">3</field>
<field name="interval_type">hours</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="code">model.run_scheduler()</field>
</record>
</data>

View File

@ -66,10 +66,10 @@
</field>
</record>
<record id="mass_reconcile_history_tree" model="ir.ui.view">
<field name="name">mass.reconcile.history.tree</field>
<field name="name">mass.reconcile.history.list</field>
<field name="model">mass.reconcile.history</field>
<field name="arch" type="xml">
<tree>
<list>
<field name="mass_reconcile_id" />
<field name="date" />
<button
@ -78,13 +78,13 @@
string="Go to reconciled items"
type="object"
/>
</tree>
</list>
</field>
</record>
<record id="action_mass_reconcile_history" model="ir.actions.act_window">
<field name="name">Mass Automatic Reconcile History</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mass.reconcile.history</field>
<field name="view_mode">tree,form</field>
<field name="view_mode">list,form</field>
</record>
</odoo>