首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在odoo-13中让一个模型的字段值自动出现在另一个模型的字段中?

如何在odoo-13中让一个模型的字段值自动出现在另一个模型的字段中?
EN

Stack Overflow用户
提问于 2020-11-18 15:05:18
回答 1查看 66关注 0票数 0

我需要sub_total_price字段的值将自动在total_price字段。假设sub_total_price = 300,则total_price = 300自动

代码语言:javascript
复制
 *** 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") 
EN

回答 1

Stack Overflow用户

发布于 2020-11-18 15:31:38

将total_price行更改为

代码语言:javascript
复制
total_price = fields.Float(string="Total Price", related="price_id.sub_total_price", store=True)

store=True将该值保存到数据库,否则将实时获取该值。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64888508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档