Browse Source

Fix lint warnings

pull/211/head
Alexandre Fayolle 6 years ago
parent
commit
6a444182da
  1. 10
      account_bank_statement_import_paypal/tests/test_paypal_statement_import.py
  2. 10
      account_bank_statement_import_paypal/wizards/account_bank_statement_import_paypal.py

10
account_bank_statement_import_paypal/tests/test_paypal_statement_import.py

@ -42,8 +42,10 @@ class TestPaypalFile(common.SavepointCase):
# Current statements before to run the wizard # Current statements before to run the wizard
old_statements = self.env['account.bank.statement'].search([]) old_statements = self.env['account.bank.statement'].search([])
# This journal is for Paypal statements # This journal is for Paypal statements
map = self.env.ref('account_bank_statement_import_paypal.paypal_map')
self.journal.paypal_map_id = map.id
paypal_map = self.env.ref(
'account_bank_statement_import_paypal.paypal_map'
)
self.journal.paypal_map_id = paypal_map.id
file = self._do_import('paypal_en.csv') file = self._do_import('paypal_en.csv')
file = base64.b64encode(file.encode("utf-8")) file = base64.b64encode(file.encode("utf-8"))
wizard = self.env['account.bank.statement.import'].with_context({ wizard = self.env['account.bank.statement.import'].with_context({
@ -55,4 +57,6 @@ class TestPaypalFile(common.SavepointCase):
self.assertEqual(len(statement.line_ids), 3) self.assertEqual(len(statement.line_ids), 3)
self.assertEqual(len(statement.mapped('line_ids').filtered( self.assertEqual(len(statement.mapped('line_ids').filtered(
lambda x: x.partner_id and x.account_id)), 1) lambda x: x.partner_id and x.account_id)), 1)
self.assertAlmostEqual(sum(statement.mapped('line_ids.amount')), 1489.2)
self.assertAlmostEqual(
sum(statement.mapped('line_ids.amount')), 1489.2
)

10
account_bank_statement_import_paypal/wizards/account_bank_statement_import_paypal.py

@ -80,19 +80,19 @@ class AccountBankStatementImport(models.TransientModel):
def _convert_paypal_line_to_dict(self, idx, line): def _convert_paypal_line_to_dict(self, idx, line):
rline = dict() rline = dict()
for item in range(len(line)): for item in range(len(line)):
map = self.mapped('paypal_map_id.map_line_ids')[item]
paypal_map = self.mapped('paypal_map_id.map_line_ids')[item]
value = line[item] value = line[item]
if not map.field_to_assign:
if not paypal_map.field_to_assign:
continue continue
if map.date_format:
if paypal_map.date_format:
try: try:
value = fields.Date.to_string( value = fields.Date.to_string(
datetime.strptime(value, map.date_format))
datetime.strptime(value, paypal_map.date_format))
except Exception: except Exception:
raise UserError( raise UserError(
_("Date format of map file and Paypal date does " _("Date format of map file and Paypal date does "
"not match.")) "not match."))
rline[map.field_to_assign] = value
rline[paypal_map.field_to_assign] = value
for field in ['commission', 'amount', 'balance']: for field in ['commission', 'amount', 'balance']:
_logger.debug('Trying to convert %s to float' % rline[field]) _logger.debug('Trying to convert %s to float' % rline[field])

Loading…
Cancel
Save