Skip to Content
Menu
This question has been flagged
2 Replies
1604 Views

Hey i am upgrading a module from v12 to 13 and it get installed but a function in it now not working and it is as following

@api.model
def run(self, product_id, product_qty, product_uom, location_id, name,
origin, values):
if 'stock_request_id' in values and values.get('stock_request_id'):
req = self.env['stock.request'].browse(
values.get('stock_request_id'))
if req.order_id:
origin = req.order_id.name
return super().run(product_id, product_qty, product_uom, location_id,
name, origin, values)

error msg is
TypeError: run() takes 2 positional arguments but 8 were given


But its working in odoo12. Kindly help
Avatar
Discard
Best Answer

Hi Abduallah,

I have found the function in stock_rule.py of odoo 13:

Thats why it throws the error - because it only takes 2 arguments.

@api.model

    def run(self, procurements):
        """ If 'run' is called on a kit, this override is made in order to call
        the original 'run' method with the values of the components of that kit.
        """
        the original 'run' method with the values of the components of that kit.
        """
        procurements_without_kit = []
        for procurement in procurements:
            bom_kit = self.env['mrp.bom']._bom_find(product=procurement.product_id, bom_type='phantom')
            if bom_kit:
                order_qty = procurement.product_uom._compute_quantity(procurement.product_qty, bom_kit.product_uom_id, round=False)
                qty_to_produce = (order_qty / bom_kit.product_qty)
                boms, bom_sub_lines = bom_kit.explode(procurement.product_id, qty_to_produce)
                for bom_line, bom_line_data in bom_sub_lines:
                    bom_line_uom = bom_line.product_uom_id
                    quant_uom = bom_line.product_id.uom_id
                    # recreate dict of values since each child has its own bom_line_id
                    values = dict(procurement.values, bom_line_id=bom_line.id)
                    component_qty, procurement_uom = bom_line_uom._adjust_uom_quantities(bom_line_data['qty'], quant_uom)
                    procurements_without_kit.append(self.env['procurement.group'].Procurement(
                        bom_line.product_id, component_qty, procurement_uom,
                        procurement.location_id, procurement.name,
                        procurement.origin, procurement.company_id, values))
            else:
                procurements_without_kit.append(procurement)
        return super(ProcurementGroup, self).run(procurements_without_kit)

Avatar
Discard
Author

Hey ti-sq,

its in https://apps.odoo.com/apps/modules/12.0/stock_request/ this module, kindly look into it, it'll be a big help.

i was unable to find about this run() function in the documentation.