mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[MIG] account_statement_import_move_line: Migration to version 17.0
TT51242
This commit is contained in:
@@ -49,14 +49,19 @@ To configure this module, you need to:
|
||||
Usage
|
||||
=====
|
||||
|
||||
Journal entries can be imported in two ways, from a new bank statement
|
||||
or from an existing bank statement.
|
||||
|
||||
1. Go to Invoicing > Dashboard.
|
||||
2. Create a new bank statement from a bank journal.
|
||||
3. Click button "Import Journal Items".
|
||||
4. Select filtering options.
|
||||
5. Click on button "Add All Move Lines" to auto-select the move lines
|
||||
matching the selected criteria or click on Add an item to manually
|
||||
select the move lines filtered by the criteria.
|
||||
6. Click on button "Create Statement Lines".
|
||||
2. To import to a new statement, in the relevant bank journal click on
|
||||
‘Import journal items’. To import from an existing bank statement,
|
||||
open the statement form and click on ‘Import journal items’.
|
||||
3. Select the filtering options.
|
||||
4. Click on the ‘Add all transaction lines’ button to automatically
|
||||
select the transaction lines matching the selected criteria or click
|
||||
on Add an item to manually select the transaction lines filtered by
|
||||
the criteria.
|
||||
5. Click the ‘Create extract lines’ button.
|
||||
|
||||
Bug Tracker
|
||||
===========
|
||||
@@ -85,6 +90,7 @@ Contributors
|
||||
- Victor M.M. Torres
|
||||
- João Marques
|
||||
- Ernesto García
|
||||
- Pilar Vargas
|
||||
|
||||
- Pedro Gonzalez <pegonzalezs@gmail.com>
|
||||
|
||||
|
||||
@@ -3,17 +3,18 @@
|
||||
|
||||
{
|
||||
"name": "Bank statement import move lines",
|
||||
"version": "15.0.1.0.0",
|
||||
"version": "17.0.1.0.0",
|
||||
"category": "Accounting",
|
||||
"summary": "Import journal items into bank statement",
|
||||
"author": "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
"maintainers": ["pedrobaeza"],
|
||||
"website": "https://github.com/OCA/bank-statement-import",
|
||||
"depends": ["account"],
|
||||
"depends": ["account_statement_base"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"wizards/account_statement_line_create_view.xml",
|
||||
"views/account_bank_statement_view.xml",
|
||||
"views/account_journal_dashboard_view.xml",
|
||||
],
|
||||
"license": "AGPL-3",
|
||||
"development_status": "Production/Stable",
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
- Victor M.M. Torres
|
||||
- João Marques
|
||||
- Ernesto García
|
||||
- Pilar Vargas
|
||||
- Pedro Gonzalez \<<pegonzalezs@gmail.com>\>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
1. Go to Invoicing \> Dashboard.
|
||||
2. Create a new bank statement from a bank journal.
|
||||
3. Click button "Import Journal Items".
|
||||
4. Select filtering options.
|
||||
5. Click on button "Add All Move Lines" to auto-select the move lines
|
||||
matching the selected criteria or click on Add an item to manually
|
||||
select the move lines filtered by the criteria.
|
||||
6. Click on button "Create Statement Lines".
|
||||
Journal entries can be imported in two ways, from a new bank statement or from an existing bank statement.
|
||||
1. Go to Invoicing > Dashboard.
|
||||
2. To import to a new statement, in the relevant bank journal click on ‘Import journal items’. To import from an existing bank statement, open the statement form and click on ‘Import journal items’.
|
||||
3. Select the filtering options.
|
||||
5. Click on the ‘Add all transaction lines’ button to automatically select the transaction lines matching the selected criteria or click on Add an item to manually select the transaction lines filtered by the criteria.
|
||||
6. Click the ‘Create extract lines’ button.
|
||||
|
||||
@@ -398,15 +398,19 @@ into the bank statement.</p>
|
||||
</div>
|
||||
<div class="section" id="usage">
|
||||
<h1><a class="toc-backref" href="#toc-entry-2">Usage</a></h1>
|
||||
<p>Journal entries can be imported in two ways, from a new bank statement
|
||||
or from an existing bank statement.</p>
|
||||
<ol class="arabic simple">
|
||||
<li>Go to Invoicing > Dashboard.</li>
|
||||
<li>Create a new bank statement from a bank journal.</li>
|
||||
<li>Click button “Import Journal Items”.</li>
|
||||
<li>Select filtering options.</li>
|
||||
<li>Click on button “Add All Move Lines” to auto-select the move lines
|
||||
matching the selected criteria or click on Add an item to manually
|
||||
select the move lines filtered by the criteria.</li>
|
||||
<li>Click on button “Create Statement Lines”.</li>
|
||||
<li>To import to a new statement, in the relevant bank journal click on
|
||||
‘Import journal items’. To import from an existing bank statement,
|
||||
open the statement form and click on ‘Import journal items’.</li>
|
||||
<li>Select the filtering options.</li>
|
||||
<li>Click on the ‘Add all transaction lines’ button to automatically
|
||||
select the transaction lines matching the selected criteria or click
|
||||
on Add an item to manually select the transaction lines filtered by
|
||||
the criteria.</li>
|
||||
<li>Click the ‘Create extract lines’ button.</li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="bug-tracker">
|
||||
@@ -433,6 +437,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
||||
<li>Victor M.M. Torres</li>
|
||||
<li>João Marques</li>
|
||||
<li>Ernesto García</li>
|
||||
<li>Pilar Vargas</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Pedro Gonzalez <<a class="reference external" href="mailto:pegonzalezs@gmail.com">pegonzalezs@gmail.com</a>></li>
|
||||
|
||||
@@ -2,32 +2,15 @@
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0
|
||||
|
||||
from odoo import fields
|
||||
from odoo.tests import TransactionCase
|
||||
from odoo.tests import TransactionCase, tagged
|
||||
|
||||
|
||||
@tagged("post_install", "-at_install")
|
||||
class TestAccountBankStatementImportMoveLine(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestAccountBankStatementImportMoveLine, cls).setUpClass()
|
||||
|
||||
cls.account_type = cls.env["account.account.type"].create(
|
||||
{"name": "Test Account Type", "type": "other", "internal_group": "asset"}
|
||||
)
|
||||
|
||||
cls.a_receivable = cls.env["account.account"].create(
|
||||
{
|
||||
"code": "TAA",
|
||||
"name": "Test Receivable Account",
|
||||
"internal_type": "receivable",
|
||||
"user_type_id": cls.account_type.id,
|
||||
}
|
||||
)
|
||||
cls.partner = cls.env["res.partner"].create(
|
||||
{"name": "Test Partner 2", "parent_id": False}
|
||||
)
|
||||
cls.journal = cls.env["account.journal"].create(
|
||||
{"name": "Test Journal", "type": "sale", "code": "TJS0"}
|
||||
)
|
||||
super().setUpClass()
|
||||
cls.partner = cls.env["res.partner"].create({"name": "Test Partner 2"})
|
||||
cls.journal_bank = cls.env["account.journal"].create(
|
||||
{"name": "Test Journal Bank", "type": "bank", "code": "TJB0"}
|
||||
)
|
||||
@@ -36,14 +19,11 @@ class TestAccountBankStatementImportMoveLine(TransactionCase):
|
||||
"name": "Test Invoice 3",
|
||||
"partner_id": cls.partner.id,
|
||||
"move_type": "out_invoice",
|
||||
"journal_id": cls.journal.id,
|
||||
"ref": "Test",
|
||||
"invoice_line_ids": [
|
||||
(
|
||||
0,
|
||||
0,
|
||||
{
|
||||
"account_id": cls.a_receivable.id,
|
||||
"name": "Test line",
|
||||
"quantity": 1.0,
|
||||
"price_unit": 100.00,
|
||||
@@ -53,8 +33,9 @@ class TestAccountBankStatementImportMoveLine(TransactionCase):
|
||||
}
|
||||
)
|
||||
cls.statement = cls.env["account.bank.statement"].create(
|
||||
{"journal_id": cls.journal_bank.id}
|
||||
{"name": "Test account bank statement import move line"}
|
||||
)
|
||||
cls.statement.journal_id = cls.journal_bank.id
|
||||
|
||||
def test_global(self):
|
||||
self.invoice.action_post()
|
||||
@@ -68,7 +49,6 @@ class TestAccountBankStatementImportMoveLine(TransactionCase):
|
||||
{
|
||||
"statement_id": self.statement.id,
|
||||
"partner_id": self.partner.id,
|
||||
"journal_ids": [(4, self.journal.id)],
|
||||
"allow_blocked": True,
|
||||
"date_type": "move",
|
||||
"move_date": fields.Date.today(),
|
||||
|
||||
@@ -3,18 +3,25 @@
|
||||
<record id="view_bank_statement_form" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.form.population</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="inherit_id" ref="account.view_bank_statement_form" />
|
||||
<field
|
||||
name="inherit_id"
|
||||
ref="account_statement_base.view_bank_statement_form"
|
||||
/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="all_lines_reconciled" position="after">
|
||||
<button name="open_entries" position="after">
|
||||
<button
|
||||
name="%(account_statement_line_create_action)d"
|
||||
string="Import Journal Items"
|
||||
type="action"
|
||||
class="oe_highlight"
|
||||
attrs="{'invisible':[('state', '!=', 'open')]}"
|
||||
class="oe_stat_button"
|
||||
icon="fa-upload"
|
||||
invisible="not id or not journal_id"
|
||||
groups="account.group_account_user"
|
||||
/>
|
||||
</field>
|
||||
>
|
||||
<div class="o_stat_info">
|
||||
<span class="o_stat_text">Import Journal Items</span>
|
||||
</div>
|
||||
</button>
|
||||
</button>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<odoo>
|
||||
<record id="account_journal_dashboard_kanban_view" model="ir.ui.view">
|
||||
<field name="model">account.journal</field>
|
||||
<field name="inherit_id" ref="account.account_journal_dashboard_kanban_view" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//a[@id='create_transaction']/.." position="before">
|
||||
<a
|
||||
name="%(account_statement_line_create_action)d"
|
||||
type="action"
|
||||
groups="account.group_account_user"
|
||||
>
|
||||
Import Journal Items
|
||||
</a>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
@@ -30,9 +30,15 @@ class AccountStatementLineCreate(models.TransientModel):
|
||||
move_date = fields.Date(default=fields.Date.context_today)
|
||||
move_line_ids = fields.Many2many("account.move.line", string="Move Lines")
|
||||
|
||||
@api.model
|
||||
def default_get(self, field_list):
|
||||
res = super().default_get(field_list)
|
||||
res.update(
|
||||
{
|
||||
"target_move": "posted",
|
||||
"date_type": "due",
|
||||
"invoice": True,
|
||||
}
|
||||
)
|
||||
active_model = self.env.context.get("active_model")
|
||||
if active_model == "account.bank.statement":
|
||||
statement = (
|
||||
@@ -43,9 +49,6 @@ class AccountStatementLineCreate(models.TransientModel):
|
||||
if statement:
|
||||
res.update(
|
||||
{
|
||||
"target_move": "posted",
|
||||
"date_type": "due",
|
||||
"invoice": True,
|
||||
"statement_id": statement.id,
|
||||
}
|
||||
)
|
||||
@@ -55,7 +58,11 @@ class AccountStatementLineCreate(models.TransientModel):
|
||||
self.ensure_one()
|
||||
domain = [
|
||||
("reconciled", "=", False),
|
||||
("account_id.internal_type", "in", ("payable", "receivable")),
|
||||
(
|
||||
"account_id.account_type",
|
||||
"in",
|
||||
("asset_receivable", "liability_payable"),
|
||||
),
|
||||
("company_id", "=", self.env.company.id),
|
||||
]
|
||||
if self.journal_ids:
|
||||
@@ -122,7 +129,30 @@ class AccountStatementLineCreate(models.TransientModel):
|
||||
return res
|
||||
|
||||
def create_statement_lines(self):
|
||||
for rec in self:
|
||||
if rec.move_line_ids and rec.statement_id:
|
||||
rec.move_line_ids.create_statement_line_from_move_line(rec.statement_id)
|
||||
if self.move_line_ids:
|
||||
active_model = self.env.context.get("active_model")
|
||||
if active_model == "account.journal":
|
||||
journal = self.env["account.journal"].browse(
|
||||
self.env.context.get("active_id")
|
||||
)
|
||||
statement = self.env["account.bank.statement"].create(
|
||||
{
|
||||
"date": fields.Date.today(),
|
||||
"name": _("%(journal_code)s Statement %(date)s")
|
||||
% {
|
||||
"journal_code": journal.code,
|
||||
"date": fields.Date.today(),
|
||||
},
|
||||
}
|
||||
)
|
||||
statement.journal_id = journal.id
|
||||
self.statement_id = statement.id
|
||||
self.move_line_ids.create_statement_line_from_move_line(self.statement_id)
|
||||
return {
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": "account.bank.statement",
|
||||
"view_mode": "form",
|
||||
"res_id": self.statement_id.id,
|
||||
"target": "current",
|
||||
}
|
||||
return True
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
<field name="date_type" />
|
||||
<field
|
||||
name="move_date"
|
||||
attrs="{'required': [('date_type', '=', 'move')],
|
||||
'invisible': [('date_type', '!=', 'move')]}"
|
||||
required="date_type == 'move'"
|
||||
invisible="date_type != 'move'"
|
||||
/>
|
||||
<field
|
||||
name="due_date"
|
||||
attrs="{'required': [('date_type', '=', 'due')],
|
||||
'invisible': [('date_type', '!=', 'due')]}"
|
||||
required="date_type == 'due'"
|
||||
invisible="date_type != 'due'"
|
||||
/>
|
||||
<field
|
||||
name="journal_ids"
|
||||
@@ -32,23 +32,32 @@
|
||||
string="Click on Add All Move Lines to auto-select the move lines matching the above criteria or click on Add an item to manually select the move lines filtered by the above criteria."
|
||||
colspan="2"
|
||||
/>
|
||||
<button name="populate" type="object" string="Add All Move Lines" />
|
||||
<button
|
||||
name="populate"
|
||||
type="object"
|
||||
colspan="2"
|
||||
string="Add All Move Lines"
|
||||
/>
|
||||
</group>
|
||||
<group name="move_lines" string="Selected Move Lines to Create Lines">
|
||||
<field name="move_line_ids" nolabel="1">
|
||||
<field name="move_line_ids" colspan="2" nolabel="1">
|
||||
<tree>
|
||||
<field name="date" />
|
||||
<field name="move_id" required="0" />
|
||||
<field name="journal_id" />
|
||||
<field name="partner_id" />
|
||||
<field name="account_id" />
|
||||
<field name="date_maturity" />
|
||||
<field name="debit" />
|
||||
<field name="credit" />
|
||||
<field name="amount_residual" sum="Total Residual" />
|
||||
<field name="amount_currency" />
|
||||
<field name="amount_residual_currency" />
|
||||
<field name="company_currency_id" invisible="1" />
|
||||
<field name="date" optional="show" />
|
||||
<field name="move_id" required="0" optional="show" />
|
||||
<field name="journal_id" optional="show" />
|
||||
<field name="partner_id" optional="hide" />
|
||||
<field name="account_id" optional="show" />
|
||||
<field name="date_maturity" optional="show" />
|
||||
<field name="debit" optional="show" />
|
||||
<field name="credit" optional="show" />
|
||||
<field
|
||||
name="amount_residual"
|
||||
sum="Total Residual"
|
||||
optional="show"
|
||||
/>
|
||||
<field name="amount_currency" optional="show" />
|
||||
<field name="amount_residual_currency" optional="show" />
|
||||
<field name="company_currency_id" column_invisible="1" />
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user