account_usability: improve partial reconcile matching_number
This commit is contained in:
committed by
Alexis de Lattre
parent
deb37a1688
commit
c2c4957686
@@ -1,2 +1,3 @@
|
|||||||
from . import models
|
from . import models
|
||||||
from . import wizard
|
from . import wizard
|
||||||
|
from .hooks import post_init_hook
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Account Usability',
|
'name': 'Account Usability',
|
||||||
'version': '14.0.1.0.0',
|
'version': '14.0.1.1.0',
|
||||||
'category': 'Accounting & Finance',
|
'category': 'Accounting & Finance',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'summary': 'Small usability enhancements in account module',
|
'summary': 'Small usability enhancements in account module',
|
||||||
@@ -41,4 +41,5 @@
|
|||||||
],
|
],
|
||||||
'qweb': ['static/src/xml/account_payment.xml'],
|
'qweb': ['static/src/xml/account_payment.xml'],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
"post_init_hook": "post_init_hook",
|
||||||
}
|
}
|
||||||
|
|||||||
9
account_usability/hooks.py
Normal file
9
account_usability/hooks.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright 2022 Akretion (https://www.akretion.com).
|
||||||
|
# @author Sébastien BEAU <sebastien.beau@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import SUPERUSER_ID, api
|
||||||
|
|
||||||
|
def post_init_hook(cr, registry):
|
||||||
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
env["account.move.line"].update_matching_number()
|
||||||
@@ -524,11 +524,6 @@ msgstr ""
|
|||||||
msgid "Recipient Bank"
|
msgid "Recipient Bank"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: account_usability
|
|
||||||
#: model:ir.model.fields,field_description:account_usability.field_account_move_line__reconcile_string
|
|
||||||
msgid "Reconcile"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#. module: account_usability
|
#. module: account_usability
|
||||||
#: model:ir.model.fields,field_description:account_usability.field_account_bank_statement_line__ref
|
#: model:ir.model.fields,field_description:account_usability.field_account_bank_statement_line__ref
|
||||||
#: model:ir.model.fields,field_description:account_usability.field_account_move__ref
|
#: model:ir.model.fields,field_description:account_usability.field_account_move__ref
|
||||||
|
|||||||
9
account_usability/migrations/14.0.1.1.0/post-migrate.py
Normal file
9
account_usability/migrations/14.0.1.1.0/post-migrate.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright 2020 ACSONE SA/NV
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import SUPERUSER_ID, api
|
||||||
|
|
||||||
|
|
||||||
|
def migrate(cr, version):
|
||||||
|
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||||
|
env["account.move.line"].update_matching_number()
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
import logging
|
||||||
from odoo import api, fields, models, _
|
from odoo import api, fields, models, _
|
||||||
from odoo.tools import float_is_zero
|
from odoo.tools import float_is_zero
|
||||||
from odoo.tools.misc import format_date
|
from odoo.tools.misc import format_date
|
||||||
@@ -9,6 +10,8 @@ from odoo.osv import expression
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from odoo.exceptions import UserError
|
from odoo.exceptions import UserError
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AccountMove(models.Model):
|
class AccountMove(models.Model):
|
||||||
_inherit = 'account.move'
|
_inherit = 'account.move'
|
||||||
@@ -238,8 +241,6 @@ class AccountMoveLine(models.Model):
|
|||||||
full_reconcile_id = fields.Many2one(string='Full Reconcile')
|
full_reconcile_id = fields.Many2one(string='Full Reconcile')
|
||||||
matched_debit_ids = fields.One2many(string='Partial Reconcile Debit')
|
matched_debit_ids = fields.One2many(string='Partial Reconcile Debit')
|
||||||
matched_credit_ids = fields.One2many(string='Partial Reconcile Credit')
|
matched_credit_ids = fields.One2many(string='Partial Reconcile Credit')
|
||||||
reconcile_string = fields.Char(
|
|
||||||
compute='_compute_reconcile_string', string='Reconcile', store=True)
|
|
||||||
# for optional display in tree view
|
# for optional display in tree view
|
||||||
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
|
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
|
||||||
|
|
||||||
@@ -255,17 +256,21 @@ class AccountMoveLine(models.Model):
|
|||||||
})
|
})
|
||||||
return action
|
return action
|
||||||
|
|
||||||
@api.depends(
|
def update_matching_number(self):
|
||||||
'full_reconcile_id', 'matched_debit_ids', 'matched_credit_ids')
|
records = self.search([("matching_number", "=", "P")])
|
||||||
def _compute_reconcile_string(self):
|
_logger.info(f"Update partial reconcile number for {len(records)} lines")
|
||||||
for line in self:
|
records._compute_matching_number()
|
||||||
rec_str = False
|
|
||||||
if line.full_reconcile_id:
|
def _compute_matching_number(self):
|
||||||
rec_str = line.full_reconcile_id.name
|
# TODO maybe it will be better to have the same maching_number for
|
||||||
else:
|
# all partial so it will be easier to group by
|
||||||
rec_str = ', '.join([
|
super()._compute_matching_number()
|
||||||
'a%d' % pr.id for pr in line.matched_debit_ids + line.matched_credit_ids])
|
for record in self:
|
||||||
line.reconcile_string = rec_str
|
if record.matching_number == "P":
|
||||||
|
record.matching_number = ", ".join([
|
||||||
|
"a%d" % pr.id
|
||||||
|
for pr in record.matched_debit_ids + record.matched_credit_ids
|
||||||
|
])
|
||||||
|
|
||||||
def _get_computed_name(self):
|
def _get_computed_name(self):
|
||||||
# This is useful when you want to have the product code in a dedicated
|
# This is useful when you want to have the product code in a dedicated
|
||||||
|
|||||||
@@ -42,8 +42,7 @@
|
|||||||
<attribute name="optional">show</attribute>
|
<attribute name="optional">show</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='line_ids']/tree/field[@name='tax_tag_ids']" position="after">
|
<xpath expr="//field[@name='line_ids']/tree/field[@name='tax_tag_ids']" position="after">
|
||||||
<field name="matching_number" optional="hide"/>
|
<field name="matching_number" optional="show"/>
|
||||||
<field name="reconcile_string" optional="show"/>
|
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='product_id']" position="after">
|
<xpath expr="//field[@name='invoice_line_ids']/tree/field[@name='product_id']" position="after">
|
||||||
<field name="product_barcode" optional="hide"/>
|
<field name="product_barcode" optional="hide"/>
|
||||||
@@ -106,7 +105,7 @@
|
|||||||
<separator/>
|
<separator/>
|
||||||
</filter>
|
</filter>
|
||||||
<field name="partner_id" position="after">
|
<field name="partner_id" position="after">
|
||||||
<field name="reconcile_string" />
|
<field name="matching_number" />
|
||||||
<field name="debit" filter_domain="['|', ('debit', '=', self), ('credit', '=', self)]" string="Debit or Credit"/>
|
<field name="debit" filter_domain="['|', ('debit', '=', self), ('credit', '=', self)]" string="Debit or Credit"/>
|
||||||
</field>
|
</field>
|
||||||
<filter name="unreconciled" position="before">
|
<filter name="unreconciled" position="before">
|
||||||
|
|||||||
Reference in New Issue
Block a user