bypass wizard in proteus

22 views
Skip to first unread message

lists.j...@symetrie.com

unread,
Jul 18, 2017, 3:45:15 AM7/18/17
to try...@googlegroups.com
Hi,


When setting up a new db from proteus, is it mandatory to call the wizards (ie, to simulate the actions done from the client) or is it possible/recommended to bypass it and populate directly the db?
Below the two ways I tried.

Seems that the company doesn’t become the default company for the next script lines with the second method.
With the wizard way, where can I find the form parameters to be filled ?

# wizard
company_config = Wizard('company.company.config')
company_config.execute('company')
company = company_config.form
company.name = MY_DATA['company']['name']
euro, = Currency.find([('code', '=', MY_DATA['company']['currency'])])
company.currency = euro
company.footer = MY_DATA['company']['footer']
company.party = Party()
company_config.execute('add')
company, = Company.find()

or

# simply create company
party = Party(name=MY_DATA['company']['name'], lang=fr)
party.save()
company = Company(party=party, currency=euro)
company.footer = MY_DATA['company']['footer']
company.timezone = MY_DATA['company']['timezone']
company.vat_country = MY_DATA['company']['country']
company.vat_number = MY_DATA['company']['vat_number']
company.save()

Jean-Christophe Michel

Sergi Almacellas Abellana

unread,
Jul 18, 2017, 3:51:33 AM7/18/17
to try...@googlegroups.com
El 18/07/17 a les 09:45, lists.j...@symetrie.com ha escrit:
> Hi,
>
>
> When setting up a new db from proteus, is it mandatory to call the wizards (ie, to simulate the actions done from the client) or is it possible/recommended to bypass it and populate directly the db?
> Below the two ways I tried.
>
> Seems that the company doesn’t become the default company for the next script lines with the second method.
> With the wizard way, where can I find the form parameters to be filled ?
For creating the company you can have a look at the test tools of
company module:

http://hg.tryton.org/modules/company/file/5b8a0005ebf9/tests/tools.py#l11

Once the data is created, you can mark the create company wizard as
done. This data is stored in the ir.config.wizard.item table. We use the
following code to mark all wizard items as done:

ConfigWizardItem = Model.get('ir.module.config_wizard.item')

items = []

for item in ConfigWizardItem.find([('state', '!=', 'done')]):

item.state = 'done'

items.append(item)

ConfigWizardItem.save(items)

Hope it helps.

--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk
Reply all
Reply to author
Forward
0 new messages