Odoo 15.0 Development Changes
Things to look out for when migrating modules.
7 October, 2021 by
Odoo 15.0 Development Changes
Jared Kipe
| No comments yet

Last update added Oct. 8th 2021. Not so comprehensive list of things I've come across while migrating our modules to newly release Odoo 15.0

Migrating Modules & Techniques for Odoo 15.0

Assets.

You won't see this in the docs (yet), but frontend assets (Javascript & CSS/SCSS) are no longer compiled together by using xpaths on extension views like `web.assets_backend`. Instead new __manifest__.py key/dictionary 'assets' holds the various asset type of keys and allows you to have control over assets that load in different parts of Odoo. This also replaces the frontend 'qweb' key (now use `web.assets_qweb` in the assets key of manifest). 

As an example, take a look at this very simple module that re-themes the colors by putting a specific SCSS file before others by 'prepend'ing it.

{
    #  other parts of __manifest__.py
    'assets': {
        'web._assets_primary_variables': [
            ('prepend', 'your_module/static/src/scss/primary_variables.scss'),
        ],
    },
}

In the example, 'prepend' was used to put it before the other . Note that instead of putting it after the last script or link element (CSS/SCSS file), you now just either 'append' it to the list (default, no tuple), 'prepend', or 'replace' (which takes 3 arguments, like ('replace', 'original_module/something.scss', 'my_module/something_else.scss').


New Product Package Type model. 

If you interact with inventory packages, there are important refactors to be done.  If you had a shipping method that had something like.. 

my_default_packaging_id = fields.Many2one('product.packaging', ...)

you should now be linking to the new `stock.package.type` model.

Likewise, you should find instances of `some_stock_quant_package.packaging_id` and replace it with `some_stock_quant_package.package_type_id`.



New way to do inventory adjustments (especially useful in test code).

If you've worked with Odoo for a while, you have hopefully seen `stock.quant` and been told "don't touch them". Inventory was adjusted by stock moves and other adjustment mechanisms so `stock.quant` was how inventory was represented, but not to be manipulated directly. Well the `stock.inventory` model is gone and now you can create quants directly (along with some context magic) to adjust inventory. 

Let's say that you're writing a test that needs to have some inventory on hand for your scenario.  In Odoo 14.0 you might have done this.

adjustment = self.env['stock.inventory'].create({
    'name': 'Test Adjustment',
    'location_id': wh.lot_stock_id.id,
    'product_id': product.id,
    'filter': 'product',
})
adjustment.action_start()
adjustment.action_start.line_ids.create({
    'inventory_id': adjustment.id,
    'product_id': product.id,
    'product_qty': 100.0,
    'location_id': wh.lot_stock_id.id,
})
adjustment.action_validate()

In Odoo 15.0, you just need to create the quant with context `inventory_mode=True`. Note the similarities between creating an inventory line and creating the quant itself.

adjust_quant = self.env['stock.quant'].with_context(inventory_mode=True).create({
    'product_id': product.id,
    'inventory_quantity': 100.0,
    'location_id': wh.lot_stock_id.id,
})

Check back for More!

Odoo 15.0 Development Changes
Jared Kipe
7 October, 2021
Share this post
Archive
Sign in to leave a comment