Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8.0 pep8 v7 forward port #33

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
0ca4175
In account_easy_reconcile, now write-off entries can be created with …
guewen Mar 27, 2014
c45e47d
Improvement on the account_statement_base_import module to have profi…
pedrobaeza Jul 2, 2014
beea3e1
Create README.md
pedrobaeza Jul 2, 2014
59234d8
Merge pull request #9 from lepistone/7.0-account_easy_reconcile-analy…
lepistone Jul 11, 2014
56f6818
Merge pull request #4 from pedrobaeza/7.0-bank-statement-reconcile-pr…
pedrobaeza Jul 14, 2014
2971f66
[imp] auto reconcile: commit every 10 lines
lepistone Jul 15, 2014
8193d5d
refactor as suggested by @guewen
lepistone Jul 15, 2014
7b735ac
Merge pull request #12 from lepistone/easy_reconcile_commit
bwrsandman Jul 16, 2014
8f5861e
Add meta files
bwrsandman Jul 16, 2014
e5cfdfc
Add account-financial-tools dependency
bwrsandman Jul 16, 2014
3bf9710
allow to configure reconcile_commit_every
lepistone Jul 16, 2014
5c0f812
easy auto reconcile: commit at the end
lepistone Jul 16, 2014
996dea7
I'm a contributor, not an author
lepistone Jul 16, 2014
a1245da
Add ofxparse python dependency
bwrsandman Jul 16, 2014
1d1ae57
Merge pull request #15 from lepistone/easy_reconcile_commit_settings
lepistone Jul 16, 2014
1a96b22
Add logging during reconcile
guewen Jul 18, 2014
f40fe31
Wrong count of credit lines
guewen Jul 18, 2014
c6e8ea5
[FIX] API Improvement
florian-dacosta Jul 23, 2014
30525cf
fix docstring
florian-dacosta Jul 23, 2014
a61698b
fix docstring
florian-dacosta Jul 23, 2014
f6c5967
Merge pull request #19 from guewen/advanced-reconcile-logging
yvaucher Jul 28, 2014
d081f6c
Merge pull request #13 from bwrsandman/7.0-metafiles
yvaucher Jul 31, 2014
c1cf75d
[FIX] travis: update travis file to match the one in https://github.c…
lmignon Aug 1, 2014
bf46411
[FIX] travis: exclude account_statement_ext_point_of_sale (addon with…
lmignon Aug 1, 2014
18eb190
Merge pull request #25 from acsone/7.0-fix-travis
pedrobaeza Aug 1, 2014
7022628
[IMP] account_statement_base_import: Fill balance start when parser d…
pedrobaeza Aug 4, 2014
69c0e16
[FIX] Correct call order
pedrobaeza Aug 4, 2014
8e20a45
Merge pull request #22 from florian-dacosta/api_improvement
pedrobaeza Aug 4, 2014
2c1773e
Merge pull request #27 from pedrobaeza/7.0-import_start_balance_null
pedrobaeza Aug 4, 2014
44a59ce
autopep8
pedrobaeza Aug 4, 2014
2ec18f7
[IMP] account_statement_transactionid_import: Fix PEP8
pedrobaeza Aug 4, 2014
4a1c950
[IMP] account_easy_reconcile: Fix PEP8
pedrobaeza Aug 4, 2014
5072c71
[IMP] statement_voucher_killer: Fix PEP8
pedrobaeza Aug 4, 2014
f1e0b78
[IMP] account_advanced_reconcile: Fix PEP8
pedrobaeza Aug 4, 2014
c6298b0
[IMP] account_statement_base_completion: Fix PEP8
pedrobaeza Aug 4, 2014
b3c1aa9
[IMP] account_statement_so_completion: Fix PEP8
pedrobaeza Aug 4, 2014
5e98a81
[IMP] account_statement_ext_voucher: Fix PEP8
pedrobaeza Aug 4, 2014
d0a06fd
[IMP] account_statement_one_move: Fix PEP8
pedrobaeza Aug 4, 2014
66af054
[IMP] account_statement_ext_point_of_sale: Fix PEP8
pedrobaeza Aug 4, 2014
d64122c
[IMP] account_statement_regex_account_completion: Fix PEP8
pedrobaeza Aug 4, 2014
602d39d
[IMP] account_statement_completion_label: Fix PEP8
pedrobaeza Aug 4, 2014
aebcbfd
[IMP] account_invoice_reference: Fix PEP8
pedrobaeza Aug 4, 2014
d9a943d
[IMP] account_statement_base_import: Fix PEP8
pedrobaeza Aug 4, 2014
a851336
[IMP] account_statement_transactionid_completion: Fix PEP8
pedrobaeza Aug 4, 2014
6ccd6f4
[IMP] account_statement_commission: Fix PEP8
pedrobaeza Aug 4, 2014
9facd19
[IMP] account_statement_no_invoice_import: Fix PEP8
pedrobaeza Aug 4, 2014
5f0628b
[IMP] account_statement_ofx_import: Fix PEP8
pedrobaeza Aug 4, 2014
48e03e6
[IMP] account_advanced_reconcile_transaction_ref: Fix PEP8
pedrobaeza Aug 4, 2014
5cfa975
[IMP] account_statement_completion_voucher: Fix PEP8
pedrobaeza Aug 4, 2014
85d139f
[IMP] account_statement_completion_voucher: Fix PEP8
pedrobaeza Aug 4, 2014
b94bebe
[IMP] account_statement_bankaccount_completion: Fix PEP8
pedrobaeza Aug 4, 2014
b522f28
Fix Travis errors
pedrobaeza Aug 4, 2014
4e13e0e
F401 remaining
pedrobaeza Aug 4, 2014
a33cfa6
Fix multiline docstring param
pedrobaeza Aug 5, 2014
c0cbab8
Merge pull request #31 from pedrobaeza/7.0-pep8_fix
pedrobaeza Aug 6, 2014
8496d84
Merge remote-tracking branch 'upstream/7.0' into 8.0-port-base-import
lmignon Aug 6, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[IMP] account_easy_reconcile: Fix PEP8
  • Loading branch information
pedrobaeza committed Aug 4, 2014
commit 4a1c950044619bc8fd39cfee0e672e33b37bce1a
16 changes: 4 additions & 12 deletions account_easy_reconcile/base_reconciliation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from operator import itemgetter, attrgetter


class easy_reconcile_base(orm.AbstractModel):
class EasyReconcileBase(orm.AbstractModel):

"""Abstract Model for reconciliation methods"""

Expand Down Expand Up @@ -88,7 +88,6 @@ def _where(self, rec, *args, **kwargs):
# which returns a list, we have to
# accomodate with that
params = [rec.account_id.id]

if rec.partner_ids:
where += " AND account_move_line.partner_id IN %s"
params.append(tuple([l.id for l in rec.partner_ids]))
Expand Down Expand Up @@ -116,14 +115,13 @@ def _below_writeoff_limit(self, cr, uid, rec, lines,
for key, value
in line.iteritems()
if key in keys), lines)

