如何在报价单的同一行添加多个产品?

How to add multi products in the same line in quotation?

如图销售订单行,我创建了很多字段来添加更多的产品如何在单价字段中计算并显示所有价格

谢谢

为玻璃、飞行、选项 1 和选项 2 价格创建字段,如单价字段,如

x_XxX_P = fields.Float('XxX P', required=True, default=0.0)

然后为每个新产品列创建 api 更改,例如

@api.multi

@api.onchange('x_XxX')
def product_id_change(self):
    if not self.x_XxX:
        return {'domain': {'product_uom': []}}

    vals = {}
    domain = {'product_uom': [('category_id', '=', self.x_XxX.uom_id.category_id.id)]}
    if not self.product_uom or (self.x_XxX.uom_id.id != self.product_uom.id):
        vals['product_uom'] = self.x_XxX.uom_id
        vals['product_uom_qty'] = 1.0

    product = self.x_XxX.with_context(
        lang=self.order_id.partner_id.lang,
        partner=self.order_id.partner_id.id,
        quantity=vals.get('product_uom_qty') or self.product_uom_qty,
        date=self.order_id.date_order,
        pricelist=self.order_id.pricelist_id.id,
        uom=self.product_uom.id
    )

    result = {'domain': domain}

    title = False
    message = False
    warning = {}
    if product.sale_line_warn != 'no-message':
        title = _("Warning for %s") % product.name
        message = product.sale_line_warn_msg
        warning['title'] = title
        warning['message'] = message
        result = {'warning': warning}
        if product.sale_line_warn == 'block':
            self.x_XxX = False
            return result

    self._compute_tax_id()

    if self.order_id.pricelist_id and self.order_id.partner_id:
        vals['x_XxX_P'] = self.env['account.tax']._fix_tax_included_price_company(self._get_display_price(product), product.taxes_id, self.tax_id, self.company_id)
    self.update(vals)

    return result

然后创建一个字段来计算所有价格

@api.depends('x', 'x', 'x_', 'x_', 'x_')

def _get_price_unit(自己):

自己的行:

line.price_unit = line.x_ + line.x_ + line.x_ + line.x_ + line.x_