Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an example of on_change usage #15

Open
florentx opened this issue Jan 10, 2013 · 0 comments
Open

add an example of on_change usage #15

florentx opened this issue Jan 10, 2013 · 0 comments
Labels

Comments

@florentx
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant