تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2799 أدوات العرض

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)
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يونيو 23
3489
1
يونيو 22
3518
1
أغسطس 24
3162
coding system تم الحل
1
يونيو 24
1997
1
يناير 24
2758