Replace wrong usage of False by None
issue2512
This commit is contained in:
1 parent
7aeca3313b
commit
36bb3ddde1
7 files changed
+115
-134
No files matched your search
+41
-48
@@ -85,7 +85,7 @@ class TypeTemplate(ModelSQL, ModelView):
|
||||
return res
|
||||
|
||||
def create_type(self, template, company_id, template2type=None,
|
||||
parent_id=False):
|
||||
parent_id=None):
|
||||
'''
|
||||
Create recursively types based on template.
|
||||
|
||||
@@ -403,7 +403,7 @@ class AccountTemplate(ModelSQL, ModelView):
|
||||
return res
|
||||
|
||||
def create_account(self, template, company_id, template2account=None,
|
||||
template2type=None, parent_id=False):
|
||||
template2type=None, parent_id=None):
|
||||
'''
|
||||
Create recursively accounts based on template.
|
||||
|
||||
@@ -437,7 +437,7 @@ class AccountTemplate(ModelSQL, ModelView):
|
||||
vals = self._get_account_value(template)
|
||||
vals['company'] = company_id
|
||||
vals['parent'] = parent_id
|
||||
vals['type'] = template2type.get(template.type.id, False)
|
||||
vals['type'] = template2type.get(template.type.id)
|
||||
|
||||
new_id = account_obj.create(vals)
|
||||
|
||||
@@ -604,7 +604,7 @@ class Account(ModelSQL, ModelView):
|
||||
return True
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company') or None
|
||||
|
||||
def default_reconcile(self):
|
||||
return False
|
||||
@@ -712,7 +712,7 @@ class Account(ModelSQL, ModelView):
|
||||
res[account_id] += deferral.debit - deferral.credit
|
||||
else:
|
||||
with Transaction().set_context(fiscalyear=fiscalyear.id,
|
||||
date=False):
|
||||
date=None):
|
||||
res2 = self.get_balance(ids, name)
|
||||
for account_id in ids:
|
||||
res[account_id] += res2[account_id]
|
||||
@@ -812,7 +812,7 @@ class Account(ModelSQL, ModelView):
|
||||
res[name][account_id] += deferral[name]
|
||||
else:
|
||||
with Transaction().set_context(fiscalyear=fiscalyear.id,
|
||||
date=False):
|
||||
date=None):
|
||||
res2 = self.get_credit_debit(ids, names)
|
||||
for account_id in ids:
|
||||
for name in names:
|
||||
@@ -851,7 +851,7 @@ class Account(ModelSQL, ModelView):
|
||||
default['left'] = 0
|
||||
default['right'] = 0
|
||||
res = super(Account, self).copy(ids, default=default)
|
||||
self._rebuild_tree('parent', False, 0)
|
||||
self._rebuild_tree('parent', None, 0)
|
||||
return res
|
||||
|
||||
def write(self, ids, vals):
|
||||
@@ -908,10 +908,8 @@ class Account(ModelSQL, ModelView):
|
||||
if account.template:
|
||||
vals = template_obj._get_account_value(account.template,
|
||||
account=account)
|
||||
if account.type.id != template2type.get(account.template.type.id,
|
||||
False):
|
||||
vals['type'] = template2type.get(account.template.type.id,
|
||||
False)
|
||||
if account.type.id != template2type.get(account.template.type.id):
|
||||
vals['type'] = template2type.get(account.template.type.id)
|
||||
if vals:
|
||||
self.write(account.id, vals)
|
||||
|
||||
@@ -1103,13 +1101,12 @@ class PrintGeneralLegderStart(ModelView):
|
||||
def default_fiscalyear(self):
|
||||
fiscalyear_obj = Pool().get('account.fiscalyear')
|
||||
fiscalyear_id = fiscalyear_obj.find(
|
||||
Transaction().context.get('company', False), exception=False)
|
||||
Transaction().context.get('company'), exception=False)
|
||||
if fiscalyear_id:
|
||||
return fiscalyear_id
|
||||
return False
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
def default_posted(self):
|
||||
return False
|
||||
@@ -1119,8 +1116,8 @@ class PrintGeneralLegderStart(ModelView):
|
||||
|
||||
def on_change_fiscalyear(self, vals):
|
||||
return {
|
||||
'start_period': False,
|
||||
'end_period': False,
|
||||
'start_period': None,
|
||||
'end_period': None,
|
||||
}
|
||||
|
||||
PrintGeneralLegderStart()
|
||||
@@ -1141,11 +1138,11 @@ class PrintGeneralLegder(Wizard):
|
||||
if session.start.start_period:
|
||||
start_period = session.start.start_period.id
|
||||
else:
|
||||
start_period = False
|
||||
start_period = None
|
||||
if session.start.end_period:
|
||||
end_period = session.start.end_period.id
|
||||
else:
|
||||
end_period = False
|
||||
end_period = None
|
||||
data = {
|
||||
'company': session.start.company.id,
|
||||
'fiscalyear': session.start.fiscalyear.id,
|
||||
@@ -1313,13 +1310,12 @@ class PrintTrialBalanceStart(ModelView):
|
||||
def default_fiscalyear(self):
|
||||
fiscalyear_obj = Pool().get('account.fiscalyear')
|
||||
fiscalyear_id = fiscalyear_obj.find(
|
||||
Transaction().context.get('company') or False, exception=False)
|
||||
Transaction().context.get('company'), exception=False)
|
||||
if fiscalyear_id:
|
||||
return fiscalyear_id
|
||||
return False
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
def default_posted(self):
|
||||
return False
|
||||
@@ -1329,8 +1325,8 @@ class PrintTrialBalanceStart(ModelView):
|
||||
|
||||
def on_change_fiscalyear(self, vals):
|
||||
return {
|
||||
'start_period': False,
|
||||
'end_period': False,
|
||||
'start_period': None,
|
||||
'end_period': None,
|
||||
}
|
||||
|
||||
PrintTrialBalanceStart()
|
||||
@@ -1351,11 +1347,11 @@ class PrintTrialBalance(Wizard):
|
||||
if session.start.start_period:
|
||||
start_period = session.start.start_period.id
|
||||
else:
|
||||
start_period = False
|
||||
start_period = None
|
||||
if session.start.end_period:
|
||||
end_period = session.start.end_period.id
|
||||
else:
|
||||
end_period = False
|
||||
end_period = None
|
||||
data = {
|
||||
'company': session.start.company.id,
|
||||
'fiscalyear': session.start.fiscalyear.id,
|
||||
@@ -1465,7 +1461,7 @@ class OpenBalanceSheetStart(ModelView):
|
||||
return date_obj.today()
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
def default_posted(self):
|
||||
return False
|
||||
@@ -1537,21 +1533,20 @@ class OpenIncomeStatementStart(ModelView):
|
||||
def default_fiscalyear(self):
|
||||
fiscalyear_obj = Pool().get('account.fiscalyear')
|
||||
fiscalyear_id = fiscalyear_obj.find(
|
||||
Transaction().context.get('company') or False, exception=False)
|
||||
Transaction().context.get('company'), exception=False)
|
||||
if fiscalyear_id:
|
||||
return fiscalyear_id
|
||||
return False
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
def default_posted(self):
|
||||
return False
|
||||
|
||||
def on_change_fiscalyear(self, vals):
|
||||
return {
|
||||
'start_period': False,
|
||||
'end_period': False,
|
||||
'start_period': None,
|
||||
'end_period': None,
|
||||
}
|
||||
|
||||
OpenIncomeStatementStart()
|
||||
@@ -1620,10 +1615,10 @@ class CreateChartAccount(ModelView):
|
||||
_description = __doc__
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
account_template = fields.Many2One('account.account.template',
|
||||
'Account Template', required=True, domain=[('parent', '=', False)])
|
||||
'Account Template', required=True, domain=[('parent', '=', None)])
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
CreateChartAccount()
|
||||
|
||||
@@ -1703,7 +1698,7 @@ class CreateChart(Wizard):
|
||||
template2tax_code = {}
|
||||
tax_code_template_ids = tax_code_template_obj.search([
|
||||
('account', '=', account_template.id),
|
||||
('parent', '=', False),
|
||||
('parent', '=', None),
|
||||
])
|
||||
for tax_code_template in tax_code_template_obj.browse(
|
||||
tax_code_template_ids):
|
||||
@@ -1715,7 +1710,7 @@ class CreateChart(Wizard):
|
||||
template2tax = {}
|
||||
tax_template_ids = tax_template_obj.search([
|
||||
('account', '=', account_template.id),
|
||||
('parent', '=', False),
|
||||
('parent', '=', None),
|
||||
])
|
||||
for tax_template in tax_template_obj.browse(tax_template_ids):
|
||||
tax_template_obj.create_tax(tax_template,
|
||||
@@ -1766,7 +1761,7 @@ class CreateChart(Wizard):
|
||||
], limit=1)
|
||||
property_ids = property_obj.search([
|
||||
('field', '=', account_receivable_field_id),
|
||||
('res', '=', False),
|
||||
('res', '=', None),
|
||||
('company', '=', session.properties.company.id),
|
||||
])
|
||||
with Transaction().set_user(0):
|
||||
@@ -1785,7 +1780,7 @@ class CreateChart(Wizard):
|
||||
], limit=1)
|
||||
property_ids = property_obj.search([
|
||||
('field', '=', account_payable_field_id),
|
||||
('res', '=', False),
|
||||
('res', '=', None),
|
||||
('company', '=', session.properties.company.id),
|
||||
])
|
||||
with Transaction().set_user(0):
|
||||
@@ -1807,7 +1802,7 @@ class UpdateChartStart(ModelView):
|
||||
_name = 'account.update_chart.start'
|
||||
_description = __doc__
|
||||
account = fields.Many2One('account.account', 'Root Account',
|
||||
required=True, domain=[('parent', '=', False)])
|
||||
required=True, domain=[('parent', '=', None)])
|
||||
|
||||
UpdateChartStart()
|
||||
|
||||
@@ -1876,7 +1871,7 @@ class UpdateChart(Wizard):
|
||||
template2tax_code = {}
|
||||
tax_code_ids = tax_code_obj.search([
|
||||
('company', '=', account.company.id),
|
||||
('parent', '=', False),
|
||||
('parent', '=', None),
|
||||
])
|
||||
for tax_code in tax_code_obj.browse(tax_code_ids):
|
||||
tax_code_obj.update_tax_code(tax_code,
|
||||
@@ -1885,7 +1880,7 @@ class UpdateChart(Wizard):
|
||||
if account.template:
|
||||
tax_code_template_ids = tax_code_template_obj.search([
|
||||
('account', '=', account.template.id),
|
||||
('parent', '=', False),
|
||||
('parent', '=', None),
|
||||
])
|
||||
for tax_code_template in tax_code_template_obj.browse(
|
||||
tax_code_template_ids):
|
||||
@@ -1897,7 +1892,7 @@ class UpdateChart(Wizard):
|
||||
template2tax = {}
|
||||
tax_ids = tax_obj.search([
|
||||
('company', '=', account.company.id),
|
||||
('parent', '=', False),
|
||||
('parent', '=', None),
|
||||
])
|
||||
for tax in tax_obj.browse(tax_ids):
|
||||
tax_obj.update_tax(tax, template2tax_code=template2tax_code,
|
||||
@@ -1907,7 +1902,7 @@ class UpdateChart(Wizard):
|
||||
if account.template:
|
||||
tax_template_ids = tax_template_obj.search([
|
||||
('account', '=', account.template.id),
|
||||
('parent', '=', False),
|
||||
('parent', '=', None),
|
||||
])
|
||||
for tax_template in tax_template_obj.browse(tax_template_ids):
|
||||
tax_template_obj.create_tax(tax_template, account.company.id,
|
||||
@@ -1972,16 +1967,15 @@ class OpenThirdPartyBalanceStart(ModelView):
|
||||
def default_fiscalyear(self):
|
||||
fiscalyear_obj = Pool().get('account.fiscalyear')
|
||||
fiscalyear_id = fiscalyear_obj.find(
|
||||
Transaction().context.get('company') or False, exception=False)
|
||||
Transaction().context.get('company'), exception=False)
|
||||
if fiscalyear_id:
|
||||
return fiscalyear_id
|
||||
return False
|
||||
|
||||
def default_posted(self):
|
||||
return False
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
OpenThirdPartyBalanceStart()
|
||||
|
||||
@@ -2091,10 +2085,9 @@ class OpenAgedBalanceStart(ModelView):
|
||||
def default_fiscalyear(self):
|
||||
fiscalyear_obj = Pool().get('account.fiscalyear')
|
||||
fiscalyear_id = fiscalyear_obj.find(
|
||||
Transaction().context.get('company') or False, exception=False)
|
||||
Transaction().context.get('company'), exception=False)
|
||||
if fiscalyear_id:
|
||||
return fiscalyear_id
|
||||
return False
|
||||
|
||||
def default_balance_type(self):
|
||||
return "customer"
|
||||
@@ -2115,7 +2108,7 @@ class OpenAgedBalanceStart(ModelView):
|
||||
return 'day'
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
OpenAgedBalanceStart()
|
||||
|
||||
|
||||
+3
-3
@@ -36,14 +36,14 @@ class Configuration(ModelSingleton, ModelSQL, ModelView):
|
||||
], limit=1)
|
||||
property_ids = property_obj.search([
|
||||
('field', '=', account_field_id),
|
||||
('res', '=', False),
|
||||
('res', '=', None),
|
||||
('company', '=', company_id),
|
||||
], limit=1)
|
||||
if property_ids:
|
||||
prop = property_obj.browse(property_ids[0])
|
||||
value = int(prop.value.split(',')[1])
|
||||
else:
|
||||
value = False
|
||||
value = None
|
||||
return dict((x, value) for x in ids)
|
||||
|
||||
def set_account(self, ids, name, value):
|
||||
@@ -56,7 +56,7 @@ class Configuration(ModelSingleton, ModelSQL, ModelView):
|
||||
], limit=1)
|
||||
property_ids = property_obj.search([
|
||||
('field', '=', account_field_id),
|
||||
('res', '=', False),
|
||||
('res', '=', None),
|
||||
('company', '=', company_id),
|
||||
])
|
||||
with Transaction().set_user(0):
|
||||
|
||||
+4
-4
@@ -35,7 +35,7 @@ class FiscalYear(ModelSQL, ModelView):
|
||||
required=True, domain=[('code', '=', 'account.move'),
|
||||
['OR',
|
||||
('company', '=', Eval('company')),
|
||||
('company', '=', False)
|
||||
('company', '=', None)
|
||||
]],
|
||||
context={
|
||||
'code': 'account.move',
|
||||
@@ -91,7 +91,7 @@ class FiscalYear(ModelSQL, ModelView):
|
||||
return 'open'
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
def check_dates(self, ids):
|
||||
cursor = Transaction().cursor
|
||||
@@ -199,7 +199,7 @@ class FiscalYear(ModelSQL, ModelView):
|
||||
if exception:
|
||||
self.raise_user_error('no_fiscalyear_date')
|
||||
else:
|
||||
return False
|
||||
return None
|
||||
return ids[0]
|
||||
|
||||
def _process_account(self, account, fiscalyear):
|
||||
@@ -254,7 +254,7 @@ class FiscalYear(ModelSQL, ModelView):
|
||||
period_obj.close(period_ids)
|
||||
|
||||
with Transaction().set_context(fiscalyear=fiscalyear.id,
|
||||
date=False):
|
||||
date=None):
|
||||
account_ids = account_obj.search([
|
||||
('company', '=', fiscalyear.company.id),
|
||||
])
|
||||
|
||||
+1
-1
@@ -145,7 +145,7 @@ class Journal(ModelSQL, ModelView):
|
||||
return False
|
||||
|
||||
def default_sequence(self):
|
||||
return False
|
||||
return None
|
||||
|
||||
def get_types(self):
|
||||
type_obj = Pool().get('account.journal.type')
|
||||
|
||||
@@ -103,7 +103,7 @@ class Move(ModelSQL, ModelView):
|
||||
|
||||
def default_period(self):
|
||||
period_obj = Pool().get('account.period')
|
||||
return period_obj.find(Transaction().context.get('company') or False,
|
||||
return period_obj.find(Transaction().context.get('company'),
|
||||
exception=False)
|
||||
|
||||
def default_state(self):
|
||||
@@ -123,8 +123,8 @@ class Move(ModelSQL, ModelView):
|
||||
period_obj = Pool().get('account.period')
|
||||
res = vals['date']
|
||||
line_ids = line_obj.search([
|
||||
('journal', '=', vals.get('journal', False)),
|
||||
('period', '=', vals.get('period', False)),
|
||||
('journal', '=', vals.get('journal')),
|
||||
('period', '=', vals.get('period')),
|
||||
], order=[('id', 'DESC')], limit=1)
|
||||
if line_ids:
|
||||
line = line_obj.browse(line_ids[0])
|
||||
@@ -243,10 +243,10 @@ class Move(ModelSQL, ModelView):
|
||||
if default is None:
|
||||
default = {}
|
||||
default = default.copy()
|
||||
default['reference'] = False
|
||||
default['reference'] = None
|
||||
default['state'] = self.default_state()
|
||||
default['post_date'] = False
|
||||
default['lines'] = False
|
||||
default['post_date'] = None
|
||||
default['lines'] = None
|
||||
|
||||
new_ids = []
|
||||
for move in self.browse(ids):
|
||||
@@ -544,8 +544,8 @@ class Line(ModelSQL, ModelView):
|
||||
|
||||
res = date_obj.today()
|
||||
line_ids = self.search([
|
||||
('journal', '=', Transaction().context.get('journal', False)),
|
||||
('period', '=', Transaction().context.get('period', False)),
|
||||
('journal', '=', Transaction().context.get('journal')),
|
||||
('period', '=', Transaction().context.get('period')),
|
||||
], order=[('id', 'DESC')], limit=1)
|
||||
if line_ids:
|
||||
line = self.browse(line_ids[0])
|
||||
@@ -639,7 +639,7 @@ class Line(ModelSQL, ModelView):
|
||||
code_id = tax.credit_note_tax_code.id
|
||||
account_id = tax.credit_note_account.id
|
||||
if base_id in line_code_taxes or not base_id:
|
||||
taxes.setdefault((account_id, code_id, tax.id), False)
|
||||
taxes.setdefault((account_id, code_id, tax.id), None)
|
||||
for tax_line in line.tax_lines:
|
||||
taxes[(line.account.id, tax_line.code.id,
|
||||
tax_line.tax.id)] = True
|
||||
@@ -656,14 +656,14 @@ class Line(ModelSQL, ModelView):
|
||||
if 'account' in fields:
|
||||
if total >= Decimal('0.0'):
|
||||
values.setdefault('account', move.journal.credit_account \
|
||||
and move.journal.credit_account.id or False)
|
||||
and move.journal.credit_account.id or None)
|
||||
else:
|
||||
values.setdefault('account', move.journal.debit_account \
|
||||
and move.journal.debit_account.id or False)
|
||||
and move.journal.debit_account.id or None)
|
||||
|
||||
if ('debit' in fields) or ('credit' in fields):
|
||||
values.setdefault('debit', total < 0 and - total or False)
|
||||
values.setdefault('credit', total > 0 and total or False)
|
||||
values.setdefault('debit', total < 0 and - total or None)
|
||||
values.setdefault('credit', total > 0 and total or None)
|
||||
|
||||
if move.journal.type in ('expense', 'revenue'):
|
||||
for account_id, code_id, tax_id in taxes:
|
||||
@@ -1171,7 +1171,7 @@ class Line(ModelSQL, ModelView):
|
||||
'period': (vals.get('period')
|
||||
or Transaction().context.get('period')),
|
||||
'journal': journal_id,
|
||||
'date': vals.get('date', False),
|
||||
'date': vals.get('date'),
|
||||
})
|
||||
res = super(Line, self).create(vals)
|
||||
line = self.browse(res)
|
||||
@@ -1183,9 +1183,9 @@ class Line(ModelSQL, ModelView):
|
||||
if default is None:
|
||||
default = {}
|
||||
if 'move' not in default:
|
||||
default['move'] = False
|
||||
default['move'] = None
|
||||
if 'reconciliation' not in default:
|
||||
default['reconciliation'] = False
|
||||
default['reconciliation'] = None
|
||||
return super(Line, self).copy(ids, default=default)
|
||||
|
||||
def view_header_get(self, value, view_type='form'):
|
||||
@@ -1246,7 +1246,7 @@ class Line(ModelSQL, ModelView):
|
||||
return True
|
||||
return result
|
||||
|
||||
def reconcile(self, ids, journal_id=False, date=False, account_id=False):
|
||||
def reconcile(self, ids, journal_id=None, date=None, account_id=None):
|
||||
pool = Pool()
|
||||
move_obj = pool.get('account.move')
|
||||
currency_obj = pool.get('currency.currency')
|
||||
@@ -1338,7 +1338,7 @@ class OpenJournalAsk(ModelView):
|
||||
|
||||
def default_period(self):
|
||||
period_obj = Pool().get('account.period')
|
||||
return period_obj.find(Transaction().context.get('company') or False,
|
||||
return period_obj.find(Transaction().context.get('company'),
|
||||
exception=False)
|
||||
|
||||
OpenJournalAsk()
|
||||
@@ -1508,9 +1508,9 @@ class ReconcileLines(Wizard):
|
||||
def transition_reconcile(self, session):
|
||||
line_obj = Pool().get('account.move.line')
|
||||
|
||||
journal_id = False
|
||||
date = False
|
||||
account_id = False
|
||||
journal_id = None
|
||||
date = None
|
||||
account_id = None
|
||||
if session.writeoff.journal:
|
||||
journal_id = session.writeoff.journal.id
|
||||
if session.writeoff.date:
|
||||
@@ -1577,7 +1577,7 @@ class OpenReconcileLines(Wizard):
|
||||
def do_open_(self, session, action):
|
||||
action['pyson_domain'] = PYSONEncoder().encode([
|
||||
('account', '=', session.start.account.id),
|
||||
('reconciliation', '=', False),
|
||||
('reconciliation', '=', None),
|
||||
])
|
||||
return action, {}
|
||||
|
||||
@@ -1623,7 +1623,7 @@ class PrintGeneralJournalStart(ModelView):
|
||||
return date_obj.today()
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
def default_posted(self):
|
||||
return False
|
||||
|
||||
@@ -138,7 +138,7 @@ class Period(ModelSQL, ModelView):
|
||||
:param date: the date searched
|
||||
:param exception: a boolean to raise or not an exception
|
||||
:param test_state: a boolean if true will search on non-closed periods
|
||||
:return: the period id found or False
|
||||
:return: the period id found or None
|
||||
'''
|
||||
date_obj = Pool().get('ir.date')
|
||||
|
||||
@@ -157,7 +157,7 @@ class Period(ModelSQL, ModelView):
|
||||
if exception:
|
||||
self.raise_user_error('no_period_date')
|
||||
else:
|
||||
return False
|
||||
return None
|
||||
return ids[0]
|
||||
|
||||
def _check(self, ids):
|
||||
|
||||
@@ -40,7 +40,7 @@ class CodeTemplate(ModelSQL, ModelView):
|
||||
parent = fields.Many2One('account.tax.code.template', 'Parent')
|
||||
childs = fields.One2Many('account.tax.code.template', 'parent', 'Children')
|
||||
account = fields.Many2One('account.account.template', 'Account Template',
|
||||
domain=[('parent', '=', False)], required=True)
|
||||
domain=[('parent', '=', None)], required=True)
|
||||
description = fields.Text('Description', translate=True)
|
||||
|
||||
def __init__(self):
|
||||
@@ -74,7 +74,7 @@ class CodeTemplate(ModelSQL, ModelView):
|
||||
return res
|
||||
|
||||
def create_tax_code(self, template, company_id, template2tax_code=None,
|
||||
parent_id=False):
|
||||
parent_id=None):
|
||||
'''
|
||||
Create recursively tax codes based on template.
|
||||
|
||||
@@ -173,7 +173,7 @@ class Code(ModelSQL, ModelView):
|
||||
return True
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
def on_change_with_currency_digits(self, vals):
|
||||
company_obj = Pool().get('company.company')
|
||||
@@ -391,7 +391,7 @@ class TaxTemplate(ModelSQL, ModelView):
|
||||
'Credit Note Tax Code')
|
||||
credit_note_tax_sign = fields.Numeric('Credit Note Tax Sign', digits=(2, 0))
|
||||
account = fields.Many2One('account.account.template', 'Account Template',
|
||||
domain=[('parent', '=', False)], required=True)
|
||||
domain=[('parent', '=', None)], required=True)
|
||||
|
||||
def __init__(self):
|
||||
super(TaxTemplate, self).__init__()
|
||||
@@ -446,7 +446,7 @@ class TaxTemplate(ModelSQL, ModelView):
|
||||
return res
|
||||
|
||||
def create_tax(self, template, company_id, template2tax_code,
|
||||
template2account, template2tax=None, parent_id=False):
|
||||
template2account, template2tax=None, parent_id=None):
|
||||
'''
|
||||
Create recursively taxes based on template.
|
||||
|
||||
@@ -483,32 +483,32 @@ class TaxTemplate(ModelSQL, ModelView):
|
||||
vals['invoice_account'] = \
|
||||
template2account[template.invoice_account.id]
|
||||
else:
|
||||
vals['invoice_account'] = False
|
||||
vals['invoice_account'] = None
|
||||
if template.credit_note_account:
|
||||
vals['credit_note_account'] = \
|
||||
template2account[template.credit_note_account.id]
|
||||
else:
|
||||
vals['credit_note_account'] = False
|
||||
vals['credit_note_account'] = None
|
||||
if template.invoice_base_code:
|
||||
vals['invoice_base_code'] = \
|
||||
template2tax_code[template.invoice_base_code.id]
|
||||
else:
|
||||
vals['invoice_base_code'] = False
|
||||
vals['invoice_base_code'] = None
|
||||
if template.invoice_tax_code:
|
||||
vals['invoice_tax_code'] = \
|
||||
template2tax_code[template.invoice_tax_code.id]
|
||||
else:
|
||||
vals['invoice_tax_code'] = False
|
||||
vals['invoice_tax_code'] = None
|
||||
if template.credit_note_base_code:
|
||||
vals['credit_note_base_code'] = \
|
||||
template2tax_code[template.credit_note_base_code.id]
|
||||
else:
|
||||
vals['credit_note_base_code'] = False
|
||||
vals['credit_note_base_code'] = None
|
||||
if template.credit_note_tax_code:
|
||||
vals['credit_note_tax_code'] = \
|
||||
template2tax_code[template.credit_note_tax_code.id]
|
||||
else:
|
||||
vals['credit_note_tax_code'] = False
|
||||
vals['credit_note_tax_code'] = None
|
||||
|
||||
new_id = tax_obj.create(vals)
|
||||
|
||||
@@ -691,7 +691,7 @@ class Tax(ModelSQL, ModelView):
|
||||
return Decimal('1')
|
||||
|
||||
def default_company(self):
|
||||
return Transaction().context.get('company') or False
|
||||
return Transaction().context.get('company')
|
||||
|
||||
def on_change_with_currency_digits(self, vals):
|
||||
company_obj = Pool().get('company.company')
|
||||
@@ -804,64 +804,52 @@ class Tax(ModelSQL, ModelView):
|
||||
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,
|
||||
False):
|
||||
template2account.get(tax.template.invoice_account.id):
|
||||
vals['invoice_account'] = \
|
||||
template2account.get(tax.template.invoice_account.id,
|
||||
False)
|
||||
template2account.get(tax.template.invoice_account.id)
|
||||
elif not tax.template.invoice_account \
|
||||
and tax.invoice_account:
|
||||
vals['invoice_account'] = False
|
||||
vals['invoice_account'] = None
|
||||
if tax.template.credit_note_account \
|
||||
and tax.credit_note_account.id != \
|
||||
template2account.get(tax.template.credit_note_account.id,
|
||||
False):
|
||||
template2account.get(tax.template.credit_note_account.id):
|
||||
vals['credit_note_account'] = \
|
||||
template2account.get(tax.template.credit_note_account.id,
|
||||
False)
|
||||
template2account.get(tax.template.credit_note_account.id)
|
||||
elif not tax.template.credit_note_account \
|
||||
and tax.credit_note_account:
|
||||
vals['credit_note_account'] = False
|
||||
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,
|
||||
False):
|
||||
template2tax_code.get(tax.template.invoice_base_code.id):
|
||||
vals['invoice_base_code'] = \
|
||||
template2tax_code.get(tax.template.invoice_base_code.id,
|
||||
False)
|
||||
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'] = False
|
||||
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,
|
||||
False):
|
||||
template2tax_code.get(tax.template.invoice_tax_code.id):
|
||||
vals['invoice_tax_code'] = \
|
||||
template2tax_code.get(tax.template.invoice_tax_code.id,
|
||||
False)
|
||||
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'] = False
|
||||
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,
|
||||
False):
|
||||
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,
|
||||
False)
|
||||
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'] = False
|
||||
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,
|
||||
False):
|
||||
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,
|
||||
False)
|
||||
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'] = False
|
||||
vals['credit_note_tax_code'] = None
|
||||
|
||||
if vals:
|
||||
self.write(tax.id, vals)
|
||||
@@ -926,7 +914,7 @@ class Line(ModelSQL, ModelView):
|
||||
|
||||
def on_change_tax(self, vals):
|
||||
res = {
|
||||
'code': False,
|
||||
'code': None,
|
||||
}
|
||||
return res
|
||||
|
||||
@@ -940,7 +928,7 @@ class RuleTemplate(ModelSQL, ModelView):
|
||||
name = fields.Char('Name', required=True, translate=True)
|
||||
lines = fields.One2Many('account.tax.rule.line.template', 'rule', 'Lines')
|
||||
account = fields.Many2One('account.account.template', 'Account Template',
|
||||
domain=[('parent', '=', False)], required=True)
|
||||
domain=[('parent', '=', None)], required=True)
|
||||
|
||||
def _get_tax_rule_value(self, template, rule=None):
|
||||
'''
|
||||
@@ -1031,7 +1019,7 @@ class Rule(ModelSQL, ModelView):
|
||||
:param tax: a tax id or the BrowseRecord of the tax
|
||||
:param pattern: a dictonary with rule line field as key
|
||||
and match value as value
|
||||
:return: a list of the tax id to use or False
|
||||
:return: a list of the tax id to use or None
|
||||
'''
|
||||
tax_obj = Pool().get('account.tax')
|
||||
rule_line_obj = Pool().get('account.tax.rule.line')
|
||||
@@ -1043,13 +1031,13 @@ class Rule(ModelSQL, ModelView):
|
||||
tax = tax_obj.browse(tax)
|
||||
|
||||
pattern = pattern.copy()
|
||||
pattern['group'] = tax and tax.group.id or False
|
||||
pattern['origin_tax'] = tax and tax.id or False
|
||||
pattern['group'] = tax and tax.group.id or None
|
||||
pattern['origin_tax'] = tax and tax.id or None
|
||||
|
||||
for line in rule.lines:
|
||||
if rule_line_obj.match(line, pattern):
|
||||
return rule_line_obj.get_taxes(line)
|
||||
return tax and [tax.id] or False
|
||||
return tax and [tax.id] or None
|
||||
|
||||
def update_rule(self, rule, template2rule=None):
|
||||
'''
|
||||
@@ -1178,11 +1166,11 @@ class RuleLineTemplate(ModelSQL, ModelView):
|
||||
if template.origin_tax:
|
||||
vals['origin_tax'] = template2tax[template.origin_tax.id]
|
||||
else:
|
||||
vals['origin_tax'] = False
|
||||
vals['origin_tax'] = None
|
||||
if template.tax:
|
||||
vals['tax'] = template2tax[template.tax.id]
|
||||
else:
|
||||
vals['tax'] = False
|
||||
vals['tax'] = None
|
||||
new_id = rule_line_obj.create(vals)
|
||||
template2rule_line[template.id] = new_id
|
||||
else:
|
||||
@@ -1256,7 +1244,7 @@ class RuleLine(ModelSQL, ModelView):
|
||||
'''
|
||||
if line.tax:
|
||||
return [line.tax.id]
|
||||
return False
|
||||
return None
|
||||
|
||||
def update_rule_line(self, rule_line, template2tax, template2rule,
|
||||
template2rule_line=None):
|
||||
@@ -1366,7 +1354,7 @@ class AccountTemplate(ModelSQL, ModelView):
|
||||
_name = 'account.account.template'
|
||||
taxes = fields.Many2Many('account.account.template-account.tax.template',
|
||||
'account', 'tax', 'Default Taxes',
|
||||
domain=[('parent', '=', False)])
|
||||
domain=[('parent', '=', None)])
|
||||
|
||||
AccountTemplate()
|
||||
|
||||
@@ -1390,7 +1378,7 @@ class Account(ModelSQL, ModelView):
|
||||
'account', 'tax', 'Default Taxes',
|
||||
domain=[
|
||||
('company', '=', Eval('company')),
|
||||
('parent', '=', False),
|
||||
('parent', '=', None),
|
||||
],
|
||||
help='Default tax for manual encoding of move lines \n' \
|
||||
'for journal types: "expense" and "revenue"',
|
||||
|
||||
Reference in new issue
Block a user