Skip to Content
Menu
This question has been flagged
1484 Views

Hello!
I am developing a feature for manufacture module, that using a super function, it goes through the BoM lines and groups and filters them together(For our company use case, we need 2 BoM lists, detailed and grouped/filtered). The idea was to import detailed BoM lines to BoM model, and when creating MO, then it goes through the list and products with same name or meta info tag and returns shortened list for MO lines.

It worked when creating MO from scratch, but when creating via confirming a sales order with manufactorable product, it gives error(When creating a MO from scratch, the BoM lines are a list, but when creating via confirming sales order the BoM lines are objects).
How do I delete and update those object lines? And what other solutions are there?
the currently working code goes like this:


            raws = vals["move_raw_ids"]                        forrinraws:                # Taking metadata about unique line                dict = {}                bom_line = self.env['mrp.bom.line'].search([('id', '=', r[2]["bom_line_id"])])                if"["inbom_line.aircalc_description:                    slicedstring = bom_line.aircalc_description.split("[")[1][:-1]                    string = "{" + slicedstring + "}"                    dict = ast.literal_eval(str(string))                    if"ul"notindict:                        dict["ul"] = 0                else:                    dict["ul"] = 0                                    #If product exists in new list already and has no unique tag, we update quantity                ifr[2]["product_id"] ingrouped_idsanddict["ul"] == 0:                    index = grouped_ids.index(r[2]["product_id"])                    new_raws[index][2]["product_uom_qty"] += r[2]["product_uom_qty"]                                    #Otherwise we add new item into list, except unit metainfo or manual accessories                elifbom_line.aircalc_code != "UNIT-METAINFO"orbom_line.aircalc_code != "MANACC":                    grouped_ids.append(r[2]["product_id"])                    new_raws.append(r)                else:                    next
            vals["move_raw_ids"] = new_raws                returnsuper(SkawenProduction, self).create(vals)
Avatar
Discard
Related Posts Replies Views Activity
1
Jun 23
1586
1
Jun 22
2045
1
Aug 24
1524
1
Jun 24
585
1
Jan 24
995