Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
2851 Weergaven

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
jun. 23
3681
1
jun. 22
3600
1
aug. 24
3320
1
jun. 24
2155
1
jan. 24
2976