我需要sub_total_price字段的值将自动在total_price字段。假设sub_total_price = 300,则total_price = 300自动
*** order.py ***
class Order_Line(models.Model):
_name = 'orderline.data'
_description = "Oder details"
weight = fields.Float(string="Weight", required=True)
product_image = fields.Image(string="Image")
product_quantity = fields.Integer(string="Quantity", required=True)
making_cost = fields.Integer(string="Making cost", )
gold_rate = fields.Float(string="Gold Rate", required=True, )
sub_total_price = fields.Float( compute='gold_cost_count', store=True)
create_orderline = fields.Many2one('order.order', string="Oder Line")
class PaymentLine(models.Model):
_name = 'paymentline.data'
# _inherit = 'orderline.data'
_description = "Payment Details"
price_id = fields.Many2one('orderline.data', )
total_price = fields.Integer(related='price_id.sub_total_price',string="Total Price")
advance_payment = fields.Integer(string="Advance payment")
total_due = fields.Float(string="Total Due")
create_paymentline = fields.Many2one('order.order', string="Payment Line") 发布于 2020-11-18 15:31:38
将total_price行更改为
total_price = fields.Float(string="Total Price", related="price_id.sub_total_price", store=True)store=True将该值保存到数据库,否则将实时获取该值。
https://stackoverflow.com/questions/64888508
复制相似问题