[IMP] account_move_base_import: black, isort, prettier

This commit is contained in:
Damien Crier
2020-07-15 11:43:01 +02:00
committed by Florian da Costa
parent e81b55d0a8
commit 68fc7849f3
16 changed files with 653 additions and 571 deletions

View File

@@ -4,9 +4,11 @@
# Copyright 2014 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import datetime
from .file_parser import FileParser, float_or_zero
from odoo.tools import ustr
from .file_parser import FileParser, float_or_zero
class GenericFileParser(FileParser):
"""Standard parser that use a define format in csv or xls to import into a
@@ -15,25 +17,22 @@ class GenericFileParser(FileParser):
file.
"""
def __init__(self, journal, ftype='csv', **kwargs):
def __init__(self, journal, ftype="csv", **kwargs):
conversion_dict = {
'label': ustr,
'date': datetime.datetime,
'amount': float_or_zero,
"label": ustr,
"date": datetime.datetime,
"amount": float_or_zero,
}
# set self.env for later ORM searches
self.env = journal.env
super().__init__(
journal, ftype=ftype,
extra_fields=conversion_dict,
**kwargs)
super().__init__(journal, ftype=ftype, extra_fields=conversion_dict, **kwargs)
@classmethod
def parser_for(cls, parser_name):
"""Used by the new_bank_statement_parser class factory. Return true if
the providen name is generic_csvxls_so
"""
return parser_name == 'generic_csvxls_so'
return parser_name == "generic_csvxls_so"
def get_move_line_vals(self, line, *args, **kwargs):
"""
@@ -52,27 +51,27 @@ class GenericFileParser(FileParser):
'debit':value
}
"""
account_obj = self.env['account.account']
partner_obj = self.env['res.partner']
account_obj = self.env["account.account"]
partner_obj = self.env["res.partner"]
account_id = False
partner_id = False
if line.get('account'):
accounts = account_obj.search([('code', '=', line['account'])])
if line.get("account"):
accounts = account_obj.search([("code", "=", line["account"])])
if len(accounts) == 1:
account_id = accounts[0].id
if line.get('partner'):
partners = partner_obj.search([('name', '=', line['partner'])])
if line.get("partner"):
partners = partner_obj.search([("name", "=", line["partner"])])
if len(partners) == 1:
partner_id = partners[0].id
amount = line.get('amount', 0.0)
amount = line.get("amount", 0.0)
return {
'name': line.get('label', '/'),
'date_maturity': line.get('date', datetime.datetime.now().date()),
'credit': amount > 0.0 and amount or 0.0,
'debit': amount < 0.0 and -amount or 0.0,
'account_id': account_id,
'partner_id': partner_id,
"name": line.get("label", "/"),
"date_maturity": line.get("date", datetime.datetime.now().date()),
"credit": amount > 0.0 and amount or 0.0,
"debit": amount < 0.0 and -amount or 0.0,
"account_id": account_id,
"partner_id": partner_id,
}