good morning, by calculations I need to have 2 additional columns in the detail of the invoice. unit_price2 and price_subtotal2 where: unit_price2 = product price * 20 price_subtotal2 = unit_price2 * quantity my code works well before recording, or save the document in draft. There seems to be a method that overwrites it. probe with the following codes but I get different errors. please your support. code 1: class AccountInvoiceLine (models.Model): _inherit = "account.invoice.line" price_unit2 = fields.Float ("Unit Price", readonly = False) @ api.one @ api.onchange ('product_id') def price_prod (self): self.price_unit2 = self.product_id.lst_price * 20 This code works, but when I create or save the document the price is changed with the current value of the product. probe with overwrite the method "product_id_change" @ api.one @ api.onchange ('product_id') def product_id_change (self): res = super (AccountInvoiceLine, self) .product_id_change (self) for line in self: line.price_unit2 = self.product_id.lst_price return res error: method_res = method (self) File "/mnt/extra-addons/models/account/account_invoice_line.py", line 31, in product_id_change res = super (AccountInvoiceLine, self) .product_id_change () AttributeError: 'super' object has no attribute 'product_id_change'
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ờ
1
Trả lời
5369
Lượt xem
Hello ,
Try to replace the "product_id_change" function with "_onchange_product_id"
Check here Code
Then you can add super like this
res = super (AccountInvoiceLine, self) ._onchange_product_id(self)
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 | |
---|---|---|---|---|
|
2
thg 8 25
|
2769 | ||
|
1
thg 7 25
|
1120 | ||
|
1
thg 8 25
|
1152 | ||
|
0
thg 5 25
|
1535 | ||
|
2
thg 4 25
|
3737 |