debit, credit = sums['debit'], sums['credit']
writeoff_amount = round(debit - credit, precision)
return bool(writeoff_limit >= abs(writeoff_amount)), debit, credit

def _get_rec_date(self, cr, uid, rec, lines,
based_on='end_period_last_credit', context=None):
period_obj = self.pool.get('account.period')
period_obj = self.pool['account.period']

def last_period(mlines):
period_ids = [ml['period_id'] for ml in mlines]
Expand Down Expand Up @@ -154,7 +152,8 @@ def debit(mlines):
# when date is None
return None

def _reconcile_lines(self, cr, uid, rec, lines, allow_partial=False, context=None):
def _reconcile_lines(self, cr, uid, rec, lines, allow_partial=False,
context=None):
""" Try to reconcile given lines

:param list lines: list of dict of move lines, they must at least
Expand All @@ -169,29 +168,23 @@ def _reconcile_lines(self, cr, uid, rec, lines, allow_partial=False, context=Non
"""
if context is None:
context = {}

ml_obj = self.pool.get('account.move.line')
writeoff = rec.write_off

line_ids = [l['id'] for l in lines]
below_writeoff, sum_debit, sum_credit = self._below_writeoff_limit(
cr, uid, rec, lines, writeoff, context=context)
date = self._get_rec_date(
cr, uid, rec, lines, rec.date_base_on, context=context)

rec_ctx = dict(context, date_p=date)
if below_writeoff:
if sum_credit < sum_debit:
writeoff_account_id = rec.account_profit_id.id
else:
writeoff_account_id = rec.account_lost_id.id

period_id = self.pool.get('account.period').find(
cr, uid, dt=date, context=context)[0]

