Skip to content

add an example of on_change usage #15

@florentx

Description

@florentx

There's nothing specific for on_change events in ERPpeek.

The way to mimic the OpenERP client (6.1) is:

# on_change with ERPpeek for invoice creation

@step('this customer has {nb:d} invoices')
def impl(ctx, nb):
    assert_true(ctx.data['partner'])
    partner = ctx.data['partner']
    account_invoice_obj = model('account.invoice')
    for idx in xrange(1, nb + 1):
        # On change
        data = {
            'name': "Invoice # %d" % idx,
            'type': "out_invoice",
            'address_invoice_id': partner.address[0].id,
            'partner_id': partner.id,
        }
        rv = account_invoice_obj.onchange_partner_id([], 'out_invoice', partner.id, date.today(), False, False)
        data.update(rv['value'])
        inv = account_invoice_obj.create(data)
        if partner.contract_ids:
            inv.write({'contract_id': partner.contract_ids[0].id})
        ctx.data['invoice'] = inv

To be added to the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions