Corrigiendo bug de ajustes de inventario - Modulo fix_inventory_line_constraint

Gustavo Orrillo
- 01/19/2020 - 1 min. de lectura

Mientras preparaba el material para el webinar de actualización de stocks con xmlrpc, me encontré con el siguiente error:

There is already one inventory adjustment line for this product

Despues de revisar el código de Odoo, me encontré que dicho error era causado por la siguiente restricción:

    def _check_no_duplicate_line(self):
        for line in self:
            domain = [
                ('id', '!=', line.id),
                ('product_id', '=', line.product_id.id),
                ('location_id', '=', line.location_id.id),
                ('partner_id', '=', line.partner_id.id),
                ('package_id', '=', line.package_id.id),
                ('prod_lot_id', '=', line.prod_lot_id.id),
                ('inventory_id', '=', line.inventory_id.id)]
            existings = self.search_count(domain)
            if existings:
                raise UserError(_("There is already one inventory adjustment line for this product,"
                                  " you should rather modify this one instead of creating a new one."))

La cual present un problema, practicamente impide la creación de lineas de inventario. Bueno, este problema fue solucionado con el módulo fix_inventory_line_constraint el cual lo pueden descargar de github. La instalación es muy sencilla, lo instalan y reinician Odoo.

Acerca de:

Gustavo Orrillo

Passionate about programming, he has implemented Odoo for different types of businesses since 2010. In Moldeo Interactive he is a founding Partner and Programmer; In addition to writing on the Blog about different topics related to the developments he makes.