if rec.analytic_account_id:
rec_ctx['analytic_id'] = rec.analytic_account_id.id

ml_obj.reconcile(
cr, uid,
line_ids,
Expand All @@ -208,5 +201,4 @@ def _reconcile_lines(self, cr, uid, rec, lines, allow_partial=False, context=Non
type='manual',
context=rec_ctx)
return True, False

return False, False
45 changes: 18 additions & 27 deletions account_easy_reconcile/easy_reconcile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
from openerp.osv import fields, osv, orm
from openerp.tools.translate import _
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
from openerp.tools.translate import _


class easy_reconcile_options(orm.AbstractModel):

class EasyReconcileOptions(orm.AbstractModel):
"""Options of a reconciliation profile

Columns shared by the configuration of methods
Expand All @@ -38,12 +36,14 @@ class easy_reconcile_options(orm.AbstractModel):
_name = 'easy.reconcile.options'

def _get_rec_base_date(self, cr, uid, context=None):
return [('end_period_last_credit', 'End of period of most recent credit'),
('newest', 'Most recent move line'),
('actual', 'Today'),
('end_period', 'End of period of most recent move line'),
('newest_credit', 'Date of most recent credit'),
('newest_debit', 'Date of most recent debit')]
return [
('end_period_last_credit', 'End of period of most recent credit'),
('newest', 'Most recent move line'),
('actual', 'Today'),
('end_period', 'End of period of most recent move line'),
('newest_credit', 'Date of most recent credit'),
('newest_debit', 'Date of most recent debit')
]

_columns = {
'write_off': fields.float('Write off allowed'),
Expand All @@ -69,13 +69,10 @@ def _get_rec_base_date(self, cr, uid, context=None):
}


class account_easy_reconcile_method(orm.Model):

class AccountEasyReconcileMethod(orm.Model):
_name = 'account.easy.reconcile.method'
_description = 'reconcile method for account_easy_reconcile'

_inherit = 'easy.reconcile.options'

_order = 'sequence'

def _get_all_rec_method(self, cr, uid, context=None):
Expand Down Expand Up @@ -132,7 +129,7 @@ def init(self, cr):
""")


class account_easy_reconcile(orm.Model):
class AccountEasyReconcile(orm.Model):

_name = 'account.easy.reconcile'
_description = 'account easy reconcile'
Expand Down Expand Up @@ -261,7 +258,7 @@ def _no_history(self, cr, uid, rec, context=None):
be called when there is no history on the reconciliation
task.
"""
raise osv.except_osv(
raise orm.except_orm(
_('Error'),
_('There is no history of reconciled '
'items on the task: %s.') % rec.name)
Expand All @@ -280,14 +277,10 @@ def _open_move_line_list(sefl, cr, uid, move_line_ids, name, context=None):
}

def open_unreconcile(self, cr, uid, ids, context=None):
""" Open the view of move line with the unreconciled move lines
"""

""" Open the view of move line with the unreconciled move lines"""
assert len(ids) == 1, \
"You can only open entries from one profile at a time"

obj_move_line = self.pool.get('account.move.line')
res = {}
for task in self.browse(cr, uid, ids, context=context):
line_ids = obj_move_line.search(
cr, uid,
Expand All @@ -297,17 +290,14 @@ def open_unreconcile(self, cr, uid, ids, context=None):
context=context)

name = _('Unreconciled items')
return self._open_move_line_list(cr, uid, line_ids, name, context=context)
return self._open_move_line_list(cr, uid, line_ids, name,
context=context)

def open_partial_reconcile(self, cr, uid, ids, context=None):
""" Open the view of move line with the unreconciled move lines
"""

""" Open the view of move line with the unreconciled move lines"""
assert len(ids) == 1, \
"You can only open entries from one profile at a time"

obj_move_line = self.pool.get('account.move.line')
res = {}
for task in self.browse(cr, uid, ids, context=context):
line_ids = obj_move_line.search(
cr, uid,
Expand All @@ -316,7 +306,8 @@ def open_partial_reconcile(self, cr, uid, ids, context=None):
('reconcile_partial_id', '!=', False)],
context=context)
name = _('Partial reconciled items')
return self._open_move_line_list(cr, uid, line_ids, name, context=context)
return self._open_move_line_list(cr, uid, line_ids, name,
context=context)

def last_history_reconcile(self, cr, uid, rec_id, context=None):
""" Get the last history record for this reconciliation profile
Expand Down
13 changes: 3 additions & 10 deletions account_easy_reconcile/easy_reconcile_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
from openerp.tools.translate import _


