初始提交

This commit is contained in:
2026-11-04 19:58:07 +08:00
commit 53b7d22429
829 changed files with 469986 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import demo
from . import models
from . import wizard
from odoo import Command
import logging
_logger = logging.getLogger(__name__)
def _account_accountant_post_init(env):
company = env.company
if company.country_id and 'SEPA' in company.country_id.country_group_codes:
module_ids = env['ir.module.module'].search([
('name', 'in', ['account_iso20022', 'account_bank_statement_import_camt']),
('state', '=', 'uninstalled')
])
if module_ids:
module_ids.sudo().button_install()
env['account.chart.template']._load_pre_defined_data({
'res.company': {
'deferred_expense_journal_id',
'deferred_revenue_journal_id',
'deferred_expense_account_id',
'deferred_revenue_account_id',
},
})
def uninstall_hook(env):
# Disable the basic group to remove access menus defined in account
group_basic = env.ref('account.group_account_basic')
group_manager = env.ref('account.group_account_manager')
if group_basic:
group_basic.write({
'user_ids': [Command.clear()],
})
group_manager.write({
'implied_ids': [Command.unlink(group_basic.id)],
})

View File

@@ -0,0 +1,65 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'Invoicing',
'version': '1.1',
'category': 'Accounting/Accounting',
'sequence': 30,
'summary': 'Invoices, Payments, Follow-ups & Bank synchronization (Enterprise)',
'icon': '/account/static/description/icon.png',
'description': """
Invoicing Access Rights
========================
It gives the Administrator user access to important invoicing features such as bank recon and payment follow-up.
""",
'website': 'https://www.odoo.com/app/accounting',
'depends': ['account', 'mail_enterprise', 'web_tour'],
'data': [
'data/ir_cron.xml',
'data/digest_data.xml',
'data/account_accountant_tour.xml',
'data/ir_config_parameters.xml',
'security/account_accountant_security.xml',
'views/account_account_views.xml',
'views/account_fiscal_year_view.xml',
'views/account_journal_dashboard_views.xml',
'views/account_move_views.xml',
'views/account_payment_views.xml',
'views/account_reconcile_views.xml',
'views/account_accountant_menuitems.xml',
'views/digest_views.xml',
'views/res_config_settings_views.xml',
'views/product_views.xml',
'views/bank_rec_widget_views.xml',
'views/report_invoice.xml',
'views/account_journal_views.xml',
'wizard/account_change_lock_date.xml',
'wizard/account_auto_reconcile_wizard.xml',
'wizard/account_reconcile_wizard.xml',
'wizard/bank_rec_auto_reconcile_wizard.xml',
'wizard/account_select_account_line.xml',
'wizard/account_split_journal_item_wizard.xml',
'security/ir.access.csv',
],
'auto_install': True,
'post_init_hook': '_account_accountant_post_init',
'uninstall_hook': "uninstall_hook",
'author': 'Odoo S.A.',
'license': 'OEEL-1',
'assets': {
'web.assets_backend': [
'account_accountant/static/src/js/tours/account_accountant.js',
'account_accountant/static/src/components/**/*',
'account_accountant/static/src/**/*.xml',
],
'web.assets_unit_tests': [
'account_accountant/static/tests/**/*',
('remove', 'account_accountant/static/tests/tours/**/*'),
],
'web.assets_tests': [
'account_accountant/static/tests/tours/**/*',
],
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="account_accountant_tour" model="web_tour.tour">
<field name="name">account_accountant_tour</field>
<field name="sequence">60</field>
<field name="rainbow_man_message"><![CDATA[
<strong><b>Good job!</b> You went through all steps of this tour.</strong>
<br>See how to manage your customer invoices in the <b>Customers/Invoices</b> menu
]]></field>
</record>
</odoo>

View File

@@ -0,0 +1,37 @@
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<data noupdate="1">
<record id="digest.digest_digest_default" model="digest.digest">
<field name="kpi_account_bank_cash">True</field>
</record>
</data>
<data noupdate="0">
<record id="digest_tip_account_accountant_0" model="digest.tip">
<field name="name">Tip: Bulk update journal items</field>
<field name="sequence">900</field>
<field name="group_id" ref="account.group_account_user" />
<field name="tip_description" type="html">
<div>
<b class="tip_title">Tip: Bulk update journal items</b>
<p class="tip_content">From any list view, select multiple records and the list becomes editable. If you update a cell, selected records are updated all at once. Use this feature to update multiple journal entries from the General Ledger, or any Journal view.</p>
<img src="https://download.odoocdn.com/digests/account_accountant/static/src/img/milk-accounting-bulk.gif" width="540" class="illustration_border" />
</div>
</field>
</record>
<record id="digest_tip_account_accountant_1" model="digest.tip">
<field name="name">Tip: Find an Accountant or register your Accounting Firm</field>
<field name="sequence">1000</field>
<field name="group_id" ref="account.group_account_user" />
<field name="tip_description" type="html">
<div>
<b class="tip_title">Tip: Find an Accountant or register your Accounting Firm</b>
<p class="tip_content">Click here to find an accountant or if you want to list out your accounting services on Odoo</p>
<p class="mt-3">
<a class="tip_button" href="https://odoo.com/accounting-firms" target="_blank"><span class="tip_button_text">Find an Accountant</span></a>
<a class="tip_button" href="https://odoo.com/accounting-firms/register" target="_blank"><span class="tip_button_text">Register your Accounting Firm</span></a>
</p>
</div>
</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="1">
<record id="account_accountant.config_bank_rec_payment_tolerance" model="ir.config_parameter">
<field name="key">account_accountant.bank_rec_payment_tolerance</field>
<field name="value">0.00</field>
</record>
<record id="account_accountant.config_bank_rec_foreign_currency_tolerance" model="ir.config_parameter">
<field name="key">account_accountant.bank_rec_foreign_currency_tolerance</field>
<field name="value">0.03</field>
</record>
</data>
</odoo>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="auto_reconcile_bank_statement_line" model="ir.cron">
<field name="name">Try to reconcile automatically your statement lines</field>
<field name="model_id" ref="model_account_bank_statement_line"/>
<field name="state">code</field>
<field name="code">model._cron_try_auto_reconcile_statement_lines(batch_size=100)</field>
<field name='interval_number'>1</field>
<field name='interval_type'>days</field>
</record>
</odoo>

View File

@@ -0,0 +1 @@
from . import account_accountant_demo

View File

@@ -0,0 +1,43 @@
import time
from odoo import models, Command, _
from odoo.addons.account.models.chart_template import template
class AccountChartTemplate(models.AbstractModel):
_inherit = "account.chart.template"
@template(model='account.move', demo=True)
def _account_accountant_account_move_demo(self, template_code):
return {
'demo_invoice_deferred': {
'move_type': 'out_invoice',
'partner_id': 'base.res_partner_1',
'invoice_user_id': 'base.user_admin',
'invoice_date': time.strftime('%Y-01-01'),
'invoice_line_ids': [
Command.create({
'name': _('Subscription 12 months'),
'quantity': 1,
'price_unit': 120,
'deferred_start_date': time.strftime('%Y-01-01'),
'deferred_end_date': time.strftime('%Y-12-31'),
}),
],
},
'demo_bill_deferred': {
'move_type': 'in_invoice',
'partner_id': 'base.res_partner_1',
'invoice_user_id': False,
'invoice_date': time.strftime('%Y-01-01'),
'invoice_line_ids': [
Command.create({
'name': _('Insurance 12 months'),
'quantity': 1,
'price_unit': 1200,
'deferred_start_date': time.strftime('%Y-01-01'),
'deferred_end_date': time.strftime('%Y-12-31'),
}),
],
},
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,116 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_accountant
#
# Translators:
# Martin Trigaux <mat@odoo.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.saas~18+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-08-28 17:51+0000\n"
"PO-Revision-Date: 2017-10-02 11:49+0000\n"
"Last-Translator: Martin Trigaux <mat@odoo.com>, 2017\n"
"Language-Team: Spanish (Chile) (https://www.transifex.com/odoo/teams/41243/"
"es_CL/)\n"
"Language: es_CL\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__create_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__create_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__create_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__create_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__create_uid
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__create_uid
msgid "Created by"
msgstr "Creado por"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__create_date
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__create_date
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__create_date
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__create_date
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__create_date
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__create_date
msgid "Created on"
msgstr "Creado en"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_account__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement_line__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_chart_template__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_journal__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_move__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_payment__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model_line__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_tax__display_name
#: model:ir.model.fields,field_description:account_accountant.field_analytic_mixin__display_name
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_digest_digest__display_name
#: model:ir.model.fields,field_description:account_accountant.field_ir_ui_menu__display_name
#: model:ir.model.fields,field_description:account_accountant.field_mail_message__display_name
#: model:ir.model.fields,field_description:account_accountant.field_res_company__display_name
#: model:ir.model.fields,field_description:account_accountant.field_res_config_settings__display_name
#: model:ir.model.fields,field_description:account_accountant.field_sequence_mixin__display_name
msgid "Display Name"
msgstr "Nombre mostrado"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_account__id
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement__id
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement_line__id
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__id
#: model:ir.model.fields,field_description:account_accountant.field_account_chart_template__id
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__id
#: model:ir.model.fields,field_description:account_accountant.field_account_journal__id
#: model:ir.model.fields,field_description:account_accountant.field_account_move__id
#: model:ir.model.fields,field_description:account_accountant.field_account_move_line__id
#: model:ir.model.fields,field_description:account_accountant.field_account_payment__id
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model__id
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model_line__id
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_account_tax__id
#: model:ir.model.fields,field_description:account_accountant.field_analytic_mixin__id
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_digest_digest__id
#: model:ir.model.fields,field_description:account_accountant.field_ir_ui_menu__id
#: model:ir.model.fields,field_description:account_accountant.field_mail_message__id
#: model:ir.model.fields,field_description:account_accountant.field_res_company__id
#: model:ir.model.fields,field_description:account_accountant.field_res_config_settings__id
#: model:ir.model.fields,field_description:account_accountant.field_sequence_mixin__id
msgid "ID"
msgstr "ID (identificación)"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__write_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__write_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__write_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__write_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__write_uid
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__write_uid
msgid "Last Updated by"
msgstr "Última actualización de"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__write_date
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__write_date
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__write_date
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__write_date
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__write_date
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__write_date
msgid "Last Updated on"
msgstr "Última actualización en"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,76 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_accountant
#
# Translators:
# Martin Trigaux <mat@odoo.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.saas~18+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-08-28 17:51+0000\n"
"PO-Revision-Date: 2017-10-02 11:49+0000\n"
"Last-Translator: Martin Trigaux <mat@odoo.com>, 2017\n"
"Language-Team: French (Canada) (https://www.transifex.com/odoo/teams/41243/"
"fr_CA/)\n"
"Language: fr_CA\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_account__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement_line__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_chart_template__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_journal__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_move__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_payment__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model_line__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_tax__display_name
#: model:ir.model.fields,field_description:account_accountant.field_analytic_mixin__display_name
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_digest_digest__display_name
#: model:ir.model.fields,field_description:account_accountant.field_ir_ui_menu__display_name
#: model:ir.model.fields,field_description:account_accountant.field_mail_message__display_name
#: model:ir.model.fields,field_description:account_accountant.field_res_company__display_name
#: model:ir.model.fields,field_description:account_accountant.field_res_config_settings__display_name
#: model:ir.model.fields,field_description:account_accountant.field_sequence_mixin__display_name
msgid "Display Name"
msgstr "Nom affiché"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_account__id
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement__id
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement_line__id
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__id
#: model:ir.model.fields,field_description:account_accountant.field_account_chart_template__id
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__id
#: model:ir.model.fields,field_description:account_accountant.field_account_journal__id
#: model:ir.model.fields,field_description:account_accountant.field_account_move__id
#: model:ir.model.fields,field_description:account_accountant.field_account_move_line__id
#: model:ir.model.fields,field_description:account_accountant.field_account_payment__id
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model__id
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model_line__id
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_account_tax__id
#: model:ir.model.fields,field_description:account_accountant.field_analytic_mixin__id
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_digest_digest__id
#: model:ir.model.fields,field_description:account_accountant.field_ir_ui_menu__id
#: model:ir.model.fields,field_description:account_accountant.field_mail_message__id
#: model:ir.model.fields,field_description:account_accountant.field_res_company__id
#: model:ir.model.fields,field_description:account_accountant.field_res_config_settings__id
#: model:ir.model.fields,field_description:account_accountant.field_sequence_mixin__id
msgid "ID"
msgstr "Identifiant"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,116 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * account_accountant
#
# Translators:
# Martin Trigaux <mat@odoo.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.saas~18+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-08-28 17:51+0000\n"
"PO-Revision-Date: 2017-10-02 11:49+0000\n"
"Last-Translator: Martin Trigaux <mat@odoo.com>, 2017\n"
"Language-Team: Dutch (Belgium) (https://www.transifex.com/odoo/teams/41243/"
"nl_BE/)\n"
"Language: nl_BE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__create_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__create_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__create_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__create_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__create_uid
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__create_uid
msgid "Created by"
msgstr "Aangemaakt door"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__create_date
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__create_date
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__create_date
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__create_date
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__create_date
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__create_date
msgid "Created on"
msgstr "Aangemaakt op"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_account__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement_line__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_chart_template__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_journal__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_move__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_move_line__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_payment__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model_line__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_account_tax__display_name
#: model:ir.model.fields,field_description:account_accountant.field_analytic_mixin__display_name
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__display_name
#: model:ir.model.fields,field_description:account_accountant.field_digest_digest__display_name
#: model:ir.model.fields,field_description:account_accountant.field_ir_ui_menu__display_name
#: model:ir.model.fields,field_description:account_accountant.field_mail_message__display_name
#: model:ir.model.fields,field_description:account_accountant.field_res_company__display_name
#: model:ir.model.fields,field_description:account_accountant.field_res_config_settings__display_name
#: model:ir.model.fields,field_description:account_accountant.field_sequence_mixin__display_name
msgid "Display Name"
msgstr "Schermnaam"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_account__id
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement__id
#: model:ir.model.fields,field_description:account_accountant.field_account_bank_statement_line__id
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__id
#: model:ir.model.fields,field_description:account_accountant.field_account_chart_template__id
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__id
#: model:ir.model.fields,field_description:account_accountant.field_account_journal__id
#: model:ir.model.fields,field_description:account_accountant.field_account_move__id
#: model:ir.model.fields,field_description:account_accountant.field_account_move_line__id
#: model:ir.model.fields,field_description:account_accountant.field_account_payment__id
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model__id
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_model_line__id
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_account_tax__id
#: model:ir.model.fields,field_description:account_accountant.field_analytic_mixin__id
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__id
#: model:ir.model.fields,field_description:account_accountant.field_digest_digest__id
#: model:ir.model.fields,field_description:account_accountant.field_ir_ui_menu__id
#: model:ir.model.fields,field_description:account_accountant.field_mail_message__id
#: model:ir.model.fields,field_description:account_accountant.field_res_company__id
#: model:ir.model.fields,field_description:account_accountant.field_res_config_settings__id
#: model:ir.model.fields,field_description:account_accountant.field_sequence_mixin__id
msgid "ID"
msgstr "ID"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__write_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__write_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__write_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__write_uid
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__write_uid
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__write_uid
msgid "Last Updated by"
msgstr "Laatst bijgewerkt door"
#. module: account_accountant
#: model:ir.model.fields,field_description:account_accountant.field_account_auto_reconcile_wizard__write_date
#: model:ir.model.fields,field_description:account_accountant.field_account_change_lock_date__write_date
#: model:ir.model.fields,field_description:account_accountant.field_account_fiscal_year__write_date
#: model:ir.model.fields,field_description:account_accountant.field_account_reconcile_wizard__write_date
#: model:ir.model.fields,field_description:account_accountant.field_account_split_journal_item_wizard__write_date
#: model:ir.model.fields,field_description:account_accountant.field_bank_rec_auto_reconcile_wizard__write_date
msgid "Last Updated on"
msgstr "Laatst bijgewerkt op"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_account
from . import account_bank_statement
from . import account_chart_template
from . import account_fiscal_year
from . import account_journal
from . import account_journal_dashboard
from . import account_move
from . import account_payment
from . import account_reconcile_model
from . import account_reconcile_model_line
from . import account_tax
from . import analytic_mixin
from . import digest
from . import mail_message
from . import res_config_settings
from . import res_company
from . import sequence_mixin
from . import ir_ui_menu
from . import res_groups

View File

@@ -0,0 +1,25 @@
import ast
from odoo import models, fields
class AccountAccount(models.Model):
_inherit = "account.account"
is_deferred = fields.Boolean(string="Deferred", tracking=True, help="Check to enable deferred accounting, deferred dates will be required on invoice / bill")
deferred_account_id = fields.Many2one(
comodel_name="account.account",
string="Deferred Account",
copy=False,
check_company=True,
tracking=True,
help="Account automatically used for deferred entries on this account.",
)
def action_open_reconcile(self):
self.ensure_one()
# Open reconciliation view for this account
action_values = self.env['ir.actions.act_window']._for_xml_id('account_accountant.action_move_line_posted_unreconciled')
domain = ast.literal_eval(action_values['domain'])
domain.append(('account_id', '=', self.id))
action_values['domain'] = domain
return action_values

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
from odoo.addons.account.models.chart_template import template
from odoo import models, modules
class AccountChartTemplate(models.AbstractModel):
_inherit = 'account.chart.template'
@template(model='res.company')
def _get_account_accountant_res_company(self, template_code):
# Default values when not defined in the CoA base module
# Should be loaded with _load_pre_defined_data in the post init hook.
company = self.env.company
account_data = self._get_account_account(template_code)
return {
company.id: {
'deferred_expense_journal_id': company.deferred_expense_journal_id.id or 'general',
'deferred_revenue_journal_id': company.deferred_revenue_journal_id.id or 'general',
'deferred_expense_account_id': company.deferred_expense_account_id.id or next((xid for xid, d in account_data.items() if d['account_type'] == 'asset_current'), None),
'deferred_revenue_account_id': company.deferred_revenue_account_id.id or next((xid for xid, d in account_data.items() if d['account_type'] == 'liability_current'), None)
}
}
def _post_load_data(self, template_code, company, template_data):
super()._post_load_data(template_code, company, template_data)
sepa_countries = self.env.ref('base.sepa_zone').country_ids
if company.country_id in sepa_countries:
sepa_module = self.env['ir.module.module'].sudo().search([('name', '=', 'account_iso20022')], limit=1)
if sepa_module and sepa_module.state != 'installed':
if self.env.registry.ready and not modules.module.current_test and not self.env.context.get('install_demo'):
sepa_module.button_immediate_install()
else:
sepa_module.button_install()

View File

@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
from odoo.exceptions import ValidationError
from odoo import api, fields, models, _
from datetime import datetime
class AccountFiscalYear(models.Model):
_name = 'account.fiscal.year'
_description = 'Fiscal Year'
name = fields.Char(string='Name', required=True)
date_from = fields.Date(string='Start Date', required=True,
help='Start Date, included in the fiscal year.')
date_to = fields.Date(string='End Date', required=True,
help='Ending Date, included in the fiscal year.')
company_id = fields.Many2one('res.company', string='Company', required=True,
default=lambda self: self.env.company)
@api.constrains('date_from', 'date_to', 'company_id')
def _check_dates(self):
'''
Check interleaving between fiscal years.
Cases to consider:
s1 s2 e1 e2
( [----)----]
s2 s1 e2 e1
[----(----] )
s1 s2 e2 e1
( [----] )
s2 s1 e1 e2
[----( )----]
'''
for fy in self:
# Starting date must be prior to the ending date
date_from = fy.date_from
date_to = fy.date_to
if date_to < date_from:
raise ValidationError(_('The ending date must not be prior to the starting date.'))
if fy.company_id.parent_id:
raise ValidationError(_('You cannot have a fiscal year on a child company.'))
domain = [
('id', '!=', fy.id),
('company_id', '=', fy.company_id.id),
('date_from', '<=', fy.date_to),
('date_to', '>=', fy.date_from),
]
if self.search_count(domain) > 0:
raise ValidationError(_('You can not have an overlap between two fiscal years, please correct the start and/or end dates of your fiscal years.'))
@api.model_create_multi
def create(self, vals_list):
self.env.cr.cache.pop('cached_fiscalyears_by_company', None)
return super().create(vals_list)
def write(self, vals):
self.env.cr.cache.pop('cached_fiscalyears_by_company', None)
return super().write(vals)
@api.ondelete(at_uninstall=False)
def _unlink_clear_fiscalyear_cache(self):
self.env.cr.cache.pop('cached_fiscalyears_by_company', None)

View File

@@ -0,0 +1,10 @@
from odoo import models
class AccountJournal(models.Model):
_inherit = "account.journal"
def action_open_auto_reconcile_wizard(self):
self.ensure_one()
wizard = self.env['bank.rec.auto.reconcile.wizard'].create({'journal_id': self.id})
return wizard._get_records_action(target='new', name=self.env._("Run Auto Reconciliation"))

View File

@@ -0,0 +1,82 @@
from odoo import models
from odoo.tools import formatLang
class AccountJournal(models.Model):
_inherit = "account.journal"
def action_open_reconcile(self):
self.ensure_one()
if self.type in ('bank', 'cash', 'credit'):
return self.env['account.bank.statement.line']._action_open_bank_reconciliation_widget(
default_context={
'default_journal_id': self.id,
'search_default_journal_id': self.id,
'search_default_not_matched': True,
},
)
else:
# Open reconciliation view for customers/suppliers
return self.env['ir.actions.act_window']._for_xml_id('account_accountant.action_move_line_posted_unreconciled')
def action_open_to_check(self):
self.ensure_one()
return self.env['account.bank.statement.line']._action_open_bank_reconciliation_widget(
default_context={
'search_default_to_check': True,
'search_default_journal_id': self.id,
'default_journal_id': self.id,
},
)
def action_open_bank_transactions(self):
self.ensure_one()
return self.env['account.bank.statement.line']._action_open_bank_reconciliation_widget(
default_context={
'search_default_journal_id': self.id,
'default_journal_id': self.id
},
kanban_first=False,
)
def open_invalid_statements_action(self):
# EXTENDS account
self.ensure_one()
if self.env['account.bank.statement'].search([('journal_id', '=', self.id), ('first_line_index', '=', False)], limit=1):
# Empty statements are not shown in the bank reco widget
return super().open_invalid_statements_action()
return self.env['account.bank.statement.line']._action_open_bank_reconciliation_widget(
extra_domain=[('line_ids.account_id', '=', self.default_account_id.id)],
default_context={
'default_journal_id': self.id,
'search_default_journal_id': self.id,
'search_default_invalid_statement': True,
},
kanban_first=False,
)
def open_action(self):
# EXTENDS account
# set default action for liquidity journals in dashboard
if self.type in ('bank', 'cash', 'credit') and not self.env.context.get('action_name'):
self.ensure_one()
return self.env['account.bank.statement.line']._action_open_bank_reconciliation_widget(
default_context={
'default_journal_id': self.id,
'search_default_journal_id': self.id,
},
)
return super().open_action()
def get_total_journal_amount(self):
balance = ''
if self.exists() and any(
company in self.company_id._accessible_branches() for company in self.env.companies):
balance = formatLang(
self.env,
self.current_statement_balance,
currency_obj=self.currency_id or self.company_id.sudo().currency_id,
)
return {'balance_amount': balance, 'has_invalid_statements': self.has_invalid_statements}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,221 @@
import ast
from collections import defaultdict
from odoo import Command, models
from odoo.tools.float_utils import float_compare
class AccountPayment(models.Model):
_inherit = "account.payment"
def action_open_manual_reconciliation_widget(self):
''' Open the manual reconciliation widget for the current payment.
:return: A dictionary representing an action.
'''
self.ensure_one()
action_values = self.env['ir.actions.act_window']._for_xml_id('account_accountant.action_move_line_posted_unreconciled')
if self.partner_id:
context = ast.literal_eval(action_values['context'])
context.update({'search_default_partner_id': self.partner_id.id})
if self.partner_type == 'customer':
context.update({'search_default_trade_receivable': 1})
elif self.partner_type == 'supplier':
context.update({'search_default_trade_payable': 1})
action_values['context'] = context
return action_values
def button_open_statement_lines(self):
# OVERRIDE
""" Redirect the user to the statement line(s) reconciled to this payment.
:return: An action to open the view of the payment in the reconciliation widget.
"""
self.ensure_one()
default_statement_line = self.reconciled_statement_line_ids[-1]
return self.env['account.bank.statement.line']._action_open_bank_reconciliation_widget(
extra_domain=[('id', 'in', self.reconciled_statement_line_ids.ids)],
default_context={
'create': False,
'default_st_line_id': default_statement_line.id,
'default_journal_id': default_statement_line.journal_id.id,
},
name=self.env._("Matched Transactions")
)
def _get_aml_amount_in_payment_currency(self, aml):
""" Converts the account move line's amount into its payment's (self) currency.
:param aml: the account move line from which the amount has to be converted
:return: the converted account move line amount, in the payment (self) currency
"""
self.ensure_one()
comp_curr = aml.company_id.currency_id
if self.currency_id == aml.currency_id:
amount = aml.amount_residual_currency
elif self.currency_id == comp_curr:
# Foreign currency on aml but the company currency one on the payment.
amount = aml.currency_id._convert(from_amount=aml.amount_residual_currency, to_currency=self.currency_id, date=self.date)
else:
# Currency on payment different from that of the company or aml
amount = comp_curr._convert(from_amount=aml.amount_residual, to_currency=self.currency_id, date=self.date)
return amount
def _get_amls_for_reconciliation(self, st_line):
""" Fetch all amls linked to self, in a context of a bank statement line reconciliation.
Taken in chronological order, returns the account move lines paid by self, in the limit
of the payment amount. If the payment amount is larger than the sum of the amls amount,
an additional residual line will fill the rest.
:param st_line: the statement line for which we need the amls from self
:return: amls_to_create, a list of lines (as dicts) to add to the reconciliation, fetched from self
has_exchange_diff, boolean indicating if an exchange difference was computed for at least one aml
"""
def get_current_amount(payment, line_amount, remaining):
return min(remaining, line_amount) if payment.currency_id.compare_amounts(payment.amount_signed, 0) >= 0 else max(remaining, line_amount)
amls_to_create = []
has_exchange_diff = False
payments_with_move = self.filtered(lambda payment: payment.move_id)
_transaction_amount, transaction_currency, _journal_amount, _journal_currency, _company_amount, company_currency = st_line._get_accounting_amounts_and_currencies()
domain = st_line._get_default_amls_matching_domain()
for payment in payments_with_move:
liquidity_lines, _counterpart_lines, _writeoff_lines = payment._seek_for_lines()
filtered_liquidity_lines = liquidity_lines.filtered_domain(domain)
for payment_move_line in filtered_liquidity_lines:
exchange_diff_balance = st_line._lines_get_account_balance_exchange_diff(payment_move_line.currency_id, payment_move_line.amount_residual, payment_move_line.amount_residual_currency)
has_exchange_diff = has_exchange_diff or not payment_move_line.currency_id.is_zero(exchange_diff_balance)
amls_to_create.append(
payment_move_line._get_aml_values(
balance=-(payment_move_line.amount_residual + exchange_diff_balance),
amount_currency=-payment_move_line.amount_currency,
reconciled_lines_ids=[Command.set(payment_move_line.ids)],
payment_lines_ids=[Command.set(payment.ids)],
),
)
valid_payment_states = ['draft', *self._valid_payment_states()]
for payment in (self - payments_with_move):
if payment.state not in valid_payment_states:
continue
payment_term_lines = payment.invoice_ids.line_ids.filtered(lambda line: line.display_type == "payment_term" and not line.reconciled).sorted("date")
remaining = payment.amount_signed
for line in payment_term_lines:
if payment.currency_id.is_zero(remaining):
break
line_amount = payment._get_aml_amount_in_payment_currency(line)
current_amount = get_current_amount(payment, line_amount, remaining)
exchange_diff_balance = st_line._lines_get_account_balance_exchange_diff(line.currency_id, line.amount_residual, line.amount_residual_currency)
amls_to_add = [line._get_aml_values(
name=line.name,
balance=payment.currency_id._convert(from_amount=-current_amount, to_currency=company_currency, date=st_line.date),
currency_id=payment.currency_id.id,
amount_currency=-current_amount,
reconciled_lines_ids=[Command.set(line.ids)],
payment_lines_ids=[Command.set(payment.ids)],
)]
if line.currency_id == payment.currency_id: # Payments in another currency than the invoice's currently don't handle EPDs
lines_with_epd, _total_amount, total_amount_currency = st_line._apply_early_payment_discount(
line,
current_amount - line_amount,
transaction_currency,
exchange_diff_balance,
)
amls_to_add = lines_with_epd or amls_to_add
current_amount = total_amount_currency or current_amount
if len(lines_with_epd) == 1:
# If the EPD needed a payment with move, we should handle the current payment (without move) already linked to the line invoice.
# It should not be possible to have multiple payments without move for the current line's invoice,
# as current_amount would not have been enough for _apply_early_payment_discount to apply an EPD.
payment_with_move = line.move_id.matched_payment_ids.filtered(lambda pay: pay.move_id and pay.state in valid_payment_states)
if payment.currency_id.compare_amounts(payment.amount_signed, current_amount) == 0:
payment.action_cancel()
body = payment.env._('A payment with entry was created for the related invoice during its reconciliation, replacing this one: %(link)s.',
link=payment_with_move._get_html_link(),
)
payment.message_post(subject=payment.env._('Canceled payment during reconciliation'), body=body)
else:
payment.invoice_ids -= line.move_id
payment.amount -= current_amount
body = payment.env._('A payment with entry was created for an invoice previously linked to this payment: %(link)s.\n'
'Its amount was deducted from this payment.',
link=payment_with_move._get_html_link(),
)
payment.message_post(subject=payment.env._('Modified amount during reconciliation'), body=body)
elif lines_with_epd:
lines_with_epd[0]['payment_lines_ids'] = [Command.set(payment.ids)]
remaining -= current_amount
amls_to_create.extend(amls_to_add)
if remaining:
partner_account = (
payment.partner_id.property_account_payable_id
if payment.payment_type == "outbound"
else payment.partner_id.property_account_receivable_id
)
amls_to_create.append({
'name': payment.name,
'partner_id': payment.partner_id.id,
'account_id': partner_account.id,
'currency_id': payment.currency_id.id,
'amount_currency': -remaining,
'balance': payment.currency_id._convert(from_amount=-remaining, to_currency=company_currency, date=st_line.date),
'payment_lines_ids': [Command.set(payment.ids)],
})
return amls_to_create, has_exchange_diff
def _get_amls_for_payment_without_move(self):
valid_payment_states = ['draft', *self._valid_payment_states()]
lines_to_create = []
for payment in self:
if payment.state not in valid_payment_states:
continue
line2amount = defaultdict(float)
payment_term_lines = payment.invoice_ids.line_ids.filtered(lambda line: line.display_type == "payment_term" and not line.reconciled).sorted("date")
remaining = payment.amount_signed
for line in payment_term_lines:
if not remaining:
break
if float_compare(payment.amount_signed, 0, payment.currency_id.decimal_places) >= 0:
current = min(remaining, line.currency_id._convert(from_amount=line.amount_currency, to_currency=payment.currency_id))
else:
current = max(remaining, line.currency_id._convert(from_amount=line.amount_currency, to_currency=payment.currency_id))
remaining -= current
line2amount[line] -= current
if remaining:
line2amount[False] -= remaining
for line, amount in line2amount.items():
if line:
line_to_create = line._get_aml_values(
name=payment.name,
balance=payment.currency_id._convert(from_amount=amount, to_currency=self.env.company.currency_id),
amount_currency=amount,
reconciled_lines_ids=[Command.set(line.ids)],
payment_lines_ids=[Command.set(payment.ids)],
)
else:
partner_account = (
payment.partner_id.property_account_payable_id
if payment.payment_type == "outbound"
else payment.partner_id.property_account_receivable_id
)
line_to_create = {
'name': payment.name,
'partner_id': payment.partner_id.id,
'account_id': partner_account.id,
'currency_id': payment.currency_id.id,
'amount_currency': amount,
'balance': payment.currency_id._convert(from_amount=amount, to_currency=self.env.company.currency_id),
'payment_lines_ids': [Command.set(payment.ids)],
}
lines_to_create.append(line_to_create)
return lines_to_create

View File

@@ -0,0 +1,426 @@
from collections import defaultdict
from odoo import SUPERUSER_ID, api, fields, models
from odoo.tools import SQL
class AccountReconcileModel(models.Model):
_inherit = 'account.reconcile.model'
# Technical field to know if the rule was created automatically or by a user.
created_automatically = fields.Boolean(default=False, copy=False)
is_asking_for_autopost = fields.Boolean(default=True)
use_count = fields.Integer()
def _apply_lines_for_bank_widget(self, residual_amount_currency, residual_balance, partner, st_line):
""" Apply the reconciliation model lines to the statement line passed as parameter.
:param residual_amount_currency: The open amount currency of the statement line in the bank reconciliation widget
expressed in the statement line currency.
:param residual_balance: The open balance of the statement line in the bank reconciliation widget
expressed in the company currency.
:param partner: The partner set on the wizard.
:param st_line: The statement line processed by the bank reconciliation widget.
:return: A list of python dictionaries (one per reconcile model line) representing
the journal items to be created by the current reconcile model.
"""
self.ensure_one()
currency = st_line.foreign_currency_id or st_line.journal_id.currency_id or st_line.company_currency_id
vals_list = []
for line in self.line_ids:
vals = line._apply_in_bank_widget(
residual_amount_currency=residual_amount_currency,
residual_balance=residual_balance,
partner=line.partner_id or partner,
st_line=st_line,
)
amount_currency = vals['amount_currency']
balance = vals['balance']
if currency.is_zero(amount_currency) and st_line.company_currency_id.is_zero(balance):
continue
vals_list.append(vals)
residual_amount_currency -= amount_currency
residual_balance -= balance
return vals_list
@api.model
def get_available_reconcile_model_per_statement_line(self, statement_line_ids):
self.check_access('read')
self.env['account.reconcile.model'].flush_model()
self.env['account.bank.statement.line'].flush_model()
self.env.cr.execute(SQL(
"""
WITH matching_journal_ids AS (
SELECT account_reconcile_model_id,
ARRAY_AGG(account_journal_id) AS ids
FROM account_journal_account_reconcile_model_rel
GROUP BY account_reconcile_model_id
),
matching_partner_ids AS (
SELECT account_reconcile_model_id,
ARRAY_AGG(res_partner_id) AS ids
FROM account_reconcile_model_res_partner_rel
GROUP BY account_reconcile_model_id
)
SELECT st_line.id AS st_line_id,
array_agg(reco_model.id ORDER BY reco_model.created_automatically ASC NULLS FIRST, reco_model.sequence ASC, reco_model.id ASC) AS reco_model_ids,
array_agg(reco_model.name ORDER BY reco_model.created_automatically ASC NULLS FIRST, reco_model.sequence ASC, reco_model.id ASC) AS reco_model_names
FROM account_bank_statement_line st_line
LEFT JOIN LATERAL (
SELECT DISTINCT reco_model.id,
reco_model.sequence,
reco_model.created_automatically,
COALESCE(reco_model.name -> %(lang)s, reco_model.name -> 'en_US') as name
FROM account_reconcile_model reco_model
LEFT JOIN matching_journal_ids ON reco_model.id = matching_journal_ids.account_reconcile_model_id
LEFT JOIN matching_partner_ids ON reco_model.id = matching_partner_ids.account_reconcile_model_id
LEFT JOIN account_reconcile_model_line reco_model_line ON reco_model_line.model_id = reco_model.id
WHERE (matching_journal_ids.ids IS NULL OR st_line.journal_id = ANY(matching_journal_ids.ids))
AND (matching_partner_ids.ids IS NULL OR st_line.partner_id = ANY(matching_partner_ids.ids))
AND (
CASE COALESCE(reco_model.match_amount, '')
WHEN 'lower' THEN st_line.amount <= reco_model.match_amount_max
WHEN 'greater' THEN st_line.amount >= reco_model.match_amount_min
WHEN 'between' THEN
(st_line.amount BETWEEN reco_model.match_amount_min AND reco_model.match_amount_max) OR
(st_line.amount BETWEEN reco_model.match_amount_max AND reco_model.match_amount_min)
ELSE TRUE
END
)
AND (
reco_model.match_label IS NULL
OR (
reco_model.match_label = 'contains'
AND (
st_line.payment_ref IS NOT NULL AND st_line.payment_ref ILIKE '%%' || reco_model.match_label_param || '%%'
OR st_line.transaction_details IS NOT NULL AND st_line.transaction_details::TEXT ILIKE '%%' || reco_model.match_label_param || '%%'
)
) OR (
reco_model.match_label = 'not_contains'
AND NOT (
st_line.payment_ref IS NOT NULL AND st_line.payment_ref ILIKE '%%' || reco_model.match_label_param || '%%'
OR st_line.transaction_details IS NOT NULL AND st_line.transaction_details::TEXT ILIKE '%%' || reco_model.match_label_param || '%%'
)
) OR (
reco_model.match_label = 'match_regex'
AND (
st_line.payment_ref IS NOT NULL AND st_line.payment_ref ~* reco_model.match_label_param
OR st_line.transaction_details IS NOT NULL AND st_line.transaction_details::TEXT ~* reco_model.match_label_param
)
)
)
AND reco_model.company_id = st_line.company_id
AND reco_model.trigger = 'manual'
AND reco_model_line.account_id IS NOT NULL
AND reco_model.active IS TRUE
) AS reco_model ON TRUE
WHERE st_line.id IN %(statement_lines)s
AND reco_model.id IS NOT NULL
GROUP BY st_line.id
""",
lang=self.env.lang,
statement_lines=tuple(statement_line_ids),
))
query_result = self.env.cr.fetchall()
return {
st_line_id: [
{'id': model_id, 'display_name': model_name}
for (model_id, model_name)
in zip(model_ids, model_names)
]
for st_line_id, model_ids, model_names
in query_result
}
def _apply_reconcile_models(self, statement_lines, remaining_st_line_ids=None, account_ids=None):
if not self or not statement_lines:
return
self.env['account.reconcile.model'].flush_model()
statement_lines.flush_recordset(['journal_id', 'amount', 'amount_residual', 'transaction_details', 'payment_ref', 'partner_id', 'company_id'])
self.env.cr.execute(SQL(r"""
WITH matching_journal_ids AS (
SELECT account_reconcile_model_id,
ARRAY_AGG(account_journal_id) AS ids
FROM account_journal_account_reconcile_model_rel
GROUP BY account_reconcile_model_id
),
matching_partner_ids AS (
SELECT account_reconcile_model_id,
ARRAY_AGG(res_partner_id) AS ids
FROM account_reconcile_model_res_partner_rel
GROUP BY account_reconcile_model_id
),
model_fees AS (
SELECT model_fees.id,
model_fees.trigger,
matching_journal_ids.ids AS journal_ids
FROM account_reconcile_model model_fees
JOIN ir_model_data imd ON model_fees.id = imd.res_id
JOIN account_reconcile_model_line model_lines ON model_lines.model_id = model_fees.id
LEFT JOIN matching_journal_ids ON model_fees.id = matching_journal_ids.account_reconcile_model_id
WHERE imd.module = 'account'
AND imd.name LIKE 'account\_reco\_model\_fee\_%%'
AND model_fees.active IS TRUE
AND model_lines.account_id IS NOT NULL
)
SELECT st_line.id AS st_line_id,
COALESCE(reco_model.id, model_fees.id) AS reco_model_id,
COALESCE(reco_model.trigger, model_fees.trigger) AS trigger
FROM account_bank_statement_line st_line
JOIN account_move move ON st_line.move_id = move.id
LEFT JOIN LATERAL (
SELECT reco_model.id,
reco_model.trigger
FROM account_reconcile_model reco_model
LEFT JOIN matching_journal_ids ON reco_model.id = matching_journal_ids.account_reconcile_model_id
LEFT JOIN matching_partner_ids ON reco_model.id = matching_partner_ids.account_reconcile_model_id
WHERE (matching_journal_ids.ids IS NULL OR st_line.journal_id = ANY(matching_journal_ids.ids))
AND (matching_partner_ids.ids IS NULL OR st_line.partner_id = ANY(matching_partner_ids.ids))
AND (
CASE COALESCE(reco_model.match_amount, '')
WHEN 'lower' THEN st_line.amount <= reco_model.match_amount_max
WHEN 'greater' THEN st_line.amount >= reco_model.match_amount_min
WHEN 'between' THEN
(st_line.amount BETWEEN reco_model.match_amount_min AND reco_model.match_amount_max) OR
(st_line.amount BETWEEN reco_model.match_amount_max AND reco_model.match_amount_min)
ELSE TRUE
END
)
AND (
reco_model.match_label IS NULL
OR (
reco_model.match_label = 'contains'
AND (
st_line.payment_ref IS NOT NULL AND st_line.payment_ref ILIKE '%%' || reco_model.match_label_param || '%%'
OR st_line.transaction_details IS NOT NULL AND st_line.transaction_details::TEXT ILIKE '%%' || reco_model.match_label_param || '%%'
OR move.narration IS NOT NULL AND move.narration::TEXT ILIKE '%%' || reco_model.match_label_param || '%%'
)
) OR (
reco_model.match_label = 'not_contains'
AND NOT (
st_line.payment_ref IS NOT NULL AND st_line.payment_ref ILIKE '%%' || reco_model.match_label_param || '%%'
OR st_line.transaction_details IS NOT NULL AND st_line.transaction_details::TEXT ILIKE '%%' || reco_model.match_label_param || '%%'
OR move.narration IS NOT NULL AND move.narration::TEXT ILIKE '%%' || reco_model.match_label_param || '%%'
)
) OR (
reco_model.match_label = 'match_regex'
AND (
st_line.payment_ref IS NOT NULL AND st_line.payment_ref ~* reco_model.match_label_param
OR st_line.transaction_details IS NOT NULL AND st_line.transaction_details::TEXT ~* reco_model.match_label_param
OR move.narration IS NOT NULL AND move.narration::TEXT ~* reco_model.match_label_param
)
)
)
AND reco_model.id IN %s
AND reco_model.can_be_proposed IS TRUE
AND reco_model.company_id = st_line.company_id
ORDER BY reco_model.created_automatically ASC NULLS FIRST, reco_model.sequence ASC, reco_model.id ASC
LIMIT 1
) AS reco_model ON TRUE
LEFT JOIN LATERAL (
SELECT model_fees.id,
model_fees.trigger
FROM model_fees
WHERE st_line.journal_id = ANY(model_fees.journal_ids)
-- Show model fees if matched amount was 3 %% higher than incoming statement line amount
AND SIGN(st_line.amount) > 0
AND SIGN(st_line.amount_residual) > 0
AND ABS(st_line.amount_residual) < 0.03 * st_line.amount / 1.03
) AS model_fees ON TRUE
WHERE st_line.id IN %s
""", tuple(self.ids), tuple(statement_lines.ids)))
query_result = self.env.cr.fetchall()
processed_st_line_ids = set()
matching_rules = defaultdict(lambda: self.env['account.bank.statement.line'])
# apply the found suitable reco models on the statement lines
for st_line_id, reco_model_id, reco_model_trigger in query_result:
if st_line_id in processed_st_line_ids or reco_model_id is None:
continue
st_line = self.env['account.bank.statement.line'].browse(st_line_id).with_prefetch(statement_lines.ids)
reco_model = self.env['account.reconcile.model'].browse(reco_model_id).with_prefetch(self.ids)
if reco_model_trigger == 'manual':
st_line._action_manual_reco_model(reco_model_id)
elif reco_model.rule_type == 'matching_rule':
matching_rules[reco_model] += st_line
else:
reco_model.with_user(SUPERUSER_ID)._trigger_reconciliation_model(st_line.with_user(SUPERUSER_ID))
processed_st_line_ids.add(st_line_id)
for matching_rule, st_lines in matching_rules.items():
st_lines._try_auto_matching_and_reconcile(st_lines.move_id.ids, remaining_st_line_ids, account_ids, matching_rule=matching_rule)
return remaining_st_line_ids
def _trigger_reconciliation_model(self, statement_line):
self.ensure_one()
liquidity_line, suspense_line, other_lines = statement_line._seek_for_lines()
amls_to_create = list(
self._apply_lines_for_bank_widget(
residual_amount_currency=sum(suspense_line.mapped('amount_currency')),
residual_balance=sum(suspense_line.mapped('balance')),
partner=statement_line.partner_id,
st_line=statement_line,
)
)
# Get the original base lines and tax lines before the creation of new lines
if any(aml.get('tax_ids') for aml in amls_to_create):
original_base_lines, original_tax_lines = statement_line._prepare_for_tax_lines_recomputation()
statement_line._set_move_line_to_statement_line_move(liquidity_line + other_lines, amls_to_create)
# Now that the new lines have been added, we can recompute the taxes
if any(aml.get('tax_ids') for aml in amls_to_create):
_new_liquidity_line, new_suspense_line, _new_other_lines = statement_line._seek_for_lines()
new_lines = statement_line.line_ids - (liquidity_line + other_lines + new_suspense_line)
statement_line._create_tax_lines(original_base_lines, original_tax_lines, new_lines)
if self.next_activity_type_id:
statement_line.activity_schedule(
activity_type_id=self.next_activity_type_id.id,
user_id=self.env.user.id,
)
def _trigger_matching_rule(self, st_line, aml_ids, amls_amount_residual, processed_st_line_ids, allow_partial=True):
""" Reconcile amls with the st_line, respecting the matching order and the payment tolerance of the matching_rule.
We loop into aml_ids until we hit the payment tolerance or the statement line is reconciled or we matched all
account.move.line.
Once we set the aml on the statement line, if we hit the tolerance, apply the matching rule counterparts items.
:param st_line: The statement line to reconcile.
:param aml_ids: List of account.move.line ids to reconcile with the statement line. This list should be the same
order as the one defined on the matching rule.
:param amls_amount_residual: List of account.move.line amount_residual, mapped with aml_ids.
:param processed_st_line_ids: Set of statement line ids, to keep track of reconciled lines.
:param allow_partial: Flag to know if we want to allow partial reconciliation.
"""
def _amount_matches_or_exceeds(st_line_amount, aml_amount):
return (
(st_line_amount < 0 and aml_amount < -st_line_amount) or
(st_line_amount > 0 and aml_amount > -st_line_amount)
)
self.ensure_one()
matched_aml_ids = []
aml_amount_sum = 0
st_line_amount_residual = st_line.amount_residual
matching_tolerance = False
if self.payment_tolerance_type == 'percentage':
tolerance = abs(st_line.amount * (self.payment_tolerance / 100))
else:
tolerance = self.payment_tolerance
amls = self.env['account.move.line'].search_fetch(domain=[('id', 'in', aml_ids)], field_names=['reconciled']).grouped('id')
# We loop until:
# 1. The amount of matched aml exceed the st_line residual amount -> We'll do a partial reconcile on the last aml
# 2. We pop all amls
# 3. We hit the tolerance -> We'll do a full reconcile on the last aml, then apply the counterparts items
#
# aml_ids & amls_amount_residual are ordered the same way
for aml_id, aml_amount_residual in zip(aml_ids, amls_amount_residual):
if not (
_amount_matches_or_exceeds(st_line.amount_residual, aml_amount_sum) and
not matching_tolerance
):
break
aml = amls.get(aml_id)
if aml.reconciled:
continue
# If the aml amount is between the tolerance boundaries, we fully match the aml then stop the loop
if tolerance and -st_line_amount_residual - tolerance <= aml_amount_residual <= -st_line_amount_residual + tolerance:
matched_aml_ids.append(aml_id)
matching_tolerance = True
processed_st_line_ids.add(st_line.id)
# We still check if the st_line residual amount is not in the tolerance boundaries to keep the suspense line in the boundaries
elif abs(st_line_amount_residual) > tolerance and allow_partial:
matched_aml_ids.append(aml_id)
st_line_amount_residual += aml_amount_residual
aml_amount_sum += aml_amount_residual
# Set the matched aml on the st_line, the partial reconcile shouldn't be allowed if we hit the tolerance
st_line.set_line_bank_statement_line(matched_aml_ids, allow_partial=not matching_tolerance and allow_partial)
self.env['account.move.line'].browse(matched_aml_ids).reconcile_model_id = self.id
# If the tolerance has been hit, trigger the reco model to apply the counterpart items if any
if matching_tolerance:
self._trigger_reconciliation_model(st_line)
def trigger_reconciliation_model(self, statement_line_ids):
self.ensure_one()
if self.is_asking_for_autopost:
self.use_count += 1
statement_lines = self.env['account.bank.statement.line'].browse(statement_line_ids).exists()
for statement_line in statement_lines:
self._trigger_reconciliation_model(statement_line)
def write(self, vals):
res = super().write(vals)
unreconciled_domain = [
*self._check_company_domain(self.env.company),
('is_reconciled', '=', False),
]
unreconciled_statement_lines = self.env['account.bank.statement.line'].search(unreconciled_domain)
if unreconciled_statement_lines:
move_lines = self.env['account.move.line'].search([
('reconcile_model_id', 'in', self.ids),
('move_id.statement_line_id', 'any', unreconciled_domain)
])
move_lines.filtered(
lambda line:
line.account_id == line.move_id.journal_id.suspense_account_id
).reconcile_model_id = False
self.filtered(lambda model: model.rule_type == 'reco_model')._apply_reconcile_models(unreconciled_statement_lines)
return res
@api.model_create_multi
def create(self, vals_list):
reco_models = super().create(vals_list)
unreconciled_statement_lines = self.env['account.bank.statement.line'].search([
*self._check_company_domain(self.env.company),
('is_reconciled', '=', False),
])
if unreconciled_statement_lines:
reco_models.filtered(lambda model: model.rule_type == 'reco_model')._apply_reconcile_models(unreconciled_statement_lines)
return reco_models
def action_archive(self):
res = super().action_archive()
unreconciled_statement_lines = self.env['account.bank.statement.line'].search([
*self._check_company_domain(self.env.company),
('is_reconciled', '=', False),
('line_ids.reconcile_model_id', 'in', self.ids),
])
if unreconciled_statement_lines:
unreconciled_statement_lines.line_ids.filtered(
lambda line:
line.account_id == line.move_id.journal_id.suspense_account_id
).reconcile_model_id = False
return res
def _order_to_sql(self, table, order, reverse=False):
sql_order = super()._order_to_sql(table, order, reverse)
if journal_id := self.env.context.get('active_id') or self.env.context.get('default_journal_id'):
return SQL(
"""EXISTS (
SELECT 1
FROM account_journal_account_reconcile_model_rel
WHERE account_reconcile_model_id = %(reco_model_id)s
AND account_journal_id = %(journal_id)s
) DESC, %(sql_order)s""",
reco_model_id=table.id,
journal_id=journal_id,
sql_order=sql_order,
)
return sql_order

View File

@@ -0,0 +1,223 @@
from odoo import Command, _, api, models
from odoo.exceptions import RedirectWarning, UserError
import json
import re
from math import copysign
def split_amount_str(amount_str):
"""
Parse a localized amount string into (int_part, dec_part) as strings
Detects the number format (European/US) purely from the string structure.
See the test test_split_amount_string for examples.
:param amount_str: The amount string to parse.
:return: Tuple of (int_part, dec_part) as strings e.g. ('1334', '07') or ('0', '0') for invalid/empty input.
"""
if not amount_str:
return ('0', '0')
# Normalize NBSP and trim
groupings_re = "[ '\xa0]"
has_grouping = bool(re.search(groupings_re, amount_str))
amount_str = re.sub(groupings_re, "", amount_str).strip()
commas = amount_str.count(',')
dots = amount_str.count('.')
last_comma, last_dot = amount_str.rfind(','), amount_str.rfind('.')
comma_distance = len(amount_str) - 1 - last_comma if last_comma >= 0 else -1
dot_distance = len(amount_str) - 1 - last_dot if last_dot >= 0 else -1
def solitary(int_part, distance):
return (
not has_grouping
and distance == 3
and int_part.isdigit()
and len(int_part) <= 3
and int_part != '0'
)
match (commas, dots):
case (0, 0):
tsep, dsep = ',', '.' # '1334'
case (c, 0) if c > 1:
tsep, dsep = ',', '.' # '1,334,567'
case (0, d) if d > 1:
tsep, dsep = '.', ',' # '1.334.567'
case (c, 1) if c > 1:
tsep, dsep = ',', '.'
case (1, d) if d > 1:
tsep, dsep = '.', ','
case (1, 1) if last_comma > last_dot:
tsep, dsep = '.', ','
case (1, 1):
tsep, dsep = ',', '.'
case (0, 1) if solitary(amount_str[:last_dot], dot_distance):
tsep, dsep = '.', ',' # best possible assumption
case (0, 1):
tsep, dsep = ',', '.'
case (1, 0) if solitary(amount_str[:last_comma], comma_distance):
tsep, dsep = ',', '.' # best possible assumption
case (1, 0):
tsep, dsep = '.', ','
case _:
return ('0', '0')
parts = amount_str.replace(tsep, '').split(dsep)
if len(parts) > 2:
return ('0', '0')
return tuple((parts + ['0'])[:2])
class AccountReconcileModelLine(models.Model):
_inherit = 'account.reconcile.model.line'
def _get_aml_name(self):
""" Return the label to write on the journal item created from this reconcile model line.
'label' is a translatable field, so its value depends on the language of whoever applies
the model: a user working in another language, or the auto-reconciliation cron, which runs
as OdooBot. The same model then writes a different label depending on who applied it. The
journal item belongs to the company, so the company language is used to read the label.
:return: The label, in the language of the company.
"""
self.ensure_one()
lang = self.company_id.partner_id.lang
return self.with_context(lang=lang).label if lang else self.label
def _prepare_aml_vals(self, partner):
""" Prepare a dictionary that will be used later to create a new journal item (account.move.line) for the
given reconcile model line.
:param partner: The partner to be linked to the journal item.
:return: A python dictionary.
"""
self.ensure_one()
taxes = self.tax_ids or self.account_id.tax_ids
if taxes and partner:
fiscal_position = self.env['account.fiscal.position']._get_fiscal_position(partner)
if fiscal_position:
taxes = fiscal_position.map_tax(taxes)
values = {
'name': self._get_aml_name(),
'partner_id': partner.id,
'analytic_distribution': self.analytic_distribution,
'reconcile_model_id': self.model_id.id,
}
if taxes:
values['tax_ids'] = [Command.set(taxes.ids)]
if self.account_id:
values['account_id'] = self.account_id.id
return values
def _apply_in_manual_widget(self, residual_amount_currency, residual_balance, partner, st_line):
""" Prepare a dictionary that will be used later to create a new journal item (account.move.line) for the
given reconcile model line used by the manual reconciliation widget.
:param residual_amount_currency: The current amount currency expressed in the account's currency.
:param residual_balance: The current balance expressed in the company currency.
:param partner: The partner to be linked to the journal item.
:param st_line: The statement line.
:return: A python dictionary.
"""
self.ensure_one()
currency = st_line.foreign_currency_id or st_line.journal_id.currency_id or st_line.company_currency_id
if self.amount_type == 'percentage':
amount_currency = currency.round(residual_amount_currency * (self.amount / 100.0))
balance = st_line.company_currency_id.round(residual_balance * (self.amount / 100.0))
elif self.amount_type == 'fixed':
sign = 1 if residual_amount_currency > 0.0 else -1
amount_currency = currency.round(self.amount * sign)
balance = st_line.company_currency_id.round(self.amount * sign)
else:
raise UserError(_("This reconciliation model can't be used in the manual reconciliation widget because its "
"configuration is not adapted"))
return {
**self._prepare_aml_vals(partner),
'currency_id': currency.id,
'balance': balance,
'amount_currency': amount_currency,
}
def _apply_in_bank_widget(self, residual_amount_currency, residual_balance, partner, st_line):
""" Prepare a dictionary that will be used later to create a new journal item (account.move.line) for the
given reconcile model line used by the bank reconciliation widget.
:param residual_amount_currency: The current amount currency expressed in the statement line's currency.
:param residual_balance: The current balance expressed in the company currency.
:param partner: The partner to be linked to the journal item.
:param st_line: The statement line mounted inside the bank reconciliation widget.
:return: A python dictionary.
"""
self.ensure_one()
currency = st_line.foreign_currency_id or st_line.journal_id.currency_id or st_line.company_currency_id
aml_values = {'currency_id': currency.id}
if self.amount_type == 'percentage_st_line':
_transaction_amount, _transaction_currency, journal_amount, journal_currency, company_amount, company_currency \
= st_line._get_accounting_amounts_and_currencies()
aml_values['amount_currency'] = currency.round(-journal_amount * self.amount / 100.0)
aml_values['balance'] = company_currency.round(-company_amount * self.amount / 100.0)
aml_values['currency_id'] = journal_currency.id
elif self.amount_type == 'regex':
aml_values['amount_currency'] = self._get_amount_currency_by_regex(st_line, residual_amount_currency, self.amount_string)
aml_values['balance'] = currency._convert(aml_values['amount_currency'], st_line.company_currency_id, st_line.company_id, st_line.date)
if 'amount_currency' not in aml_values or 'balance' not in aml_values:
aml_values.update(self._apply_in_manual_widget(
residual_amount_currency=residual_amount_currency,
residual_balance=residual_balance,
partner=partner,
st_line=st_line,
))
else:
aml_values.update(self._prepare_aml_vals(partner))
if not aml_values.get('name', False):
aml_values['name'] = st_line.payment_ref
return aml_values
@api.model
def _get_amount_currency_by_regex(self, st_line, residual_amount_currency, amount_string):
sign = 1 if residual_amount_currency > 0.0 else -1
transaction_details = json.dumps(st_line.transaction_details) if st_line.transaction_details else False
for target_field in (st_line.payment_ref, transaction_details, st_line.narration):
if not target_field:
continue
if match := re.search(amount_string, target_field):
try:
# If there is only one capturing group in the regex, extract the amount from it.
# If there are two capturing groups, then first group have integer part and second group have decimal part of the amount.
groups = match.groups()
if len(groups) >= 2:
group_iter = iter(groups)
int_part = str(next(group_iter) or '0').replace('.', '').replace(',', '')
dec_part = next(group_iter, None)
dec_part = dec_part if dec_part and dec_part.isdigit() else '0'
extracted_balance = float(f'{int_part}.{dec_part}')
else:
extracted_match_group = re.search(r"\d[\d\s.,'\xa0]*", match.group(1))
int_part, dec_part = split_amount_str(extracted_match_group.group())
extracted_balance = float(f"{int_part}.{dec_part}")
return copysign(extracted_balance * sign, residual_amount_currency)
except IndexError: # from .group(1) if the regex doesn't contain a parenthesis part
raise RedirectWarning(_("The regular expression for capturing the counterpart amount appears to be incorrectly formatted.\n"
"Please make sure that the part of the regex capturing the amount is the first (or only) one in parentheses, for example: BRT: ([\\d,.]+)."),
self.model_id._get_records_action(),
_("Open reconcile model")
)
except AttributeError: # from an inconclusive search -> None.group().replace(...)
raise RedirectWarning(_("The regular expression for capturing the counterpart amount appears to be incorrectly formatted.\n"
"Please make sure that the part of the regex capturing the amount (in parentheses) cannot capture an empty value (usually by an incorrect use of ? or *) "
"or any value with no digit. For example: BRT: ([\\d,.]+)."),
self.model_id._get_records_action(),
_("Open reconcile model")
)
return 0.0

View File

@@ -0,0 +1,52 @@
from odoo import models
class AccountTax(models.Model):
_inherit = "account.tax"
def _prepare_base_line_for_taxes_computation(self, record, **kwargs):
# EXTENDS 'account'
results = super()._prepare_base_line_for_taxes_computation(record, **kwargs)
results['deferred_start_date'] = self._get_base_line_field_value_from_record(record, 'deferred_start_date', kwargs, False)
results['deferred_end_date'] = self._get_base_line_field_value_from_record(record, 'deferred_end_date', kwargs, False)
return results
def _prepare_tax_line_for_taxes_computation(self, record, **kwargs):
# EXTENDS 'account'
results = super()._prepare_tax_line_for_taxes_computation(record, **kwargs)
results['deferred_start_date'] = self._get_base_line_field_value_from_record(record, 'deferred_start_date', kwargs, False)
results['deferred_end_date'] = self._get_base_line_field_value_from_record(record, 'deferred_end_date', kwargs, False)
return results
def _prepare_base_line_grouping_key(self, base_line):
# EXTENDS 'account'
results = super()._prepare_base_line_grouping_key(base_line)
results['deferred_start_date'] = base_line['deferred_start_date']
results['deferred_end_date'] = base_line['deferred_end_date']
return results
def _prepare_base_line_tax_repartition_grouping_key(self, base_line, base_line_grouping_key, tax_data, tax_rep_data):
# EXTENDS 'account'
results = super()._prepare_base_line_tax_repartition_grouping_key(base_line, base_line_grouping_key, tax_data, tax_rep_data)
record = base_line['record']
if (
isinstance(record, models.Model)
and record._name == 'account.move.line'
and record._has_deferred_compatible_account()
and base_line['deferred_start_date']
and base_line['deferred_end_date']
and not tax_rep_data['tax_rep'].use_in_tax_closing
):
results['deferred_start_date'] = base_line['deferred_start_date']
results['deferred_end_date'] = base_line['deferred_end_date']
else:
results['deferred_start_date'] = False
results['deferred_end_date'] = False
return results
def _prepare_tax_line_repartition_grouping_key(self, tax_line):
# EXTENDS 'account'
results = super()._prepare_tax_line_repartition_grouping_key(tax_line)
results['deferred_start_date'] = tax_line['deferred_start_date']
results['deferred_end_date'] = tax_line['deferred_end_date']
return results

View File

@@ -0,0 +1,68 @@
from odoo import api, models
from odoo.fields import Domain
class AnalyticMixin(models.AbstractModel):
_inherit = 'analytic.mixin'
@api.model
def _read_group_for_accrual(self, domain, groupby=(), aggregates=(), having=(), offset=0, limit=None, order=None) -> list[tuple]:
""" This method is called instead of usual `_read_group` to compute the
sum of non-storedcomputed fields. It's used in the accrual views,
by `purchase.order.line` and `sale.order.line` models.
"""
aggregates_to_skip, fields_to_patch = self._get_aggregates_to_skip_and_fields_to_patch()
fields_index = {}
for field in fields_to_patch:
field_aggregate = f'{field}:sum'
if field_aggregate in aggregates:
fields_index[field] = aggregates.index(field_aggregate)
if not fields_index.keys():
return super()._read_group(domain, groupby, aggregates, having, offset, limit, order)
aggregates_2_0 = tuple(a for a in aggregates if a not in aggregates_to_skip)
res = super()._read_group(domain, groupby, aggregates_2_0, having, offset, limit, order)
# Make the aggregate sum "manually".
# Pre-fetch all matching records once outside the loop to avoid re-evaluating
# expensive search methods on every group iteration.
field_name = groupby[0]
date_granularity = ''
if ':' in field_name:
# Support of group by date fields.
field_name, date_granularity = field_name.split(':')
all_records = self.env[self._name].search_fetch(
domain=Domain.AND([domain, self._get_accrual_domain()]),
field_names=[field_name],
)
if date_granularity:
records_by_group = dict(
all_records._read_group(
domain=[('id', 'in', all_records.ids)],
groupby=groupby,
aggregates=['id:recordset'],
)
)
else:
records_by_group = all_records.grouped(field_name)
patched_res = []
for group in res:
records = records_by_group.get(group[0], all_records.browse())
new_tuple = list(group)
for field, index in fields_index.items():
sum_qty_received = sum(rec[field] for rec in records)
new_tuple.insert(index + 1, sum_qty_received)
patched_res.append(tuple(new_tuple))
return patched_res
@api.model
def _get_aggregates_to_skip_and_fields_to_patch(self):
return (
['qty_invoiced_at_date:sum', 'amount_to_invoice_at_date:sum'],
['qty_invoiced_at_date', 'amount_to_invoice_at_date']
)
AnalyticMixin._read_group_for_accrual.__override__ = False # whitelist super()

View File

@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import fields, models
class DigestDigest(models.Model):
_inherit = 'digest.digest'
kpi_account_bank_cash = fields.Boolean('Bank & Cash Moves')
kpi_account_bank_cash_value = fields.Monetary(compute='_compute_kpi_account_total_bank_cash_value')
def _compute_kpi_account_total_bank_cash_value(self):
self._raise_if_not_member_of('account.group_account_user')
start, end, companies = self._get_kpi_compute_parameters()
data = self.env['account.move']._read_group([
('date', '>=', start),
('date', '<', end),
('journal_id.type', 'in', ('cash', 'bank')),
('company_id', 'in', companies.ids),
], ['company_id'], ['amount_total:sum'])
data = dict(data)
for record in self:
company = record.company_id or self.env.company
record.kpi_account_bank_cash_value = data.get(company)
def _get_kpi_custom_settings(self, company, user):
res = super()._get_kpi_custom_settings(company, user)
menu_id = self.env.ref('account.menu_finance').id
res['kpi_action']['kpi_account_bank_cash'] = f'account.open_account_journal_dashboard_kanban?menu_id={menu_id}'
res['kpi_sequence']['kpi_account_bank_cash'] = 5550
return res

View File

@@ -0,0 +1,28 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class IrUiMenu(models.Model):
_inherit = 'ir.ui.menu'
def _get_account_readonly_menu_ids(self):
"""
Returns a list of xmlids to hide if the user does not have the `group_account_readonly` group.
"""
return [
'account_accountant.account_tag_menu',
]
def _visible_menu_ids(self, debug=False):
visible_ids = super()._visible_menu_ids(debug)
# These menus should only be visible to accountants (users with group_account_readonly) and the group specified on the menu
# We want to avoid moving these menus to the new `accountant` module
if not self.env.user.has_group('account.group_account_readonly'):
accounting_menus = self._get_account_readonly_menu_ids()
hidden_menu_ids = {
menu_id for ref_menu in accounting_menus
if (menu_id := self.env['ir.model.data']._xmlid_to_res_id(ref_menu))
}
return visible_ids - hidden_menu_ids
return visible_ids

View File

@@ -0,0 +1,10 @@
from odoo import fields, models
class MailMessage(models.Model):
_inherit = 'mail.message'
message_type = fields.Selection(
selection_add=[('transaction_details', "Transaction Details")],
ondelete={'transaction_details': lambda recs: recs.write({'message_type': 'comment'})},
)

View File

@@ -0,0 +1,235 @@
from odoo import models, fields, _
from odoo.tools.misc import DEFAULT_SERVER_DATE_FORMAT
from datetime import timedelta
from odoo.tools import date_utils
class ResCompany(models.Model):
_inherit = 'res.company'
invoicing_switch_threshold = fields.Date(string="Invoicing Switch Threshold", help="Every payment and invoice before this date will receive the 'From Invoicing' status, hiding all the accounting entries related to it. Use this option after installing Accounting if you were using only Invoicing before, before importing all your actual accounting data in to Odoo.")
sign_invoice = fields.Boolean(string='Display signing field on invoices')
signing_user = fields.Many2one(comodel_name='res.users')
# Deferred expense management
deferred_expense_journal_id = fields.Many2one(
comodel_name='account.journal',
string="Deferred Expense Journal",
)
deferred_expense_account_id = fields.Many2one(
comodel_name='account.account',
string="Deferred Expense Account",
)
generate_deferred_expense_entries_method = fields.Selection(
string="Generate Deferred Expense Entries",
selection=[
('on_validation', 'On bill validation'),
('manual', 'Manually & Grouped'),
],
default='on_validation',
required=True,
)
deferred_expense_amount_computation_method = fields.Selection(
string="Deferred Expense Based on",
selection=[
('day', 'By Days'),
('month', 'By Months'),
('full_months', 'By Full Months'),
],
default='month',
required=True,
)
deferred_expense_periodicity = fields.Selection(
string="Deferred Expense Periodicity",
selection=[
('month', "Monthly"),
('year', "Yearly"),
],
default='month',
required=True,
)
# Deferred revenue management
deferred_revenue_journal_id = fields.Many2one(
comodel_name='account.journal',
string="Deferred Revenue Journal",
)
deferred_revenue_account_id = fields.Many2one(
comodel_name='account.account',
string="Deferred Revenue Account",
)
generate_deferred_revenue_entries_method = fields.Selection(
string="Generate Deferred Revenue Entries",
selection=[
('on_validation', 'On invoice validation'),
('manual', 'Manually & Grouped'),
],
default='on_validation',
required=True,
)
deferred_revenue_amount_computation_method = fields.Selection(
string="Deferred Revenue Based on",
selection=[
('day', 'By Days'),
('month', 'By Months'),
('full_months', 'By Full Months'),
],
default='month',
required=True,
)
deferred_revenue_periodicity = fields.Selection(
string="Deferred Revenue Periodicity",
selection=[
('month', "Monthly"),
('year', "Yearly"),
],
default='month',
required=True,
)
def write(self, vals):
old_threshold_vals = {}
for record in self:
old_threshold_vals[record] = record.invoicing_switch_threshold
rslt = super(ResCompany, self).write(vals)
for record in self:
if 'invoicing_switch_threshold' in vals and old_threshold_vals[record] != vals['invoicing_switch_threshold']:
self.env['account.move.line'].flush_model(['move_id', 'parent_state'])
self.env['account.move'].flush_model(['company_id', 'date', 'state', 'payment_state', 'payment_state_before_switch'])
if record.invoicing_switch_threshold:
# If a new date was set as threshold, we switch all the
# posted moves and payments before it to 'invoicing_legacy'.
# We also reset to posted all the moves and payments that
# were 'invoicing_legacy' and were posterior to the threshold
self.env.cr.execute("""
update account_move_line aml
set parent_state = 'posted'
from account_move move
where aml.move_id = move.id
and move.payment_state = 'invoicing_legacy'
and move.date >= %(switch_threshold)s
and move.company_id = %(company_id)s;
update account_move
set state = 'posted',
payment_state = payment_state_before_switch,
payment_state_before_switch = null
where payment_state = 'invoicing_legacy'
and date >= %(switch_threshold)s
and company_id = %(company_id)s;
update account_move_line aml
set parent_state = 'cancel'
from account_move move
where aml.move_id = move.id
and move.state = 'posted'
and move.date < %(switch_threshold)s
and move.company_id = %(company_id)s;
update account_move
set state = 'cancel',
payment_state_before_switch = payment_state,
payment_state = 'invoicing_legacy'
where state = 'posted'
and date < %(switch_threshold)s
and company_id = %(company_id)s;
""", {'company_id': record.id, 'switch_threshold': record.invoicing_switch_threshold})
else:
# If the threshold date has been emptied, we re-post all the
# invoicing_legacy entries.
self.env.cr.execute("""
update account_move_line aml
set parent_state = 'posted'
from account_move move
where aml.move_id = move.id
and move.payment_state = 'invoicing_legacy'
and move.company_id = %(company_id)s;
update account_move
set state = 'posted',
payment_state = payment_state_before_switch,
payment_state_before_switch = null
where payment_state = 'invoicing_legacy'
and company_id = %(company_id)s;
""", {'company_id': record.id})
self.env['account.move.line'].invalidate_model(['parent_state'])
self.env['account.move'].invalidate_model(['state', 'payment_state', 'payment_state_before_switch'])
return rslt
def compute_fiscalyear_dates(self, current_date):
"""Compute the start and end dates of the fiscal year where the given 'date' belongs to.
:param current_date: A datetime.date/datetime.datetime object.
:return: a dictionnary in the form
``{'date_from': ..., 'date_to': ..., ['record': ...]}``
where the ``record`` key can be absent.
"""
self.ensure_one()
date_str = current_date.strftime(DEFAULT_SERVER_DATE_FORMAT)
cache = self.env.cr.cache.setdefault('cached_fiscalyears_by_company', {})
company_cache = cache.setdefault(self.id, [])
for fiscalyear in company_cache:
if fiscalyear['date_from'] <= current_date <= fiscalyear['date_to']:
return fiscalyear
# Search a fiscal year record containing the date.
# If a record is found, then no need further computation, we get the dates range directly.
fiscalyear = self.env['account.fiscal.year'].sudo().search([
('company_id', '=', self.id),
('date_from', '<=', date_str),
('date_to', '>=', date_str),
], limit=1)
if fiscalyear:
res = {
'date_from': fiscalyear.date_from,
'date_to': fiscalyear.date_to,
'record': fiscalyear,
}
company_cache.append(res)
return res
date_from, date_to = date_utils.get_fiscal_year(
current_date, day=self.fiscalyear_last_day, month=int(self.fiscalyear_last_month))
date_from_str = date_from.strftime(DEFAULT_SERVER_DATE_FORMAT)
date_to_str = date_to.strftime(DEFAULT_SERVER_DATE_FORMAT)
# Search for fiscal year records reducing the delta between the date_from/date_to.
# This case could happen if there is a gap between two fiscal year records.
# E.g. two fiscal year records: 2017-01-01 -> 2017-02-01 and 2017-03-01 -> 2017-12-31.
# => The period 2017-02-02 - 2017-02-30 is not covered by a fiscal year record.
fiscalyear_from = self.env['account.fiscal.year'].sudo().search([
('company_id', '=', self.id),
('date_from', '<=', date_from_str),
('date_to', '>=', date_from_str),
], limit=1)
if fiscalyear_from:
date_from = fiscalyear_from.date_to + timedelta(days=1)
fiscalyear_to = self.env['account.fiscal.year'].sudo().search([
('company_id', '=', self.id),
('date_from', '<=', date_to_str),
('date_to', '>=', date_to_str),
], limit=1)
if fiscalyear_to:
date_to = fiscalyear_to.date_from - timedelta(days=1)
res = {'date_from': date_from, 'date_to': date_to}
company_cache.append(res)
return res
def _get_unreconciled_statement_lines_redirect_action(self, unreconciled_statement_lines):
# OVERRIDE account
return self.env['account.bank.statement.line']._action_open_bank_reconciliation_widget(
extra_domain=[('id', 'in', unreconciled_statement_lines.ids)],
name=_('Unreconciled statements lines'),
)

View File

@@ -0,0 +1,141 @@
from datetime import date
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
fiscalyear_last_day = fields.Integer(related='company_id.fiscalyear_last_day', required=True, readonly=False)
fiscalyear_last_month = fields.Selection(related='company_id.fiscalyear_last_month', required=True, readonly=False)
use_anglo_saxon = fields.Boolean(string='Anglo-Saxon Accounting', related='company_id.anglo_saxon_accounting', readonly=False)
invoicing_switch_threshold = fields.Date(string="Invoicing Switch Threshold", related='company_id.invoicing_switch_threshold', readonly=False)
group_fiscal_year = fields.Boolean(string='Fiscal Years', implied_group='account_accountant.group_fiscal_year')
sign_invoice = fields.Boolean(string='Authorized Signatory on invoice', related='company_id.sign_invoice', readonly=False)
signing_user = fields.Many2one(
comodel_name='res.users',
string="Signature used to sign all the invoice",
readonly=False,
related='company_id.signing_user',
help="Select a user here to override every signature on invoice by this user's signature"
)
module_sign = fields.Boolean(string='Sign', compute='_compute_module_sign_status')
# Deferred expense management
deferred_expense_journal_id = fields.Many2one(
comodel_name='account.journal',
help='Journal used for deferred entries',
readonly=False,
related='company_id.deferred_expense_journal_id',
)
deferred_expense_account_id = fields.Many2one(
comodel_name='account.account',
help='Account used for deferred expenses',
readonly=False,
related='company_id.deferred_expense_account_id',
)
deferred_expense_account_active = fields.Boolean(related='deferred_expense_account_id.active', string="Deferred Expense Account Active")
generate_deferred_expense_entries_method = fields.Selection(
related='company_id.generate_deferred_expense_entries_method',
readonly=False, required=True,
help='Method used to generate deferred entries',
)
deferred_expense_amount_computation_method = fields.Selection(
related='company_id.deferred_expense_amount_computation_method',
readonly=False, required=True,
help='Method used to compute the amount of deferred entries',
)
deferred_expense_periodicity = fields.Selection(
related='company_id.deferred_expense_periodicity',
readonly=False, required=True,
help='Periodicity to post deferred entries',
)
# Deferred revenue management
deferred_revenue_journal_id = fields.Many2one(
comodel_name='account.journal',
help='Journal used for deferred entries',
readonly=False,
related='company_id.deferred_revenue_journal_id',
)
deferred_revenue_account_id = fields.Many2one(
comodel_name='account.account',
help='Account used for deferred revenues',
readonly=False,
related='company_id.deferred_revenue_account_id',
)
deferred_revenue_account_active = fields.Boolean(related='deferred_revenue_account_id.active', string="Deferred Revenue Account Active")
generate_deferred_revenue_entries_method = fields.Selection(
related='company_id.generate_deferred_revenue_entries_method',
readonly=False, required=True,
help='Method used to generate deferred entries',
)
deferred_revenue_amount_computation_method = fields.Selection(
related='company_id.deferred_revenue_amount_computation_method',
readonly=False, required=True,
help='Method used to compute the amount of deferred entries',
)
deferred_revenue_periodicity = fields.Selection(
related='company_id.deferred_revenue_periodicity',
readonly=False, required=True,
help='Periodicity to post deferred entries',
)
module_account_transfer = fields.Boolean(string="Enable Auto Transfer")
valuation_method = fields.Selection(
related="company_id.inventory_valuation", required=True,
string="Inventory Valuation", readonly=False)
cost_method = fields.Selection(
related="company_id.cost_method", required=True,
string="Inventory Cost Method", readonly=False)
inventory_period = fields.Selection(
related='company_id.inventory_period', required=True,
string="Inventory Period", readonly=False)
stock_valuation_account_id = fields.Many2one(
'account.account', "Stock Valuation Account", readonly=False,
related='company_id.account_stock_valuation_id', check_company=True)
stock_valuation_account_active = fields.Boolean(related='stock_valuation_account_id.active', string="Stock Valuation Account Active")
stock_journal_id = fields.Many2one(
'account.journal', "Stock Journal", readonly=False,
related='company_id.account_stock_journal_id', check_company=True)
@api.depends('sign_invoice')
def _compute_module_sign_status(self):
sign_installed = 'sign' in self.env['ir.module.module']._installed()
for settings in self:
settings.module_sign = sign_installed or settings.company_id.sign_invoice
@api.constrains('fiscalyear_last_day', 'fiscalyear_last_month')
def _check_fiscalyear(self):
# We try if the date exists in 2020, which is a leap year.
# We do not define the constrain on res.company, since the recomputation of the related
# fields is done one field at a time.
for wiz in self:
try:
date(2020, int(wiz.fiscalyear_last_month), wiz.fiscalyear_last_day)
except ValueError:
raise ValidationError(
_('Incorrect fiscal year date: day is out of range for month. Month: %(month)s; Day: %(day)s',
month=wiz.fiscalyear_last_month, day=wiz.fiscalyear_last_day),
)
@api.model_create_multi
def create(self, vals_list):
# Amazing workaround: non-stored related fields on company are a BAD idea since the 2 fields
# must follow the constraint '_check_fiscalyear_last_day'. The thing is, in case of related
# fields, the inverse write is done one value at a time, and thus the constraint is verified
# one value at a time... so it is likely to fail.
for vals in vals_list:
fiscalyear_last_day = vals.pop('fiscalyear_last_day', False) or self.env.company.fiscalyear_last_day
fiscalyear_last_month = vals.pop('fiscalyear_last_month', False) or self.env.company.fiscalyear_last_month
vals = {}
if fiscalyear_last_day != self.env.company.fiscalyear_last_day:
vals['fiscalyear_last_day'] = fiscalyear_last_day
if fiscalyear_last_month != self.env.company.fiscalyear_last_month:
vals['fiscalyear_last_month'] = fiscalyear_last_month
if vals:
self.env.company.write(vals)
return super().create(vals_list)

View File

@@ -0,0 +1,13 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
class ResGroups(models.Model):
_inherit = 'res.groups'
def _get_light_group_xmlids(self):
return (
*super()._get_light_group_xmlids(),
'account_accountant.group_fiscal_year',
)

View File

@@ -0,0 +1,14 @@
from datetime import date, datetime
from odoo import models
class SequenceMixin(models.AbstractModel):
_inherit = 'sequence.mixin'
def _validate_fiscalyear_difference(self, start_year, end_year):
""" Checks if there exists a fiscal year corresponding to the start and end date """
formatted_start_year = datetime.strptime(start_year, "%y").year if len(start_year) == 2 else int(start_year)
formatted_start_end = datetime.strptime(end_year, "%y").year if len(end_year) == 2 else int(end_year)
computed_fiscalyear = self.env.company.compute_fiscalyear_dates(date(formatted_start_year, 12, 31))
return computed_fiscalyear['date_from'].year == formatted_start_year and computed_fiscalyear['date_to'].year == formatted_start_end

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Add additional XMLIDs to export the overwritten names in this module's POT file -->
<function model="ir.model.data" name="_update_xmlids">
<value model="base" eval="[
{'xml_id': 'account_accountant.group_account_basic', 'record': obj().env.ref('account.group_account_basic')},
]"/>
</function>
<record id="account.group_account_basic" model="res.groups">
<field name="name">Invoicing &amp; Banks</field>
<field name="sequence">30</field>
<field name="comment">adds the accounting dashboard, bank management and follow-up reports.</field>
<field name="privilege_id" ref="account.res_groups_privilege_accounting"/>
<field name="implied_ids" eval="[(3, ref('account.group_account_readonly'))]"/>
</record>
<record id="account.group_account_manager" model="res.groups">
<field name="implied_ids" eval="[(4, ref('account.group_account_basic'))]"/>
</record>
<record id="group_fiscal_year" model="res.groups">
<field name="name">Allow to define fiscal years of more or less than a year</field>
</record>
</odoo>

View File

@@ -0,0 +1,10 @@
id,name,model_id,group_id/id,operation,domain
access_account_change_lock_date,access.account.change.lock.date,account.change.lock.date,account.group_account_manager,cru,
access_account_secure_entries_wizard,access.account.secure.entries.wizard,account.secure.entries.wizard,account.group_account_user,cru,
access_account_auto_reconcile_wizard,access.account.auto.reconcile.wizard,account.auto.reconcile.wizard,account.group_account_user,cru,
access_account_select_account_line,access.account.select.account.line,account.select.account.line,account.group_account_basic,cru,
access_account_reconcile_wizard,access.account.reconcile.wizard,account.reconcile.wizard,account.group_account_user,cru,
access_account_split_journal_item_wizard,account.split.journal.item.wizard,account.split.journal.item.wizard,account.group_account_user,cru,
access_bank_rec_auto_reconcile_wizard,access.bank.rec.auto.reconcile.wizard,bank.rec.auto.reconcile.wizard,account.group_account_basic,cru,
access_account_fiscal_year_readonly,account.fiscal.year.user,account.fiscal.year,account.group_account_readonly,r,
access_account_fiscal_year_manager,account.fiscal.year.manager,account.fiscal.year,account.group_account_manager,crud,
1 id name model_id group_id/id operation domain
2 access_account_change_lock_date access.account.change.lock.date account.change.lock.date account.group_account_manager cru
3 access_account_secure_entries_wizard access.account.secure.entries.wizard account.secure.entries.wizard account.group_account_user cru
4 access_account_auto_reconcile_wizard access.account.auto.reconcile.wizard account.auto.reconcile.wizard account.group_account_user cru
5 access_account_select_account_line access.account.select.account.line account.select.account.line account.group_account_basic cru
6 access_account_reconcile_wizard access.account.reconcile.wizard account.reconcile.wizard account.group_account_user cru
7 access_account_split_journal_item_wizard account.split.journal.item.wizard account.split.journal.item.wizard account.group_account_user cru
8 access_bank_rec_auto_reconcile_wizard access.bank.rec.auto.reconcile.wizard bank.rec.auto.reconcile.wizard account.group_account_basic cru
9 access_account_fiscal_year_readonly account.fiscal.year.user account.fiscal.year account.group_account_readonly r
10 access_account_fiscal_year_manager account.fiscal.year.manager account.fiscal.year account.group_account_manager crud

View File

@@ -0,0 +1,20 @@
import { AttachmentView } from "@mail/core/common/attachment_view";
import { onMounted, t, useProps } from "@odoo/owl";
import { useBus } from "@web/core/utils/hooks";
export class AccountAttachmentView extends AttachmentView {
static components = { AttachmentView };
openInPopout = useProps.static("openInPopout", t.boolean());
setPopout = useProps.static("setPopout", t.function());
setup() {
super.setup();
if (this.openInPopout) {
onMounted(this.onClickPopout);
}
// In the mail_popout_service.js the function pollClosedWindow will trigger a resize event on the main window
// when the external window is closed. It allow us to know when to hide the preview for small screens.
useBus(this.uiService.bus, "resize", () => this.setPopout(false));
}
}

View File

@@ -0,0 +1,105 @@
import { computed, proxy, t, useProps } from "@odoo/owl";
import { registry } from "@web/core/registry";
import { SIZES } from "@web/core/ui/ui_utils";
import { useService } from "@web/core/utils/hooks";
import { ListController } from "@web/views/list/list_controller";
import { ListRenderer, listRendererProps } from "@web/views/list/list_renderer";
import { listView } from "@web/views/list/list_view";
import { AccountAttachmentView } from "./account_attachment_view";
export class AttachmentPreviewListController extends ListController {
static template = "account_accountant.AttachmentPreviewListView";
static components = {
...ListController.components,
AccountAttachmentView,
};
setup() {
super.setup();
/** @type {import("@mail/core/common/store_service").Store} */
this.store = useService("mail.store");
this.ui = useService("ui");
this.mailPopoutService = useService("mail.popout");
this.attachmentPreviewState = proxy({
displayAttachment: localStorage.getItem(this.previewerStorageKey) !== "false",
selectedRecord: false,
thread: null,
});
this.thread = computed(() => this.attachmentPreviewState.thread);
this.popout = proxy({ active: false });
}
get previewEnabled() {
return (
!this.env.searchModel.context.disable_preview &&
(this.ui.size >= SIZES.XXL || this.mailPopoutService.externalWindow)
);
}
togglePreview() {
this.attachmentPreviewState.displayAttachment =
!this.attachmentPreviewState.displayAttachment;
localStorage.setItem(
this.previewerStorageKey,
this.attachmentPreviewState.displayAttachment
);
}
setPopout(value) {
/**
* This function will set the popout value to false or true depending on the situation.
* We set popout to True when clicking on a line that has an attachment and then clicking on the popout button.
* Once the external page is closed, the popout is set to false again.
*/
if (this.attachmentPreviewState.thread?.attachmentsInWebClientView.length) {
this.popout.active = value;
}
}
async setThread(lineData, attachmentField, modelField) {
const attachments = lineData?.data[attachmentField]?.records || [];
if (!lineData || !attachments.length) {
this.attachmentPreviewState.thread = null;
return;
}
const thread = this.store["mail.thread"].insert({
attachments: attachments.map((attachment) => ({
id: attachment.resId,
mimetype: attachment.data.mimetype,
})),
id: lineData.data[modelField].id,
model: lineData.fields[modelField].relation,
});
if (!thread.message_main_attachment_id && thread.attachmentsInWebClientView.length > 0) {
thread.update({ message_main_attachment_id: thread.attachmentsInWebClientView[0] });
}
this.attachmentPreviewState.thread = thread;
}
}
export class AttachmentPreviewListRenderer extends ListRenderer {
props = useProps({
...listRendererProps,
setSelectedRecord: t.any(),
});
async onCellClicked(record, column, ev) {
this.props.setSelectedRecord(record);
await super.onCellClicked(record, column, ev);
}
findFocusFutureCell(cell, cellIsInGroupRow, direction) {
const futureCell = super.findFocusFutureCell(cell, cellIsInGroupRow, direction);
if (futureCell) {
const dataPointId = futureCell.closest("tr").dataset.id;
const record = this.props.list.records.filter((x) => x.id === dataPointId)[0];
this.props.setSelectedRecord(record);
}
return futureCell;
}
}
export const AccountAttachmentListView = {
...listView,
Renderer: AttachmentPreviewListRenderer,
Controller: AttachmentPreviewListController,
};
registry.category("views").add("account_attachment_list", AccountAttachmentListView);

View File

@@ -0,0 +1,67 @@
.o_move_line_list_view {
&.o_view_controller > .o_content {
overflow: hidden;
display: flex;
.o_list_renderer {
@include media-only(screen) {
overflow: auto;
height: 100%;
flex: 1 1 100%;
}
}
}
.o_attachment_preview {
height: 100%;
width: 40%;
.o_attachment_control.toggle {
border-radius: 0 30px 30px 0;
padding: 15px 15px 15px 5px;
&::after {
color: white;
content: '>>';
}
}
&.hidden {
width: 0;
.o_attachment_control.toggle {
right: 0;
border-radius: 30px 0 0 30px;
padding: 15px 0 15px 15px;
&::after {
content: '<';
}
&:hover {
padding-right: 5px;
::after {
content: '<<';
}
}
}
}
}
.o_popout_icon {
position: absolute;
top: 8%;
background-color: black;
opacity: 0.3;
margin-top: -15px;
transition: all 0.3s;
z-index: $zindex-dropdown; // due to the absolute position in o-mail-Attachment-imgContainer
right: 0;
border-radius: 30px 0 0 30px;
padding: 15px 0 15px 15px;
&:hover {
padding-right: 15px;
}
}
@include media-only(print) {
.o_search_panel {
display: none;
}
}
}

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates xml:space="preserve">
<t t-name="account_accountant.AttachmentPreviewListView" t-inherit="web.ListView">
<xpath expr="//div[@t-ref='this.rootRef']" position="attributes" type="add">
<attribute name="class" add="o_move_line_list_view" separator=" "/>
</xpath>
<xpath expr="//t[@t-component='this.props.Renderer']" position="attributes">
<attribute name="setSelectedRecord.bind">this.setSelectedRecord</attribute>
</xpath>
<xpath expr="//Layout" position="inside">
<t t-call="account_accountant.AttachmentPreview"/>
</xpath>
</t>
<t t-name="account_accountant.AttachmentPreview">
<div t-if="this.previewEnabled" class="o_attachment_preview d-print-none" t-att-class="{'hidden': !this.attachmentPreviewState.displayAttachment}">
<t t-if="this.attachmentPreviewState.displayAttachment">
<t t-if="this.attachmentPreviewState.thread and this.attachmentPreviewState.thread.attachmentsInWebClientView.length > 0">
<AccountAttachmentView thread="this.thread" openInPopout="false" setPopout.bind="this.setPopout"/>
</t>
<t t-elif="!this.attachmentPreviewState.selectedRecord">
<p class="text-center">Choose a line to preview its attachments.</p>
</t>
<t t-else="">
<p class="text-center">No attachments linked.</p>
</t>
</t>
<div class="o_attachment_control toggle d-none d-md-block ms-n3" t-on-click="this.togglePreview"/>
</div>
<t t-else="">
<div class="o_popout_icon d-none d-md-block" t-on-click="() => this.setPopout(true)">
<i class="oi" data-icon="fullscreen_exit" title="Open attachment in pop out"/>
</div>
<t t-if="this.popout.active">
<div class="o_attachment_preview d-print-none"
t-if="this.attachmentPreviewState.thread?.attachmentsInWebClientView.length"
>
<AccountAttachmentView thread="this.thread" openInPopout="true" setPopout.bind="this.setPopout"/>
</div>
</t>
</t>
</t>
</templates>

View File

@@ -0,0 +1,42 @@
import { _t } from "@web/core/l10n/translation";
import { registry } from "@web/core/registry";
export const switchPartnerAccount = {
dependencies: ["bus_service", "notification", "orm"],
start(env, { bus_service, notification, orm }) {
bus_service.subscribe(
"switch_partner_account_notification",
({
current_partner_name,
potential_partner_name,
account_number,
partner_bank_id,
potential_partner_id,
}) => {
const closeNotification = notification.add(
_t(
"The bank account %(account_number)s is actually set to partner %(current_partner_name)s, click here to move it to partner %(potential_partner_name)s",
{ account_number, current_partner_name, potential_partner_name }
),
{
type: "info",
buttons: [
{
name: _t("Switch"),
onClick: async () => {
await orm.write("res.partner.bank", [partner_bank_id], {
partner_id: potential_partner_id,
});
closeNotification();
},
},
],
}
);
}
);
bus_service.start();
},
};
registry.category("services").add("switch_partner_account_notification", switchPartnerAccount);

View File

@@ -0,0 +1,80 @@
import { Component, useProps } from "@odoo/owl";
import { standardFieldProps } from "@web/views/fields/standard_field_props";
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
class BankRecWidgetApplyAmountHtmlField extends Component {
props = useProps(standardFieldProps);
static template = "account_accountant.BankRecWidgetApplyAmountHtmlField";
setup() {
this.action = useService("action");
this.orm = useService("orm");
}
get value() {
return this.props.record.data[this.props.name];
}
async switchApplyAmount(ev) {
const root = this.env.model.root;
const fetchReconciledLines = async (fields = []) =>
await this.orm.searchRead(
"account.move.line",
[
[
"id",
"in",
...root.data.reconciled_lines_excluding_exchange_diff_ids._currentIds,
],
],
fields
);
const fetchStatementLines = async (fields = []) =>
await this.orm.searchRead(
"account.move.line",
[["move_id", "=", root.data.move_id.id]],
fields
);
if (ev.target.attributes.name?.value === "action_redirect_to_move") {
const [line] = await fetchReconciledLines([
"amount_residual",
"amount_residual_currency",
"move_id",
]);
await this.openMove(line.move_id[0]);
} else if (ev.target.attributes.name?.value === "apply_full_amount") {
const [line] = await fetchReconciledLines([
"amount_residual",
"amount_residual_currency",
]);
await root.update({
balance: root.data.balance - line.amount_residual,
amount_currency: root.data.amount_currency - line.amount_residual_currency,
});
} else if (ev.target.attributes.name?.value === "apply_partial_amount") {
const lines = await fetchStatementLines(["balance", "amount_currency"]);
// We have all the lines of the entry, we want the amount of the suspense line
await root.update({
balance: lines.at(-1).balance,
amount_currency: lines.at(-1).amount_currency,
});
}
}
openMove(moveId) {
this.action.doAction({
type: "ir.actions.act_window",
res_model: "account.move",
res_id: moveId,
views: [[false, "form"]],
target: "current",
});
}
}
const bankRecWidgetApplyAmountHtmlField = { component: BankRecWidgetApplyAmountHtmlField };
registry.category("fields").add("apply_amount_html", bankRecWidgetApplyAmountHtmlField);

Some files were not shown because too many files have changed in this diff Show More