i want to show total of discounts in my total fields in invoices and quotations/sales order. can i activate it in odoo ? if not how can i compute it in a new field to take float of percentage and shows monetary?
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ờ
Hi,
In python:
The compute method will work when you save the form.
class SaleOrderLine(models.Model):
_inherit= 'sale.order.line'
discount_amount = fields.Float(string="Discount Amount", help="To get the discounted amount",compute='compute_discount_amount')
company_currency = fields.Many2one("res.currency", string='Currency',
related='company_id.currency_id', readonly=True,
tracking=True)
def compute_discount_amount(self):
for rec in self:
if rec.discount:
amount = rec.product_uom_qty * rec.price_unit
rec.discount_amount = (amount*rec.discount)/100
XML:
<record model="ir.ui.view" id="sale_order_view_inherit">
<field name="name">sale.order.view.
<field name="model">sale.order</
<field name="arch" type="xml">
<xpath expr="/form/sheet/notebook/
<field name="discount_amount" widget="monetary" options="{'currency_field': 'company_currency'}"/>
<field name="company_currency" invisible="1"/>
</xpath>
</field>
</record>
Regards
sorry to trouble you again would you please guide me on where exactly should i enter the python code and xml ? python in the init.py or manifest.py or any where else and xml where should i try it ?
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 | |
---|---|---|---|---|
|
1
thg 12 24
|
2132 | ||
|
2
thg 5 24
|
3496 | ||
|
1
thg 12 23
|
1968 | ||
|
1
thg 3 24
|
1475 | ||
|
1
thg 7 23
|
2791 |