class easy_reconcile_history(orm.Model):

class EasyReconcileHistory(orm.Model):
""" Store an history of the runs per profile
Each history stores the list of reconciliations done"""

Expand All @@ -34,10 +33,8 @@ class easy_reconcile_history(orm.Model):

def _reconcile_line_ids(self, cr, uid, ids, name, args, context=None):
result = {}

for history in self.browse(cr, uid, ids, context=context):
result[history.id] = {}

move_line_ids = []
for reconcile in history.reconcile_ids:
move_line_ids += [line.id
Expand All @@ -51,7 +48,6 @@ def _reconcile_line_ids(self, cr, uid, ids, name, args, context=None):
for line
in reconcile.line_partial_ids]
result[history.id]['partial_line_ids'] = move_line_ids

return result

_columns = {
Expand Down Expand Up @@ -91,7 +87,8 @@ def _reconcile_line_ids(self, cr, uid, ids, name, args, context=None):

}

def _open_move_lines(self, cr, uid, history_id, rec_type='full', context=None):
def _open_move_lines(self, cr, uid, history_id, rec_type='full',
context=None):
""" For an history record, open the view of move line with
the reconciled or partially reconciled move lines

Expand All @@ -101,18 +98,14 @@ def _open_move_lines(self, cr, uid, history_id, rec_type='full', context=None):
"""
assert rec_type in ('full', 'partial'), \
"rec_type must be 'full' or 'partial'"

history = self.browse(cr, uid, history_id, context=context)

if rec_type == 'full':
field = 'reconcile_line_ids'
name = _('Reconciliations')
else:
field = 'partial_line_ids'
name = _('Partial Reconciliations')

move_line_ids = [line.id for line in getattr(history, field)]

return {
'name': name,
'view_mode': 'tree,form',
Expand Down
19 changes: 4 additions & 15 deletions account_easy_reconcile/simple_reconciliation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
from openerp.osv.orm import AbstractModel, TransientModel


class easy_reconcile_simple(AbstractModel):

class EasyReconcileSimple(AbstractModel):
_name = 'easy.reconcile.simple'
_inherit = 'easy.reconcile.base'

Expand All @@ -32,20 +31,14 @@ class easy_reconcile_simple(AbstractModel):
_key_field = None

def rec_auto_lines_simple(self, cr, uid, rec, lines, context=None):
if context is None:
context = {}

if self._key_field is None:
raise ValueError("_key_field has to be defined")

count = 0
res = []
while (count < len(lines)):
for i in xrange(count + 1, len(lines)):
writeoff_account_id = False
if lines[count][self._key_field] != lines[i][self._key_field]:
break

check = False
if lines[count]['credit'] > 0 and lines[i]['debit'] > 0:
credit_line = lines[count]
Expand All @@ -57,7 +50,6 @@ def rec_auto_lines_simple(self, cr, uid, rec, lines, context=None):
check = True
if not check:
continue

reconciled, dummy = self._reconcile_lines(
cr, uid, rec, [credit_line, debit_line],
allow_partial=False, context=context)
Expand Down Expand Up @@ -90,8 +82,7 @@ def _action_rec(self, cr, uid, rec, context=None):
return self.rec_auto_lines_simple(cr, uid, rec, lines, context)


class easy_reconcile_simple_name(TransientModel):

class EasyReconcileSimpleName(TransientModel):
_name = 'easy.reconcile.simple.name'
_inherit = 'easy.reconcile.simple'

Expand All @@ -100,8 +91,7 @@ class easy_reconcile_simple_name(TransientModel):
_key_field = 'name'


class easy_reconcile_simple_partner(TransientModel):

class EasyReconcileSimplePartner(TransientModel):
_name = 'easy.reconcile.simple.partner'
_inherit = 'easy.reconcile.simple'

Expand All @@ -110,8 +100,7 @@ class easy_reconcile_simple_partner(TransientModel):
_key_field = 'partner_id'


class easy_reconcile_simple_reference(TransientModel):

class EasyReconcileSimpleReference(TransientModel):
_name = 'easy.reconcile.simple.reference'
_inherit = 'easy.reconcile.simple'

Expand Down