class model_A(models.Model): _name='module.model_a' sale_id = fields.Many2one(string='sale', comodel_name='sale.order') initial_price_value =??? class model_B(models.Model): _inherit = 'sale.order' model_id = fields.One2many(string='model_b', comodel_name='module.model_a', inverse_name='sale_id') initial_price = fields.Monetary(string="Price Initial", store=True, readonly=True, compute='_product_amount', tracking=4) amount_untaxed = fields.Monetary(string="Untaxed Amount", store=True, readonly=True, compute='_product_amount', tracking=5) amount_tax = fields.Monetary(string="Taxes", store=True, readonly=True, compute='_product_amount') @api.depends('order_line.price_total') def _product_amount(self): for order in self: amount_untaxed = amount_tax = 0.0 for line in order.order_line: amount_untaxed += line.price_subtotal amount_tax += line.price_tax order.update({ 'amount_untaxed': amount_untaxed, 'amount_tax': amount_tax, 'amount_total': amount_untaxed + amount_tax, 'initial_price': amount_untaxed + amount_tax, })
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
3
Trả lời
3942
Lượt xem
I got assertion errors: field initial_price_value with unknown currency field None ---- after I related it to sale_id
Are you asking:
How do you define a field initial_price_value on model_A so that it represents the value from initial_price on model_B ?
Review
https://www.odoo.com/documentation/13.0/reference/orm.html#related-fields
initial_price_value = fields.
Monetary(
related='sale_id.
initial_price
',store = True)
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
3
thg 1 24
|
15564 | ||
|
4
thg 2 25
|
2335 | ||
|
1
thg 8 24
|
1973 | ||
|
2
thg 11 24
|
3155 | ||
|
3
thg 10 23
|
14691 |
https://www.youtube.com/watch?v=pD6byjEvIx8