This commit is contained in:
Jordi Esteve committed 2012-04-20 09:14:04 +02:00
commit 88aeff7de7
4 files changed
+5001 -2893

No files matched your search

+37 -36
View File
@@ -1762,43 +1762,44 @@ class CreateChart(Wizard):
property_obj = pool.get('ir.property')
model_field_obj = pool.get('ir.model.field')
account_receivable_field_id, = model_field_obj.search([
('model.model', '=', 'party.party'),
('name', '=', 'account_receivable'),
], limit=1)
property_ids = property_obj.search([
('field', '=', account_receivable_field_id),
('res', '=', None),
('company', '=', session.properties.company.id),
])
with Transaction().set_user(0):
property_obj.delete(property_ids)
if session.properties.account_receivable:
property_obj.create({
'field': account_receivable_field_id,
'value': 'account.account,' + \
str(session.properties.account_receivable.id),
'company': session.properties.company.id,
})
with Transaction().set_context(company=session.properties.company.id):
account_receivable_field_id, = model_field_obj.search([
('model.model', '=', 'party.party'),
('name', '=', 'account_receivable'),
], limit=1)
property_ids = property_obj.search([
('field', '=', account_receivable_field_id),
('res', '=', None),
('company', '=', session.properties.company.id),
])
with Transaction().set_user(0):
property_obj.delete(property_ids)
if session.properties.account_receivable:
property_obj.create({
'field': account_receivable_field_id,
'value': 'account.account,' + \
str(session.properties.account_receivable.id),
'company': session.properties.company.id,
})
account_payable_field_id, = model_field_obj.search([
('model.model', '=', 'party.party'),
('name', '=', 'account_payable'),
], limit=1)
property_ids = property_obj.search([
('field', '=', account_payable_field_id),
('res', '=', None),
('company', '=', session.properties.company.id),
])
with Transaction().set_user(0):
property_obj.delete(property_ids)
if session.properties.account_payable:
property_obj.create({
'field': account_payable_field_id,
'value': 'account.account,' + \
str(session.properties.account_payable.id),
'company': session.properties.company.id,
})
account_payable_field_id, = model_field_obj.search([
('model.model', '=', 'party.party'),
('name', '=', 'account_payable'),
], limit=1)
property_ids = property_obj.search([
('field', '=', account_payable_field_id),
('res', '=', None),
('company', '=', session.properties.company.id),
])
with Transaction().set_user(0):
property_obj.delete(property_ids)
if session.properties.account_payable:
property_obj.create({
'field': account_payable_field_id,
'value': 'account.account,' + \
str(session.properties.account_payable.id),
'company': session.properties.company.id,
})
return 'end'
CreateChart()
+2087 -1420
View File
File diff suppressed because it is too large. Load diff
+2873 -1433
View File
File diff suppressed because it is too large. Load diff
+4 -4
View File
@@ -655,15 +655,15 @@ class Line(ModelSQL, ModelView):
if 'account' in fields:
if total >= Decimal('0.0'):
values.setdefault('account', move.journal.credit_account \
values['account'] = (move.journal.credit_account \
and move.journal.credit_account.id or None)
else:
values.setdefault('account', move.journal.debit_account \
values['account'] = (move.journal.debit_account \
and move.journal.debit_account.id or None)
if ('debit' in fields) or ('credit' in fields):
values.setdefault('debit', total < 0 and - total or None)
values.setdefault('credit', total > 0 and total or None)
values['debit'] = total < 0 and - total or Decimal(0)
values['credit'] = total > 0 and total or Decimal(0)
if move.journal.type in ('expense', 'revenue'):
for account_id, code_id, tax_id in taxes: