如何计算销售订单行中的两个自定义字段?

How to compute two custom fields in sale order line?

我在销售订单行(高度和宽度)中添加了两个新的服装字段和一个名为总面积的字段。我想计算总面积字段中的两个字段(高度和宽度)

谢谢

sale_order_line 班试试这个

@api.depends('height', 'width')
def _get_area(self):
    for line in self:
        line.area = line.height * line.width 


height = fields.Integer(string='Height')
width = fields.Integer(string='Width')
area = fields.Integer(compute='_get_area', string='Area article', readonly=True, store=True)