Skip to content

Commit

Permalink
[IMP] account_bank_statement_import_move_line: black, isort, prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-p-marques authored and Luis D. Lafaurie committed May 4, 2022
1 parent 24346eb commit 77762b8
Show file tree
Hide file tree
Showing 6 changed files with 225 additions and 195 deletions.
33 changes: 15 additions & 18 deletions account_statement_import_move_line/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html

{
'name': 'Bank statement import move lines',
'version': '12.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',
"name": "Bank statement import move lines",
"version": "12.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",],
"data": [
"wizards/account_statement_line_create_view.xml",
"views/account_bank_statement_view.xml",
],
'data': [
'wizards/account_statement_line_create_view.xml',
'views/account_bank_statement_view.xml',
],
'license': 'AGPL-3',
'development_status': 'Production/Stable',
'installable': True,
'auto_install': False,
"license": "AGPL-3",
"development_status": "Production/Stable",
"installable": True,
"auto_install": False,
}
20 changes: 10 additions & 10 deletions account_statement_import_move_line/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
_inherit = "account.move.line"

@api.multi
def _prepare_statement_line_vals(self, statement):
Expand All @@ -16,20 +16,20 @@ def _prepare_statement_line_vals(self, statement):
elif self.credit > 0:
amount = -self.credit
vals = {
'name': self.name or '?',
'amount': amount,
'partner_id': self.partner_id.id,
'statement_id': statement.id,
'ref': self.ref,
'date': self.date_maturity,
'amount_currency': self.amount_currency,
'currency_id': self.currency_id.id,
"name": self.name or "?",
"amount": amount,
"partner_id": self.partner_id.id,
"statement_id": statement.id,
"ref": self.ref,
"date": self.date_maturity,
"amount_currency": self.amount_currency,
"currency_id": self.currency_id.id,
}
return vals

@api.multi
def create_statement_line_from_move_line(self, statement):
abslo = self.env['account.bank.statement.line']
abslo = self.env["account.bank.statement.line"]
for mline in self:
abslo.create(mline._prepare_statement_line_vals(statement))
return
Original file line number Diff line number Diff line change
@@ -1,64 +1,75 @@
# Copyright 2017 Tecnativa - Luis M. Ontalba
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0

from odoo.tests import common
from odoo import fields
from odoo.tests import common


class TestAccountBankStatementImportMoveLine(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestAccountBankStatementImportMoveLine, cls).setUpClass()
cls.account_type = cls.env['account.account.type'].create({
'name': 'Test Account Type'})
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': 'bank',
})
cls.invoice = cls.env['account.invoice'].create({
'name': 'Test Invoice 3',
'partner_id': cls.partner.id,
'type': 'out_invoice',
'journal_id': cls.journal.id,
'invoice_line_ids': [(0, 0, {
'account_id': cls.a_receivable.id,
'name': 'Test line',
'quantity': 1.0,
'price_unit': 100.00,
})],
})
cls.statement = cls.env['account.bank.statement'].create({
'journal_id': cls.journal.id})
cls.account_type = cls.env["account.account.type"].create(
{"name": "Test Account Type"}
)
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": "bank",}
)
cls.invoice = cls.env["account.invoice"].create(
{
"name": "Test Invoice 3",
"partner_id": cls.partner.id,
"type": "out_invoice",
"journal_id": cls.journal.id,
"invoice_line_ids": [
(
0,
0,
{
"account_id": cls.a_receivable.id,
"name": "Test line",
"quantity": 1.0,
"price_unit": 100.00,
},
)
],
}
)
cls.statement = cls.env["account.bank.statement"].create(
{"journal_id": cls.journal.id}
)

def test_global(self):
self.invoice.action_invoice_open()
self.assertTrue(self.invoice.move_id)
self.invoice.move_id.post()
wizard_o = self.env['account.statement.line.create']
wizard_o = self.env["account.statement.line.create"]
context = wizard_o._context.copy()
context.update({
'active_model': 'account.bank.statement',
'active_id': self.statement.id,
})
wizard = wizard_o.with_context(context).create({
'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(),
'invoice': False,
})
context.update(
{"active_model": "account.bank.statement", "active_id": self.statement.id,}
)
wizard = wizard_o.with_context(context).create(
{
"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(),
"invoice": False,
}
)
wizard.populate()
self.assertEqual(len(wizard.move_line_ids), 1)
line = wizard.move_line_ids
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>

<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<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.view_bank_statement_form" />
<field name="arch" type="xml">
<field name="all_lines_reconciled" position="after">
<button name="%(account_statement_line_create_action)d"
string="Import Journal Items" type="action"
class="oe_highlight"
attrs="{'invisible':[('state', '!=', 'open')]}"
groups="account.group_account_user"/>
<button
name="%(account_statement_line_create_action)d"
string="Import Journal Items"
type="action"
class="oe_highlight"
attrs="{'invisible':[('state', '!=', 'open')]}"
groups="account.group_account_user"
/>
</field>
</field>
</record>

</odoo>
Loading

0 comments on commit 77762b8

Please sign in to comment.