Struggle to insert wizard in Party module (overriding)

Still cannot inject my Wizard into Party Module.
I created a party.py in my custom module.
Added the following wizard in it:

## ——————— WIZARD TO LOAD PARTIES ———————————
class ImportStatementStart(ModelView):
    "Party Import Start"
    __name__ = 'party.party.import.start'
    file_ = fields.Binary("File", required=True)
    file_format = fields.Selection([(None, '')], 'File Format', required=True)

    @classmethod
    def default_file_format(cls):
        return 'CSV'

class ImportStatement(Wizard):
    "Party Import"
    __name__ = 'party.party.import'
    start = StateView('party.party.import.start',
        'party.party.import_party_form', [
            Button("Cancel", 'end', 'tryton-cancel'),
            Button("Import", 'import_', 'tryton-ok', default=True),
            ])
    import_ = StateAction('party.party')

    def do_import_(self, action):
        pool = Pool()
        Statement = pool.get('party.party')
        ###  HERE SOME IMPORT ACTIONS ####
        return action, data

I am adding the following lines in party.xml in my module folder:

    <!-- ########################################## -->
    <!-- # Action for importing parties from file # -->
    <!-- ########################################## -->
        <!-- An action: load parties from file  -->
        <record model="ir.action.wizard" id="wizard_parties_import">
            <field name="name">Import parties</field>
            <field name="wiz_name">party.party.import</field>
            <field name="model">party.party.import.start</field>
        </record>
        <!-- ADD an action ITEM in the list of actions: Import parties -->
        <record model="ir.action.keyword" id="act_wizard_parties_import">
            <field name="keyword">form_action</field>
            <field name="model">party.party,-1</field>
            <field name="action" ref="wizard_parties_import"/>
        </record>
        <!-- ADD an wizard view to get additional data from user-->
        <record model="ir.ui.view" id="import_party_form">
            <field name="model">party.party.import.start</field>
            <field name="type">form</field>
            <!-- form view file in ./view/import_party_form.xml -->
            <field name="name">import_party_form</field>
        </record>
        <!-- Add a menu item to Tryton with this action-->
        <menuitem parent="party.menu_party" sequence="20"
            action="wizard_parties_import" id="menu_party_import"/>

And still, get the errors:

ERROR:trytond.convert:Error while parsing xml file:
In tag record model ir.action.keyword with id fleets.act_wizard_parties_import

trytond.ir.action.WizardModelError: Wrong wizard model in keyword action "Import parties". - 

trytond.ir.action.WizardModelError: Wrong wizard model in keyword action "Import parties". - 

Where I can see the working example of wizard overriding??
(I added couple of wizards to my own module without problems)

Constantine.

Did you declare all (wizard, model) in your __init__.py file ?

Your problem is in the model field of the wizard:

The model is used to limit on which models the wizard should be abailable. I see you set here the start model but this is not aplicable as this is the start model of the wizard.

Setting the field to blank should fix the issue.

1 Like

Unbelievable!
Yes that’s work!

I didn’t expect that would be possible to omit the model. Didn’t tried that!
Thanks!

Constantine.
PS: I still thinking that is worth having more complex examples for “case studies” with detailed comments. Like I asked about 3-rd party SMTP option, modules overriding, wizard views etc… I would be happy to share my findings.

1 Like

Sure thing, that is an important part, that also not clearly discussed in docs, although it is pretty evident.

Constantine.

1 Like

When I call my Wizard from the client — I receive this runtime error:

Traceback (most recent call last):
  File "/trytond/wsgi.py", line 109, in dispatch_request
    return endpoint(request, **request.view_args)
  File "/trytond/protocols/dispatcher.py", line 48, in rpc
.....
    view_id = ModelData.get_id(module, fs_id)
  File "/trytond/ir/model.py", line 1239, in get_id
    % ".".join([module, fs_id]))
KeyError: 'Reference to party.import_party_form not found'

Here the description in party.xml
it actually loads with trytond-admin.

# /modules/mymodule/party.xml
        <!-- ADD an wizard view to get additional data from user-->
        <record model="ir.ui.view" id="import_party_form">
            <field name="model">party.party.import.start</field>
            <field name="type">form</field>
            <!-- form view file in ./view/import_party_form.xml -->
            <field name="name">import_party_form</field>
        </record>
        <!-- Add a menu item to Tryton with this action-->
        <menuitem parent="party.menu_party" sequence="20"
            action="wizard_parties_import" id="menu_party_import"/>

What happens actually? I cannot understand the error report.

Constantine.

Added more detailed reporting:

  File "/trytond/ir/model.py", line 1240, in get_id
    ".".join([module, fs_id]),
KeyError: "Reference ('party', 'import_party_form') to party.import_party_form not found"

Found an error. So silly!

As the report view is kept in …/mymodule/view/…
hence the header of Wizard should look like:

class ImportStatement(Wizard):
    "Party Import"
    __name__ = 'party.party.import'
    start = StateView('party.party.import.start',
##### ——— !!!!!! Here should be an ACTUAL path to report !!!!!! —————
            'mymodule.import_party_form', [
            Button("Cancel", 'end', 'tryton-cancel'),
            Button("Import", 'import_', 'tryton-ok', default=True),
            ])
    import_ = StateAction('party.act_party_form')

and still the report description is in ../mymodule/party.xml

Constantine.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.