在销售订单行的图像中,我创建了许多字段来添加更多产品,如何在单价字段中计算和显示所有价格
由于
答案 0 :(得分:0)
为glass,fly,option1和option2价格创建字段,如单价格字段,如
x_XxX_P = fields.Float('XxX P',required = True,默认= 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(self):
for line in self:
line.price_unit = line.x_ + line.x_ + line.x_ + line.x_ + line.x _