changeset b35bb47628f6 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset;node=b35bb47628f6
description:
Set default accounts on create and update chart wizards
issue9382
review306261002
diffstat:
account.py | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diffs (45 lines):
diff -r 13e408280657 -r b35bb47628f6 account.py
--- a/account.py Mon Jul 27 16:13:56 2020 +0200
+++ b/account.py Tue Aug 25 18:04:50 2020 +0200
@@ -2360,10 +2360,24 @@
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 @@
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()