Hello,
I am working on Odoo 11 and I am trying to display the values of a 2D list ( that I have created in my model) in the form view of quotes / orders.
Here is my model :
from odoo import fields, models, apiclass SaleSectionMargin(models.Model):_inherit = 'sale.order'@api.depends('order_line', 'order_line.product_uom_qty', 'order_line.price_unit', 'order_line.discount', 'order_line.purchase_price', 'order_line.qty_invoiced')def _compute_margin_section(self):for record in self:if record.order_line:nbSection = 0stockSection = []for line in record.order_line:if line.layout_category_id:if line.layout_category_id not in stockSection:stockSection.append(line.layout_category_id)nbSection += 1col = 3 # Nombre de cologneslistSection = [[0]*col for i in range(nbSection)]ligne = 0for section in stockSection:listSection[ligne][0] = sectionligne += 1for line in record.order_line:if line.layout_category_id:L = 0find = Falsewhile find is False:if listSection[L][0] == line.layout_category_id:listSection[L][1] += line.purchase_price * line.product_uom_qtyfind = TrueL += 1for line in record.order_line:if line.layout_category_id:find = FalseL = 0Totalcost = line.purchase_price*line.product_uom_qtydiscount = (Totalcost * line.discount)/100TotalPrice = line.price_unit*line.product_uom_qtyTotalmargin = (TotalPrice-discount)-Totalcostwhile find is False:if listSection[L][0] == line.layout_category_id:listSection[L][2] += Totalmarginfind = TrueL += 1return listSectionelse:return "test"
If anyone knows how to do it I would be very grateful !