Community mailing list archives

community@mail.odoo.com

[8.0] wizard view during module install

by
mr.file
- 01/17/2015 12:03:20
Hi guys,
i'm trying to launch a wizard view during module install. I've looked at the code in the account module and made something similar, but can't reach the goal.
How can i achieve this task?

This is the code written until now (i'm porting a module to v8). The view is listed in the data section in __openerp__.py and the installer.py is imported in the file __init__.py
Thanks in advance
Fabrizio


installer.py
from openerp.osv import osv
from openerp import fields, models

class CorrispettiviConfigData(models.TransientModel):
    _name = 'corrispettivi.config.data'
    _inherit = 'res.config'

    default_credit_account_id = fields.Many2one('account.account', 'Default credit account', domain=[('type','!=','view')], required=True, help='If doubtful, use income account')
    default_debit_account_id = fields.Many2one('account.account', 'Default debit account', domain=[('type','!=','view')], required=True, help='If doubtful, use income account')

    def execute(self, cr, uid, ids, context=None):
        for o in self.browse(cr, uid, ids, context=context):
            seq_id = self.pool.get('ir.sequence').create(cr, uid, {
                'name': 'Sezionale Corrispettivi',
                'padding': 3,
                'prefix': 'COJ/%(year)s/',
                })
            journal_id = self.pool.get('account.journal').create(cr, uid, {
                'code': 'COJ',
                'name': 'Sezionale Corrispettivi',
                'type': 'sale',
                'corrispettivi': True,
                'sequence_id': seq_id,
                'default_credit_account_id': o.default_credit_account_id.id,
                'default_debit_account_id': o.default_debit_account_id.id,
                })
            partner_id = self.pool.get('res.partner').create(cr, uid, {
                'name': 'Corrispettivi',
                'ref': 'COJ',
                'customer': False,
                'supplier': False,
                'corrispettivi': True,
                })

installer_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>

        <!-- configartion view -->

        <record id="view_corrispettivi_config_data" model="ir.ui.view">
            <field name="name">Configure Corrispettivi</field>
            <field name="model">corrispettivi.config.data</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="base.res_config_installer"/>
            <field name="arch" type="xml">
              <data>
                <form position="attributes">
                  <attribute name="string">Corrispettivi Configuration</attribute>
                </form>
<separator string="title" position="replace">
                    <p class="oe_grey">
Select data to configure Corrispettivi module.
                    </p>
                    <group string="Configure corrispettivi" groups="account.group_account_user">
<group colspan="4" >
                            <field name="default_credit_account_id"/>
                            <field name="default_debit_account_id"/>
                    </group>
                    </group>
                </separator>
<footer position="replace">
                    <footer>
                      <button name="action_next" type="object" string="Continue" class="oe_highlight"/>
or
                      <button string="Skip" class="oe_link" special="cancel" />
                    </footer>
                </footer>
              </data>
            </field>
        </record>

        <record id="action_corrispettivi_config_data" model="ir.actions.act_window">
            <field name="name">Configure Corrispettivi</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">corrispettivi.config.data</field>
            <field name="view_id" ref="view_corrispettivi_config_data"/>
            <field name="view_type">form</field>
            <field name="view_mode">form</field>
            <field name="target">new</field>
        </record>

        <!-- register configuration wizard -->
        <record id="config_wizard_step_corrispettivi_config_data" model="ir.actions.todo">
            <field name="action_id" ref="action_corrispettivi_config_data"/>
            <field name="restart">onskip</field>
            <field name="groups_id" eval="[(6,0,[ref('base.group_no_one')])]"/>
        </record>

    </data>
</openerp>