Set default accounts on create and update chart wizards
issue9382 review306261002
This commit is contained in:
1 parent
cf489cbe14
commit
28175f11bf
1 file changed
+24
-1
+24
-1
@@ -2360,10 +2360,24 @@ class CreateChart(Wizard):
|
||||
return 'properties'
|
||||
|
||||
def default_properties(self, fields):
|
||||
return {
|
||||
defaults = {
|
||||
'company': self.account.company.id,
|
||||
}
|
||||
|
||||
receivable_accounts = Account.search([
|
||||
('type.receivable', '=', True),
|
||||
], limit=2)
|
||||
payable_accounts = Account.search([
|
||||
('type.payable', '=', True),
|
||||
], limit=2)
|
||||
|
||||
if len(receivable_accounts) == 1:
|
||||
defaults['account_receivable'] = receivable_accounts[0].id
|
||||
if len(payable_accounts) == 1:
|
||||
defaults['account_payable'] = payable_accounts[0].id
|
||||
|
||||
return defaults
|
||||
|
||||
def transition_create_properties(self):
|
||||
pool = Pool()
|
||||
Configuration = pool.get('account.configuration')
|
||||
@@ -2404,6 +2418,15 @@ class UpdateChart(Wizard):
|
||||
Button('OK', 'end', 'tryton-ok', default=True),
|
||||
])
|
||||
|
||||
def default_start(self, fields):
|
||||
defaults = {}
|
||||
charts = Account.search([
|
||||
('parent', '=', None),
|
||||
], limit=2)
|
||||
if len(charts) == 1:
|
||||
defaults['account'] = charts[0].id
|
||||
return defaults
|
||||
|
||||
@inactive_records
|
||||
def transition_update(self):
|
||||
pool = Pool()
|
||||
|
||||
Reference in new issue
Block a user