diff --git a/account.py b/account.py
index 6a1cb19430..546a24667f 100644
--- a/account.py
+++ b/account.py
@@ -4,7 +4,8 @@ from decimal import Decimal
import datetime
import operator
from trytond.model import ModelView, ModelSQL, fields
-from trytond.wizard import Wizard, StateView, StateAction, StateTransition, Button
+from trytond.wizard import Wizard, StateView, StateAction, StateTransition, \
+ Button
from trytond.report import Report
from trytond.tools import reduce_ids
from trytond.pyson import Eval, PYSONEncoder, Date
@@ -20,7 +21,8 @@ class TypeTemplate(ModelSQL, ModelView):
name = fields.Char('Name', required=True, translate=True)
parent = fields.Many2One('account.account.type.template', 'Parent',
ondelete="RESTRICT")
- childs = fields.One2Many('account.account.type.template', 'parent', 'Children')
+ childs = fields.One2Many('account.account.type.template', 'parent',
+ 'Children')
sequence = fields.Integer('Sequence', required=True)
balance_sheet = fields.Boolean('Balance Sheet')
income_statement = fields.Boolean('Income Statement')
@@ -52,6 +54,7 @@ class TypeTemplate(ModelSQL, ModelView):
if not ids:
return {}
res = {}
+
def _name(type):
if type.parent:
return _name(type.parent) + '\\' + type.name
@@ -240,6 +243,7 @@ class Type(ModelSQL, ModelView):
if not ids:
return {}
res = {}
+
def _name(type):
if type.parent:
return _name(type.parent) + '\\' + type.name
@@ -529,9 +533,9 @@ class Account(ModelSQL, ModelView):
'Currency'), 'get_currency')
currency_digits = fields.Function(fields.Integer('Currency Digits'),
'get_currency_digits')
- second_currency = fields.Many2One('currency.currency', 'Secondary currency',
- help='Force all moves for this account \n' \
- 'to have this secondary currency.', ondelete="RESTRICT")
+ second_currency = fields.Many2One('currency.currency',
+ 'Secondary Currency', help='Force all moves for this account \n' \
+ 'to have this secondary currency.', ondelete="RESTRICT")
type = fields.Many2One('account.account.type', 'Type', ondelete="RESTRICT",
states={
'invisible': Eval('kind') == 'view',
@@ -1273,13 +1277,14 @@ class GeneralLegder(Report):
for line in lines:
balance += line.debit - line.credit
res[account_id].append({
- 'date': line.date,
- 'debit': line.debit,
- 'credit': line.credit,
- 'balance': balance,
- 'name': line.name,
- 'state': state_selections.get(line.move.state, line.move.state),
- })
+ 'date': line.date,
+ 'debit': line.debit,
+ 'credit': line.credit,
+ 'balance': balance,
+ 'name': line.name,
+ 'state': state_selections.get(line.move.state,
+ line.move.state),
+ })
return res
GeneralLegder()
@@ -1501,7 +1506,7 @@ class OpenBalanceSheet(Wizard):
'posted': session.start.posted,
'company': company.id,
})
- action['name'] += ' - '+ date + ' - ' + company.name
+ action['name'] += ' - ' + date + ' - ' + company.name
return action, {}
def transition_open_(self, session):
@@ -1965,7 +1970,6 @@ class OpenThirdPartyBalanceStart(ModelView):
required=True)
posted = fields.Boolean('Posted Move', help='Show only posted move')
-
def default_fiscalyear(self):
fiscalyear_obj = Pool().get('account.fiscalyear')
fiscalyear_id = fiscalyear_obj.find(
@@ -2186,35 +2190,35 @@ class AgedBalance(Report):
}[data['balance_type']]
res = {}
- for position,term in enumerate(terms):
+ for position, term in enumerate(terms):
if position == 0:
term_query = '(l.maturity_date <= %s '\
'OR l.maturity_date IS NULL) '
term_args = (date_obj.today() +
- datetime.timedelta(days=term*coef),)
+ datetime.timedelta(days=term * coef),)
else:
term_query = '(l.maturity_date <= %s '\
'AND l.maturity_date > %s) '
term_args = (
- date_obj.today() + datetime.timedelta(days=term*coef),
+ date_obj.today() + datetime.timedelta(days=term * coef),
date_obj.today()
- + datetime.timedelta(days=terms[position-1]*coef),
+ + datetime.timedelta(days=terms[position - 1] * coef),
)
- cursor.execute('SELECT l.party, SUM(l.debit) - SUM(l.credit) ' \
- 'FROM account_move_line l ' \
- 'JOIN account_move m ON (l.move = m.id) '
- 'JOIN account_account a ON (l.account = a.id) '
- 'WHERE l.party IS NOT NULL '\
- 'AND a.active ' \
- 'AND a.kind IN ('+ ','.join(('%s',) * len(kind)) + ") "\
- 'AND l.reconciliation IS NULL ' \
- 'AND a.company = %s ' \
- 'AND '+ term_query+\
- 'AND ' + line_query + ' ' \
- 'GROUP BY l.party ' \
+ cursor.execute('SELECT l.party, SUM(l.debit) - SUM(l.credit) '
+ 'FROM account_move_line l '
+ 'JOIN account_move m ON (l.move = m.id) '
+ 'JOIN account_account a ON (l.account = a.id) '
+ 'WHERE l.party IS NOT NULL '
+ 'AND a.active '
+ 'AND a.kind IN (' + ','.join(('%s',) * len(kind)) + ") "
+ 'AND l.reconciliation IS NULL '
+ 'AND a.company = %s '
+ 'AND ' + term_query + ' '
+ 'AND ' + line_query + ' '
+ 'GROUP BY l.party '
'HAVING (SUM(l.debit) - SUM(l.credit) != 0)',
- kind + (data['company'],) + term_args)
+ kind + (data['company'],) + term_args)
for party, solde in cursor.fetchall():
if party in res:
res[party][position] = solde
@@ -2229,16 +2233,17 @@ class AgedBalance(Report):
localcontext['main_title'] = data['balance_type']
localcontext['unit'] = data['unit']
for i in range(3):
- localcontext['total' + str(i)] = sum((v[i] for v in res.itervalues()))
+ localcontext['total' + str(i)] = sum(
+ (v[i] for v in res.itervalues()))
localcontext['term' + str(i)] = terms[i]
localcontext['company'] = company
- localcontext['parties']= [{
- 'name': p.rec_name,
- 'amount0': res[p.id][0],
- 'amount1': res[p.id][1],
- 'amount2': res[p.id][2],
- } for p in parties]
+ localcontext['parties'] = [{
+ 'name': p.rec_name,
+ 'amount0': res[p.id][0],
+ 'amount1': res[p.id][1],
+ 'amount2': res[p.id][2],
+ } for p in parties]
return super(AgedBalance, self).parse(report, objects, data,
localcontext)
diff --git a/configuration.py b/configuration.py
index b57e577e2c..42cfacf87e 100644
--- a/configuration.py
+++ b/configuration.py
@@ -3,7 +3,7 @@
from trytond.model import ModelView, ModelSQL, ModelSingleton, fields
from trytond.pool import Pool
from trytond.transaction import Transaction
-from trytond.pyson import Eval, Bool
+from trytond.pyson import Eval
class Configuration(ModelSingleton, ModelSQL, ModelView):
@@ -14,16 +14,16 @@ class Configuration(ModelSingleton, ModelSQL, ModelView):
default_account_receivable = fields.Function(fields.Many2One(
'account.account', 'Default Account Receivable',
domain=[
- ('kind', '=', 'receivable'),
- ('company', '=', Eval('context', {}).get('company')),
- ]),
+ ('kind', '=', 'receivable'),
+ ('company', '=', Eval('context', {}).get('company')),
+ ]),
'get_account', setter='set_account')
default_account_payable = fields.Function(fields.Many2One(
'account.account', 'Default Account Payable',
domain=[
- ('kind', '=', 'payable'),
- ('company', '=', Eval('context', {}).get('company')),
- ]),
+ ('kind', '=', 'payable'),
+ ('company', '=', Eval('context', {}).get('company')),
+ ]),
'get_account', setter='set_account')
def get_account(self, ids, name):
diff --git a/fiscalyear.py b/fiscalyear.py
index 3624f63726..24c803dfec 100644
--- a/fiscalyear.py
+++ b/fiscalyear.py
@@ -132,7 +132,7 @@ class FiscalYear(ModelSQL, ModelView):
operator = ['delete', 'unlink_all', 'unlink', 'create', 'write',
'add', 'set']
vals['periods'].sort(
- lambda x, y: cmp(operator.index(x[0]), operator.index(y[0])))
+ lambda x, y: cmp(operator.index(x[0]), operator.index(y[0])))
return super(FiscalYear, self).write(ids, vals)
def delete(self, ids):
diff --git a/journal.py b/journal.py
index d97992e2d0..57ff511631 100644
--- a/journal.py
+++ b/journal.py
@@ -127,7 +127,7 @@ class Journal(ModelSQL, ModelView):
# Migration from 1.0 sequence Many2One change into Property
if table.column_exist('sequence'):
property_obj = Pool().get('ir.property')
- cursor.execute('SELECT id, sequence FROM "' + self._table +'"')
+ cursor.execute('SELECT id, sequence FROM "' + self._table + '"')
with Transaction().set_user(0):
for journal_id, sequence_id in cursor.fetchall():
property_obj.set('sequence', self._name,
diff --git a/move.py b/move.py
index 11ae8cc156..1518fae269 100644
--- a/move.py
+++ b/move.py
@@ -42,7 +42,7 @@ class Move(ModelSQL, ModelView):
journal = fields.Many2One('account.journal', 'Journal', required=True,
states=_MOVE_STATES, depends=_MOVE_DEPENDS)
date = fields.Date('Effective Date', required=True, states=_MOVE_STATES,
- depends=_MOVE_DEPENDS, on_change_with=['period', 'journal', 'date'])
+ depends=_MOVE_DEPENDS, on_change_with=['period', 'journal', 'date'])
post_date = fields.Date('Post Date', readonly=True)
state = fields.Selection([
('draft', 'Draft'),
@@ -313,17 +313,17 @@ class Move(ModelSQL, ModelView):
'centralised_line': centralised_line_id,
})
else:
- move_line_obj.write( move.centralised_line.id, {
- 'debit': debit,
- 'credit': credit,
- 'account': account_id,
- })
+ move_line_obj.write(move.centralised_line.id, {
+ 'debit': debit,
+ 'credit': credit,
+ 'account': account_id,
+ })
continue
if not draft_lines:
continue
- move_line_obj.write( [x.id for x in draft_lines], {
- 'state': 'valid',
- })
+ move_line_obj.write([x.id for x in draft_lines], {
+ 'state': 'valid',
+ })
return
@ModelView.button
@@ -733,8 +733,9 @@ class Line(ModelSQL, ModelView):
if name == 'currency_digits':
res[name][line.id] = line.account.currency_digits
elif name == 'second_currency_digits':
- if line.account.second_currency:
- res[name][line.id] = line.account.second_currency.digits
+ second_currency = line.account.second_currency
+ if second_currency:
+ res[name][line.id] = second_currency.digits
return res
def on_change_debit(self, vals):
@@ -865,7 +866,7 @@ class Line(ModelSQL, ModelView):
# SQLite uses float for SUM
if not isinstance(amount, Decimal):
amount = Decimal(str(amount))
- if not currency_obj.is_zero( party.account_receivable.currency,
+ if not currency_obj.is_zero(party.account_receivable.currency,
amount):
if amount > Decimal('0.0'):
res['credit'] = currency_obj.round(
@@ -880,7 +881,7 @@ class Line(ModelSQL, ModelView):
else:
cursor.execute(query, (party.id, party.account_payable.id))
amount = cursor.fetchone()[0]
- if not currency_obj.is_zero( party.account_payable.currency,
+ if not currency_obj.is_zero(party.account_payable.currency,
amount):
if amount > Decimal('0.0'):
res['credit'] = currency_obj.round(
@@ -1019,42 +1020,42 @@ class Line(ModelSQL, ModelView):
ids = ','.join(
str(int(x)) for x in Transaction().context['periods'])
if Transaction().context.get('posted'):
- return (obj + '.active ' \
- 'AND ' + obj + '.state != \'draft\' ' \
- 'AND ' + obj + '.move IN (' \
- 'SELECT id FROM account_move ' \
- 'WHERE period IN (' + ids + ') ' \
- 'AND state = \'posted\' ' \
- ')', [])
+ return (obj + '.active '
+ 'AND ' + obj + '.state != \'draft\' '
+ 'AND ' + obj + '.move IN ('
+ 'SELECT id FROM account_move '
+ 'WHERE period IN (' + ids + ') '
+ 'AND state = \'posted\' '
+ ')', [])
else:
- return (obj + '.active ' \
- 'AND ' + obj + '.state != \'draft\' ' \
- 'AND ' + obj + '.move IN (' \
- 'SELECT id FROM account_move ' \
- 'WHERE period IN (' + ids + ')' \
- ')', [])
+ return (obj + '.active '
+ 'AND ' + obj + '.state != \'draft\' '
+ 'AND ' + obj + '.move IN ('
+ 'SELECT id FROM account_move '
+ 'WHERE period IN (' + ids + ')'
+ ')', [])
else:
if Transaction().context.get('posted'):
- return (obj + '.active ' \
- 'AND ' + obj + '.state != \'draft\' ' \
- 'AND ' + obj + '.move IN (' \
- 'SELECT id FROM account_move ' \
- 'WHERE period IN (' \
- 'SELECT id FROM account_period ' \
- 'WHERE fiscalyear IN (' + fiscalyear_clause + ')' \
- ') ' \
- 'AND state = \'posted\' ' \
- ')', fiscalyear_ids)
+ return (obj + '.active '
+ 'AND ' + obj + '.state != \'draft\' '
+ 'AND ' + obj + '.move IN ('
+ 'SELECT id FROM account_move '
+ 'WHERE period IN ('
+ 'SELECT id FROM account_period '
+ 'WHERE fiscalyear IN (' + fiscalyear_clause + ')'
+ ') '
+ 'AND state = \'posted\' '
+ ')', fiscalyear_ids)
else:
- return (obj + '.active ' \
- 'AND ' + obj + '.state != \'draft\' ' \
- 'AND ' + obj + '.move IN (' \
- 'SELECT id FROM account_move ' \
- 'WHERE period IN (' \
- 'SELECT id FROM account_period ' \
- 'WHERE fiscalyear IN (' + fiscalyear_clause + ')' \
- ')' \
- ')', fiscalyear_ids)
+ return (obj + '.active '
+ 'AND ' + obj + '.state != \'draft\' '
+ 'AND ' + obj + '.move IN ('
+ 'SELECT id FROM account_move '
+ 'WHERE period IN ('
+ 'SELECT id FROM account_period '
+ 'WHERE fiscalyear IN (' + fiscalyear_clause + ')'
+ ')'
+ ')', fiscalyear_ids)
def on_write(self, ids):
lines = self.browse(ids)
@@ -1230,7 +1231,8 @@ class Line(ModelSQL, ModelView):
attrs.append('required="1"')
else:
attrs.append('required="0"')
- xml += '\n' % (column.field.name, ' '.join(attrs))
+ xml += ('\n'
+ % (column.field.name, ' '.join(attrs)))
for depend in getattr(self, column.field.name).depends:
fields.add(depend)
fields.add('state')
@@ -1357,7 +1359,8 @@ class OpenJournal(Wizard):
open_ = StateAction('account.act_move_line_form')
def transition_start(self, session):
- if (Transaction().context.get('active_model', '') == 'account.journal.period'
+ if (Transaction().context.get('active_model', '')
+ == 'account.journal.period'
and Transaction().context.get('active_id')):
return 'open_'
return 'ask'
diff --git a/party.py b/party.py
index 991d6817fc..1169942884 100644
--- a/party.py
+++ b/party.py
@@ -93,21 +93,20 @@ class Party(ModelSQL, ModelView):
'OR l.maturity_date IS NULL) '
today_value = [date_obj.today()]
- cursor.execute('SELECT l.party, ' \
- 'SUM((COALESCE(l.debit, 0) - COALESCE(l.credit, 0))) ' \
- 'FROM account_move_line AS l, ' \
- 'account_account AS a ' \
- 'WHERE a.id = l.account ' \
- 'AND a.active ' \
- 'AND a.kind = %s ' \
- 'AND l.party IN ' \
- '(' + ','.join(('%s',) * len(ids)) + ') ' \
- 'AND l.reconciliation IS NULL ' \
- 'AND ' + line_query + ' ' \
- + today_query + \
- 'AND a.company = %s ' \
- 'GROUP BY l.party',
- [code,] + ids + today_value + [company_id])
+ cursor.execute('SELECT l.party, '
+ 'SUM((COALESCE(l.debit, 0) - COALESCE(l.credit, 0))) '
+ 'FROM account_move_line AS l, account_account AS a '
+ 'WHERE a.id = l.account '
+ 'AND a.active '
+ 'AND a.kind = %s '
+ 'AND l.party IN '
+ '(' + ','.join(('%s',) * len(ids)) + ') '
+ 'AND l.reconciliation IS NULL '
+ 'AND ' + line_query + ' '
+ + today_query +
+ 'AND a.company = %s '
+ 'GROUP BY l.party',
+ [code] + ids + today_value + [company_id])
for party_id, sum in cursor.fetchall():
# SQLite uses float for SUM
if not isinstance(sum, Decimal):
@@ -157,20 +156,19 @@ class Party(ModelSQL, ModelView):
line_query, _ = move_line_obj.query_get()
cursor.execute('SELECT l.party '
- 'FROM account_move_line AS l, '
- 'account_account AS a '
- 'WHERE a.id = l.account '
- 'AND a.active '
- 'AND a.kind = %s '
- 'AND l.party IS NOT NULL '
- 'AND l.reconciliation IS NULL '
- 'AND ' + line_query + ' ' \
- + today_query + \
- 'AND a.company = %s '
- 'GROUP BY l.party '
- 'HAVING (SUM((COALESCE(l.debit, 0) - COALESCE(l.credit, 0))) ' \
- + clause[1] + ' %s)',
- [code] + today_value + [company_id] + [Decimal(clause[2])])
+ 'FROM account_move_line AS l, account_account AS a '
+ 'WHERE a.id = l.account '
+ 'AND a.active '
+ 'AND a.kind = %s '
+ 'AND l.party IS NOT NULL '
+ 'AND l.reconciliation IS NULL '
+ 'AND ' + line_query + ' '
+ + today_query +
+ 'AND a.company = %s '
+ 'GROUP BY l.party '
+ 'HAVING (SUM((COALESCE(l.debit, 0) - COALESCE(l.credit, 0))) '
+ + clause[1] + ' %s)',
+ [code] + today_value + [company_id] + [Decimal(clause[2])])
return [('id', 'in', [x[0] for x in cursor.fetchall()])]
Party()
diff --git a/period.py b/period.py
index bb8201ee23..b92e611c4b 100644
--- a/period.py
+++ b/period.py
@@ -29,9 +29,9 @@ class Period(ModelSQL, ModelView):
('open', 'Open'),
('close', 'Close'),
], 'State', readonly=True, required=True)
- post_move_sequence =fields.Many2One('ir.sequence', 'Post Move Sequence',
- required=True, domain=[('code', '=', 'account.move')],
- context={'code': 'account.move'}, states={
+ post_move_sequence = fields.Many2One('ir.sequence', 'Post Move Sequence',
+ required=True, domain=[('code', '=', 'account.move')],
+ context={'code': 'account.move'}, states={
'required': False,
})
type = fields.Selection([
@@ -174,6 +174,7 @@ class Period(ModelSQL, ModelView):
def search(self, args, offset=0, limit=None, order=None, count=False,
query_string=False):
args = args[:]
+
def process_args(args):
i = 0
while i < len(args):
@@ -187,7 +188,8 @@ class Period(ModelSQL, ModelView):
args[i] = ('id', '!=', '0')
else:
period = self.browse(args[i][2][0])
- args[i] = (args[i][0], args[i][1], period[args[i][2][1]])
+ args[i] = (args[i][0], args[i][1],
+ period[args[i][2][1]])
elif isinstance(args[i], list):
process_args(args[i])
i += 1
diff --git a/tax.py b/tax.py
index 301e0e63ff..8bd1f88bf7 100644
--- a/tax.py
+++ b/tax.py
@@ -197,18 +197,17 @@ class Code(ModelSQL, ModelView):
child_ids = self.search([('parent', 'child_of', ids)])
all_ids = {}.fromkeys(ids + child_ids).keys()
line_query, _ = move_line_obj.query_get()
- cursor.execute('SELECT c.id, ' \
- 'SUM(tl.amount) ' \
- 'FROM account_tax_code c, ' \
- 'account_tax_line tl, ' \
- 'account_move_line l ' \
- 'WHERE c.id = tl.code ' \
- 'AND tl.move_line = l.id ' \
- 'AND c.id IN (' + \
- ','.join(('%s',) * len(all_ids))+ ') ' \
- 'AND ' + line_query + ' ' \
- 'AND c.active ' \
- 'GROUP BY c.id', all_ids)
+ cursor.execute('SELECT c.id, SUM(tl.amount) '
+ 'FROM account_tax_code c, '
+ 'account_tax_line tl, '
+ 'account_move_line l '
+ 'WHERE c.id = tl.code '
+ 'AND tl.move_line = l.id '
+ 'AND c.id IN (' +
+ ','.join(('%s',) * len(all_ids)) + ') '
+ 'AND ' + line_query + ' '
+ 'AND c.active '
+ 'GROUP BY c.id', all_ids)
code_sum = {}
for code_id, sum in cursor.fetchall():
# SQLite uses float for SUM
@@ -386,10 +385,12 @@ class TaxTemplate(ModelSQL, ModelView):
invoice_tax_sign = fields.Numeric('Invoice Tax Sign', digits=(2, 0))
credit_note_base_code = fields.Many2One('account.tax.code.template',
'Credit Note Base Code')
- credit_note_base_sign = fields.Numeric('Credit Note Base Sign', digits=(2, 0))
+ credit_note_base_sign = fields.Numeric('Credit Note Base Sign',
+ digits=(2, 0))
credit_note_tax_code = fields.Many2One('account.tax.code.template',
'Credit Note Tax Code')
- credit_note_tax_sign = fields.Numeric('Credit Note Tax Sign', digits=(2, 0))
+ credit_note_tax_sign = fields.Numeric('Credit Note Tax Sign',
+ digits=(2, 0))
account = fields.Many2One('account.account.template', 'Account Template',
domain=[('parent', '=', None)], required=True)
@@ -454,8 +455,8 @@ class TaxTemplate(ModelSQL, ModelView):
used for tax creation
:param company_id: the id of the company for which taxes are created
:param template2tax_code: a dictionary with tax code template id as key
- and tax code id as value, used to convert tax code template into
- tax code
+ and tax code id as value, used to convert tax code template
+ into tax code
:param template2account: a dictionary with account template id as key
and account id as value, used to convert account template into
account code
@@ -601,7 +602,8 @@ class Tax(ModelSQL, ModelView):
'required': (Eval('type') != 'none') & Eval('company'),
},
depends=['company', 'type'])
- credit_note_account = fields.Many2One('account.account', 'Credit Note Account',
+ credit_note_account = fields.Many2One('account.account',
+ 'Credit Note Account',
domain=[
('company', '=', Eval('company')),
('kind', 'not in', ['view', 'receivable', 'payable']),
@@ -638,8 +640,8 @@ class Tax(ModelSQL, ModelView):
states={
'readonly': Eval('type') == 'none',
}, depends=['type'])
- credit_note_base_sign = fields.Numeric('Credit Note Base Sign', digits=(2, 0),
- help='Usualy 1 or -1',
+ credit_note_base_sign = fields.Numeric('Credit Note Base Sign',
+ digits=(2, 0), help='Usualy 1 or -1',
states={
'required': Eval('type') != 'none',
'readonly': Eval('type') == 'none',
@@ -649,8 +651,8 @@ class Tax(ModelSQL, ModelView):
states={
'readonly': Eval('type') == 'none',
}, depends=['type'])
- credit_note_tax_sign = fields.Numeric('Credit Note Tax Sign', digits=(2, 0),
- help='Usualy 1 or -1',
+ credit_note_tax_sign = fields.Numeric('Credit Note Tax Sign',
+ digits=(2, 0), help='Usualy 1 or -1',
states={
'required': Eval('type') != 'none',
'readonly': Eval('type') == 'none',
@@ -782,8 +784,8 @@ class Tax(ModelSQL, ModelView):
:param tax: a tax id or the BrowseRecord of the tax
:param template2tax_code: a dictionary with tax code template id as key
- and tax code id as value, used to convert tax code template into
- tax code
+ and tax code id as value, used to convert tax code template
+ into tax code
:param template2account: a dictionary with account template id as key
and account id as value, used to convert account template into
account code
@@ -802,53 +804,53 @@ class Tax(ModelSQL, ModelView):
if tax.template:
vals = template_obj._get_tax_value(tax.template, tax=tax)
- if tax.template.invoice_account \
- and tax.invoice_account.id != \
- template2account.get(tax.template.invoice_account.id):
- vals['invoice_account'] = \
- template2account.get(tax.template.invoice_account.id)
- elif not tax.template.invoice_account \
- and tax.invoice_account:
+ if (tax.template.invoice_account
+ and tax.invoice_account.id != template2account.get(
+ tax.template.invoice_account.id)):
+ vals['invoice_account'] = template2account.get(
+ tax.template.invoice_account.id)
+ elif (not tax.template.invoice_account
+ and tax.invoice_account):
vals['invoice_account'] = None
- if tax.template.credit_note_account \
- and tax.credit_note_account.id != \
- template2account.get(tax.template.credit_note_account.id):
- vals['credit_note_account'] = \
- template2account.get(tax.template.credit_note_account.id)
- elif not tax.template.credit_note_account \
- and tax.credit_note_account:
+ if (tax.template.credit_note_account
+ and tax.credit_note_account.id != template2account.get(
+ tax.template.credit_note_account.id)):
+ vals['credit_note_account'] = template2account.get(
+ tax.template.credit_note_account.id)
+ elif (not tax.template.credit_note_account
+ and tax.credit_note_account):
vals['credit_note_account'] = None
- if tax.template.invoice_base_code \
- and tax.invoice_base_code.id != \
- template2tax_code.get(tax.template.invoice_base_code.id):
- vals['invoice_base_code'] = \
- template2tax_code.get(tax.template.invoice_base_code.id)
- elif not tax.template.invoice_base_code \
- and tax.invoice_base_code:
+ if (tax.template.invoice_base_code
+ and tax.invoice_base_code.id != template2tax_code.get(
+ tax.template.invoice_base_code.id)):
+ vals['invoice_base_code'] = template2tax_code.get(
+ tax.template.invoice_base_code.id)
+ elif (not tax.template.invoice_base_code
+ and tax.invoice_base_code):
vals['invoice_base_code'] = None
- if tax.template.invoice_tax_code \
- and tax.invoice_tax_code.id != \
- template2tax_code.get(tax.template.invoice_tax_code.id):
- vals['invoice_tax_code'] = \
- template2tax_code.get(tax.template.invoice_tax_code.id)
- elif not tax.template.invoice_tax_code \
- and tax.invoice_tax_code:
+ if (tax.template.invoice_tax_code
+ and tax.invoice_tax_code.id != template2tax_code.get(
+ tax.template.invoice_tax_code.id)):
+ vals['invoice_tax_code'] = template2tax_code.get(
+ tax.template.invoice_tax_code.id)
+ elif (not tax.template.invoice_tax_code
+ and tax.invoice_tax_code):
vals['invoice_tax_code'] = None
- if tax.template.credit_note_base_code \
- and tax.credit_note_base_code.id != \
- template2tax_code.get(tax.template.credit_note_base_code.id):
- vals['credit_note_base_code'] = \
- template2tax_code.get(tax.template.credit_note_base_code.id)
- elif not tax.template.credit_note_base_code \
- and tax.credit_note_base_code:
+ if (tax.template.credit_note_base_code
+ and tax.credit_note_base_code.id != template2tax_code.get(
+ tax.template.credit_note_base_code.id)):
+ vals['credit_note_base_code'] = template2tax_code.get(
+ tax.template.credit_note_base_code.id)
+ elif (not tax.template.credit_note_base_code
+ and tax.credit_note_base_code):
vals['credit_note_base_code'] = None
- if tax.template.credit_note_tax_code \
- and tax.credit_note_tax_code.id != \
- template2tax_code.get(tax.template.credit_note_tax_code.id):
- vals['credit_note_tax_code'] = \
- template2tax_code.get(tax.template.credit_note_tax_code.id)
- elif not tax.template.credit_note_tax_code \
- and tax.credit_note_tax_code:
+ if (tax.template.credit_note_tax_code
+ and tax.credit_note_tax_code.id != template2tax_code.get(
+ tax.template.credit_note_tax_code.id)):
+ vals['credit_note_tax_code'] = template2tax_code.get(
+ tax.template.credit_note_tax_code.id)
+ elif (not tax.template.credit_note_tax_code
+ and tax.credit_note_tax_code):
vals['credit_note_tax_code'] = None
if vals:
diff --git a/tests/test_account.py b/tests/test_account.py
index b1b3e79a02..05f6ab7c76 100644
--- a/tests/test_account.py
+++ b/tests/test_account.py
@@ -2,7 +2,8 @@
#This file is part of Tryton. The COPYRIGHT file at the top level of
#this repository contains the full copyright notices and license terms.
-import sys, os
+import sys
+import os
DIR = os.path.abspath(os.path.normpath(os.path.join(__file__,
'..', '..', '..', '..', '..', 'trytond')))
if os.path.isdir(DIR):
@@ -108,6 +109,7 @@ class AccountTestCase(unittest.TestCase):
self.assertEqual(len(fiscalyear.periods), 12)
transaction.cursor.commit()
+
def suite():
suite = trytond.tests.test_tryton.suite()
from trytond.modules.company.tests import test_company