Contributors mailing list archives

contributors@odoo-community.org

Re: unit test of onchange in v10 - full new api

by
Dave Lasley
- 27/09/2017 14:42:00
Ohhhh Pedro’s for the win there - it’s not even touching the db.

— Dave Lasley

On Sep 27, 2017, at 7:02 AM, Pedro M. Baeza (Tecnativa) <pedro.baeza@tecnativa.com> wrote:

You can use the new method for making things on cache/memory:

product = self.env['product.product'].new({
    'name': 'Test',
})
product._onchange...()
self.assertEqual(...)

Regards.

2017-09-27 15:46 GMT+02:00 Dave Lasley <dave@laslabs.com>:

I typically will just make the necessary changes to the record, such as the product in this instance, then run the onchange method. Its all just using the record cache now, so it just works. 


-Dave Lasley

On Sep 27, 2017, at 06:10, David Beal <david.beal@akretion.com> wrote:

Hi guys,

I need your advice about unit test and onchange in v10,

Compared to old api there is a behavior I can't reproduce

In old api we had `def my_onchange (self, cr, ..., product, pricelist, ...)`

For test unit, it's easy just call method by replacing product by the product you want test.

example here


But in new api, there is no more argument in onchange method.
Then i can't understand how can i specify a particular product for my own test.

In OCA test, i haven't found any example where i could understand explicitly
where I put my product value.

For sure expert really could help me here.

Thanks a lot

Bonne journée


David BEAL - Akretion
Odoo Development / Integration

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe