mirror of
https://github.com/OCA/bank-statement-import.git
synced 2025-01-20 12:37:43 +02:00
[MIG] account_bank_statement_import_move_line: Migration to 15.0
This commit is contained in:
@@ -81,6 +81,7 @@ Contributors
|
||||
* Luis M. Ontalba
|
||||
* Victor M.M. Torres
|
||||
* João Marques
|
||||
* Ernesto García
|
||||
|
||||
* Pedro Gonzalez <pegonzalezs@gmail.com>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"name": "Bank statement import move lines",
|
||||
"version": "13.0.1.0.0",
|
||||
"version": "15.0.1.0.0",
|
||||
"category": "Accounting",
|
||||
"summary": "Import journal items into bank statement",
|
||||
"author": "Tecnativa, " "Odoo Community Association (OCA)",
|
||||
@@ -11,6 +11,7 @@
|
||||
"website": "https://github.com/OCA/bank-statement-import",
|
||||
"depends": ["account"],
|
||||
"data": [
|
||||
"security/ir.model.access.csv",
|
||||
"wizards/account_statement_line_create_view.xml",
|
||||
"views/account_bank_statement_view.xml",
|
||||
],
|
||||
|
||||
@@ -19,11 +19,16 @@ class AccountMoveLine(models.Model):
|
||||
"amount": amount,
|
||||
"partner_id": self.partner_id.id,
|
||||
"statement_id": statement.id,
|
||||
"ref": self.ref,
|
||||
"payment_ref": self.ref,
|
||||
"date": self.date_maturity,
|
||||
"amount_currency": self.amount_currency,
|
||||
"currency_id": self.currency_id.id,
|
||||
}
|
||||
if statement.currency_id != self.currency_id:
|
||||
vals.update(
|
||||
{
|
||||
"amount_currency": self.amount_currency,
|
||||
}
|
||||
)
|
||||
return vals
|
||||
|
||||
def create_statement_line_from_move_line(self, statement):
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
* Luis M. Ontalba
|
||||
* Victor M.M. Torres
|
||||
* João Marques
|
||||
* Ernesto García
|
||||
|
||||
* Pedro Gonzalez <pegonzalezs@gmail.com>
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
account_bank_statement_import_move_line.access_account_statement_line_create,access_account_statement_line_create,account_bank_statement_import_move_line.model_account_statement_line_create,account.group_account_user,1,1,1,1
|
||||
|
@@ -2,10 +2,10 @@
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0
|
||||
|
||||
from odoo import fields
|
||||
from odoo.tests import common
|
||||
from odoo.tests import TransactionCase
|
||||
|
||||
|
||||
class TestAccountBankStatementImportMoveLine(common.SavepointCase):
|
||||
class TestAccountBankStatementImportMoveLine(TransactionCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestAccountBankStatementImportMoveLine, cls).setUpClass()
|
||||
@@ -28,12 +28,16 @@ class TestAccountBankStatementImportMoveLine(common.SavepointCase):
|
||||
cls.journal = cls.env["account.journal"].create(
|
||||
{"name": "Test Journal", "type": "sale", "code": "TJS0"}
|
||||
)
|
||||
cls.journal_bank = cls.env["account.journal"].create(
|
||||
{"name": "Test Journal Bank", "type": "bank", "code": "TJB0"}
|
||||
)
|
||||
cls.invoice = cls.env["account.move"].create(
|
||||
{
|
||||
"name": "Test Invoice 3",
|
||||
"partner_id": cls.partner.id,
|
||||
"type": "out_invoice",
|
||||
"move_type": "out_invoice",
|
||||
"journal_id": cls.journal.id,
|
||||
"ref": "Test",
|
||||
"invoice_line_ids": [
|
||||
(
|
||||
0,
|
||||
@@ -49,18 +53,18 @@ class TestAccountBankStatementImportMoveLine(common.SavepointCase):
|
||||
}
|
||||
)
|
||||
cls.statement = cls.env["account.bank.statement"].create(
|
||||
{"journal_id": cls.journal.id}
|
||||
{"journal_id": cls.journal_bank.id}
|
||||
)
|
||||
|
||||
def test_global(self):
|
||||
self.invoice.post()
|
||||
self.invoice.action_post()
|
||||
self.assertTrue(self.invoice.id)
|
||||
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(
|
||||
wizard = wizard_o.with_context(**context).create(
|
||||
{
|
||||
"statement_id": self.statement.id,
|
||||
"partner_id": self.partner.id,
|
||||
|
||||
@@ -26,8 +26,8 @@ class AccountStatementLineCreate(models.TransientModel):
|
||||
string="Type of Date Filter",
|
||||
required=True,
|
||||
)
|
||||
due_date = fields.Date(string="Due Date", default=fields.Date.context_today)
|
||||
move_date = fields.Date(string="Move Date", default=fields.Date.context_today)
|
||||
due_date = fields.Date(default=fields.Date.context_today)
|
||||
move_date = fields.Date(default=fields.Date.context_today)
|
||||
move_line_ids = fields.Many2many("account.move.line", string="Move Lines")
|
||||
|
||||
@api.model
|
||||
@@ -56,7 +56,7 @@ class AccountStatementLineCreate(models.TransientModel):
|
||||
domain = [
|
||||
("reconciled", "=", False),
|
||||
("account_id.internal_type", "in", ("payable", "receivable")),
|
||||
("company_id", "=", self.env.user.company_id.id),
|
||||
("company_id", "=", self.env.company.id),
|
||||
]
|
||||
if self.journal_ids:
|
||||
domain += [("journal_id", "in", self.journal_ids.ids)]
|
||||
@@ -82,11 +82,11 @@ class AccountStatementLineCreate(models.TransientModel):
|
||||
paylines = self.env["account.payment"].search(
|
||||
[
|
||||
("state", "in", ("draft", "posted", "sent")),
|
||||
("move_line_ids", "!=", False),
|
||||
("line_ids", "!=", False),
|
||||
]
|
||||
)
|
||||
if paylines:
|
||||
move_in_payment_ids = paylines.mapped("move_line_ids.id")
|
||||
move_in_payment_ids = paylines.mapped("line_ids.id")
|
||||
domain += [("id", "not in", move_in_payment_ids)]
|
||||
return domain
|
||||
|
||||
|
||||
Reference in New Issue
Block a user