Fix flake8 errors and warnings
We add the flake8 configuration used so we ensure everyone uses the same. We remove the usage of __all__ for non public API. When possible, we rationalize the class name according to its __name__ and module. issue9082 review297061002
This commit is contained in:
+6
-19
@@ -25,19 +25,6 @@ from trytond.pool import Pool
|
||||
from .common import PeriodMixin, ActivePeriodMixin
|
||||
from .exceptions import SecondCurrencyError, ChartWarning
|
||||
|
||||
__all__ = ['TypeTemplate', 'Type', 'OpenType',
|
||||
'AccountTemplate', 'AccountTemplateTaxTemplate',
|
||||
'Account', 'AccountDeferral', 'AccountTax',
|
||||
'OpenChartAccountStart', 'OpenChartAccount',
|
||||
'GeneralLedgerAccount', 'GeneralLedgerAccountContext',
|
||||
'GeneralLedgerLine', 'GeneralLedgerLineContext',
|
||||
'GeneralLedger', 'TrialBalance',
|
||||
'BalanceSheetContext', 'BalanceSheetComparisionContext',
|
||||
'IncomeStatementContext',
|
||||
'AgedBalanceContext', 'AgedBalance', 'AgedBalanceReport',
|
||||
'CreateChartStart', 'CreateChartAccount', 'CreateChartProperties',
|
||||
'CreateChart', 'UpdateChartStart', 'UpdateChartSucceed', 'UpdateChart']
|
||||
|
||||
|
||||
def inactive_records(func):
|
||||
@wraps(func)
|
||||
@@ -231,8 +218,8 @@ class Type(
|
||||
parent = fields.Many2One('account.account.type', 'Parent',
|
||||
ondelete="RESTRICT",
|
||||
states={
|
||||
'readonly': (Bool(Eval('template', -1)) &
|
||||
~Eval('template_override', False)),
|
||||
'readonly': (Bool(Eval('template', -1))
|
||||
& ~Eval('template_override', False)),
|
||||
},
|
||||
domain=[
|
||||
('company', '=', Eval('company')),
|
||||
@@ -591,8 +578,8 @@ class AccountTemplate(
|
||||
if not account or account.party_required != self.party_required:
|
||||
res['party_required'] = self.party_required
|
||||
if (not account
|
||||
or account.general_ledger_balance !=
|
||||
self.general_ledger_balance):
|
||||
or account.general_ledger_balance
|
||||
!= self.general_ledger_balance):
|
||||
res['general_ledger_balance'] = self.general_ledger_balance
|
||||
if not account or account.template != self:
|
||||
res['template'] = self.id
|
||||
@@ -706,8 +693,8 @@ class Account(AccountMixin(), ActivePeriodMixin, tree(), ModelSQL, ModelView):
|
||||
'Account'
|
||||
__name__ = 'account.account'
|
||||
_states = {
|
||||
'readonly': (Bool(Eval('template', -1)) &
|
||||
~Eval('template_override', False)),
|
||||
'readonly': (Bool(Eval('template', -1))
|
||||
& ~Eval('template_override', False)),
|
||||
}
|
||||
company = fields.Many2One('company.company', 'Company', required=True,
|
||||
ondelete="RESTRICT")
|
||||
|
||||
+2
-2
@@ -158,8 +158,8 @@ class FiscalYear(Workflow, ModelSQL, ModelView):
|
||||
if values.get('post_move_sequence'):
|
||||
for fiscalyear in fiscalyears:
|
||||
if (fiscalyear.post_move_sequence
|
||||
and fiscalyear.post_move_sequence.id !=
|
||||
values['post_move_sequence']):
|
||||
and fiscalyear.post_move_sequence.id
|
||||
!= values['post_move_sequence']):
|
||||
if Move.search([
|
||||
('period.fiscalyear', '=', fiscalyear.id),
|
||||
('state', '=', 'posted'),
|
||||
|
||||
@@ -17,10 +17,6 @@ from trytond.tools.multivalue import migrate_property
|
||||
from trytond.modules.company.model import (
|
||||
CompanyMultiValueMixin, CompanyValueMixin)
|
||||
|
||||
__all__ = ['Journal', 'JournalSequence',
|
||||
'JournalCashContext',
|
||||
'JournalPeriod']
|
||||
|
||||
STATES = {
|
||||
'readonly': Eval('state') == 'close',
|
||||
}
|
||||
|
||||
@@ -30,15 +30,6 @@ from .exceptions import (PostError, MoveDatesError, CancelWarning,
|
||||
ReconciliationError, DeleteDelegatedWarning, GroupLineError,
|
||||
CancelDelegatedWarning)
|
||||
|
||||
__all__ = ['Move', 'Reconciliation', 'Line', 'WriteOff', 'OpenJournalAsk',
|
||||
'OpenJournal', 'OpenAccount',
|
||||
'ReconcileLinesWriteOff', 'ReconcileLines',
|
||||
'UnreconcileLines',
|
||||
'Reconcile', 'ReconcileShow',
|
||||
'CancelMoves', 'CancelMovesDefault',
|
||||
'GroupLines', 'GroupLinesStart',
|
||||
'PrintGeneralJournalStart', 'PrintGeneralJournal', 'GeneralJournal']
|
||||
|
||||
_MOVE_STATES = {
|
||||
'readonly': Eval('state') == 'posted',
|
||||
}
|
||||
@@ -85,10 +76,10 @@ class Move(ModelSQL, ModelView):
|
||||
('account.company', '=', Eval('company', -1)),
|
||||
],
|
||||
states=_MOVE_STATES, depends=_MOVE_DEPENDS + ['company'],
|
||||
context={
|
||||
'journal': Eval('journal'),
|
||||
'period': Eval('period'),
|
||||
'date': Eval('date'),
|
||||
context={
|
||||
'journal': Eval('journal'),
|
||||
'period': Eval('period'),
|
||||
'date': Eval('date'),
|
||||
})
|
||||
|
||||
@classmethod
|
||||
@@ -443,7 +434,8 @@ class Move(ModelSQL, ModelView):
|
||||
move.post_number = Sequence.get_id(
|
||||
move.period.post_move_sequence_used.id)
|
||||
|
||||
keyfunc = lambda l: (l.party, l.account)
|
||||
def keyfunc(l):
|
||||
return l.party, l.account
|
||||
to_reconcile = [l for l in move.lines
|
||||
if ((l.debit == l.credit == Decimal('0'))
|
||||
and l.account.reconcile)]
|
||||
@@ -586,12 +578,12 @@ class Line(ModelSQL, ModelView):
|
||||
|
||||
debit = fields.Numeric('Debit', digits=(16, Eval('currency_digits', 2)),
|
||||
required=True, states=_states,
|
||||
depends=['currency_digits', 'credit', 'tax_lines', 'journal'] +
|
||||
_depends)
|
||||
depends=['currency_digits', 'credit', 'tax_lines', 'journal']
|
||||
+ _depends)
|
||||
credit = fields.Numeric('Credit', digits=(16, Eval('currency_digits', 2)),
|
||||
required=True, states=_states,
|
||||
depends=['currency_digits', 'debit', 'tax_lines', 'journal'] +
|
||||
_depends)
|
||||
depends=['currency_digits', 'debit', 'tax_lines', 'journal']
|
||||
+ _depends)
|
||||
account = fields.Many2One('account.account', 'Account', required=True,
|
||||
domain=[
|
||||
('type', '!=', None),
|
||||
@@ -1375,8 +1367,8 @@ class OpenJournal(Wizard):
|
||||
|
||||
def default_ask(self, fields):
|
||||
JournalPeriod = Pool().get('account.journal.period')
|
||||
if (Transaction().context.get('active_model', '') ==
|
||||
'account.journal.period'
|
||||
if (Transaction().context.get('active_model', '')
|
||||
== 'account.journal.period'
|
||||
and Transaction().context.get('active_id')):
|
||||
journal_period = JournalPeriod(Transaction().context['active_id'])
|
||||
return {
|
||||
@@ -1388,8 +1380,8 @@ class OpenJournal(Wizard):
|
||||
def do_open_(self, action):
|
||||
JournalPeriod = Pool().get('account.journal.period')
|
||||
|
||||
if (Transaction().context.get('active_model', '') ==
|
||||
'account.journal.period'
|
||||
if (Transaction().context.get('active_model', '')
|
||||
== 'account.journal.period'
|
||||
and Transaction().context.get('active_id')):
|
||||
journal_period = JournalPeriod(Transaction().context['active_id'])
|
||||
journal = journal_period.journal
|
||||
|
||||
@@ -14,10 +14,6 @@ from trytond.transaction import Transaction
|
||||
from trytond.pool import Pool
|
||||
from trytond.tools import decistmt
|
||||
|
||||
__all__ = ['MoveTemplate', 'MoveTemplateKeyword',
|
||||
'MoveLineTemplate', 'TaxLineTemplate',
|
||||
'CreateMove', 'CreateMoveTemplate', 'CreateMoveKeywords']
|
||||
|
||||
|
||||
class MoveTemplate(DeactivableMixin, ModelSQL, ModelView):
|
||||
'Account Move Template'
|
||||
|
||||
@@ -20,7 +20,6 @@ from trytond.modules.party.exceptions import EraseError
|
||||
|
||||
from .exceptions import AccountMissing
|
||||
|
||||
__all__ = ['Party', 'PartyAccount', 'PartyReplace', 'PartyErase']
|
||||
account_names = [
|
||||
'account_payable', 'account_receivable',
|
||||
'customer_tax_rule', 'supplier_tax_rule']
|
||||
|
||||
@@ -12,8 +12,6 @@ from trytond.const import OPERATORS
|
||||
from .exceptions import (PeriodNotFoundError, ClosePeriodError,
|
||||
PeriodDatesError, PeriodSequenceError)
|
||||
|
||||
__all__ = ['Period']
|
||||
|
||||
_STATES = {
|
||||
'readonly': Eval('state') != 'open',
|
||||
}
|
||||
@@ -212,7 +210,8 @@ class Period(Workflow, ModelSQL, ModelView):
|
||||
i = 0
|
||||
while i < len(args):
|
||||
# add test for xmlrpc and pyson that doesn't handle tuple
|
||||
if ((isinstance(args[i], tuple)
|
||||
if ((
|
||||
isinstance(args[i], tuple)
|
||||
or (isinstance(args[i], list) and len(args[i]) > 2
|
||||
and args[i][1] in OPERATORS))
|
||||
and args[i][0] in ('start_date', 'end_date')
|
||||
@@ -272,8 +271,8 @@ class Period(Workflow, ModelSQL, ModelView):
|
||||
if values.get('post_move_sequence'):
|
||||
for period in periods:
|
||||
if (period.post_move_sequence
|
||||
and period.post_move_sequence.id !=
|
||||
values['post_move_sequence']):
|
||||
and period.post_move_sequence.id
|
||||
!= values['post_move_sequence']):
|
||||
if Move.search([
|
||||
('period', '=', period.id),
|
||||
('state', '=', 'posted'),
|
||||
|
||||
@@ -79,8 +79,8 @@ setup(name=name,
|
||||
keywords='tryton account',
|
||||
package_dir={'trytond.modules.account': '.'},
|
||||
packages=(
|
||||
['trytond.modules.account'] +
|
||||
['trytond.modules.account.%s' % p for p in find_packages()]
|
||||
['trytond.modules.account']
|
||||
+ ['trytond.modules.account.%s' % p for p in find_packages()]
|
||||
),
|
||||
package_data={
|
||||
'trytond.modules.account': (info.get('xml', [])
|
||||
@@ -94,7 +94,8 @@ setup(name=name,
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Financial and Insurance Industry',
|
||||
'Intended Audience :: Legal Industry',
|
||||
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
|
||||
'License :: OSI Approved :: '
|
||||
'GNU General Public License v3 or later (GPLv3+)',
|
||||
'Natural Language :: Bulgarian',
|
||||
'Natural Language :: Catalan',
|
||||
'Natural Language :: Chinese (Simplified)',
|
||||
|
||||
@@ -23,14 +23,6 @@ from trytond.pool import Pool
|
||||
|
||||
from .common import PeriodMixin, ActivePeriodMixin
|
||||
|
||||
__all__ = ['TaxGroup', 'TaxCodeTemplate', 'TaxCode',
|
||||
'TaxCodeLineTemplate', 'TaxCodeLine',
|
||||
'OpenChartTaxCodeStart', 'OpenChartTaxCode',
|
||||
'TaxTemplate', 'Tax', 'TaxLine', 'TaxRuleTemplate', 'TaxRule',
|
||||
'TaxRuleLineTemplate', 'TaxRuleLine',
|
||||
'OpenTaxCode',
|
||||
'TestTax', 'TestTaxView', 'TestTaxViewResult']
|
||||
|
||||
KINDS = [
|
||||
('sale', 'Sale'),
|
||||
('purchase', 'Purchase'),
|
||||
@@ -1026,8 +1018,8 @@ class Tax(sequence_ordered(), ModelSQL, ModelView, DeactivableMixin):
|
||||
vals = child.template._get_tax_value(tax=child)
|
||||
invoice_account_id = (child.invoice_account.id
|
||||
if child.invoice_account else None)
|
||||
if (child.template.invoice_account and
|
||||
invoice_account_id != template2account.get(
|
||||
if (child.template.invoice_account
|
||||
and invoice_account_id != template2account.get(
|
||||
child.template.invoice_account.id)):
|
||||
vals['invoice_account'] = template2account.get(
|
||||
child.template.invoice_account.id)
|
||||
@@ -1036,8 +1028,9 @@ class Tax(sequence_ordered(), ModelSQL, ModelView, DeactivableMixin):
|
||||
vals['invoice_account'] = None
|
||||
credit_note_account_id = (child.credit_note_account.id
|
||||
if child.credit_note_account else None)
|
||||
if (child.template.credit_note_account and
|
||||
credit_note_account_id != template2account.get(
|
||||
if (child.template.credit_note_account
|
||||
and credit_note_account_id
|
||||
!= template2account.get(
|
||||
child.template.credit_note_account.id)):
|
||||
vals['credit_note_account'] = template2account.get(
|
||||
child.template.credit_note_account.id)
|
||||
@@ -1431,8 +1424,8 @@ class TaxRuleLineTemplate(sequence_ordered(), ModelSQL, ModelView):
|
||||
('group', '=', None),
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
|
||||
('group.kind', 'in', ['sale', 'both']),
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both') ==
|
||||
'purchase',
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both')
|
||||
== 'purchase',
|
||||
('group.kind', 'in', ['purchase', 'both']),
|
||||
('group.kind', 'in', ['sale', 'purchase', 'both']))),
|
||||
],
|
||||
@@ -1452,8 +1445,8 @@ class TaxRuleLineTemplate(sequence_ordered(), ModelSQL, ModelView):
|
||||
('group', '=', None),
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
|
||||
('group.kind', 'in', ['sale', 'both']),
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both') ==
|
||||
'purchase',
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both')
|
||||
== 'purchase',
|
||||
('group.kind', 'in', ['purchase', 'both']),
|
||||
('group.kind', 'in', ['sale', 'purchase', 'both']))),
|
||||
],
|
||||
@@ -1545,8 +1538,8 @@ class TaxRuleLine(sequence_ordered(), ModelSQL, ModelView, MatchMixin):
|
||||
('group', '=', None),
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
|
||||
('group.kind', 'in', ['sale', 'both']),
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both') ==
|
||||
'purchase',
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both')
|
||||
== 'purchase',
|
||||
('group.kind', 'in', ['purchase', 'both']),
|
||||
('group.kind', 'in', ['sale', 'purchase', 'both']))),
|
||||
],
|
||||
@@ -1566,8 +1559,8 @@ class TaxRuleLine(sequence_ordered(), ModelSQL, ModelView, MatchMixin):
|
||||
('group', '=', None),
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
|
||||
('group.kind', 'in', ['sale', 'both']),
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both') ==
|
||||
'purchase',
|
||||
If(Eval('_parent_rule', {}).get('kind', 'both')
|
||||
== 'purchase',
|
||||
('group.kind', 'in', ['purchase', 'both']),
|
||||
('group.kind', 'in', ['sale', 'purchase', 'both']))),
|
||||
],
|
||||
@@ -1645,8 +1638,8 @@ class TaxRuleLine(sequence_ordered(), ModelSQL, ModelView, MatchMixin):
|
||||
vals['rule'] = template2rule[line.template.rule.id]
|
||||
if line.origin_tax:
|
||||
if line.template.origin_tax:
|
||||
if (line.origin_tax.id !=
|
||||
template2tax[line.template.origin_tax.id]):
|
||||
if (line.origin_tax.id
|
||||
!= template2tax[line.template.origin_tax.id]):
|
||||
vals['origin_tax'] = template2tax[
|
||||
line.template.origin_tax.id]
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user