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
- Bogføring
- Lager
- PoS
- Project
- MRP
Dette spørgsmål er blevet anmeldt
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 ?
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Tilmeld digRelated Posts | Besvarelser | Visninger | Aktivitet | |
---|---|---|---|---|
|
1
dec. 24
|
2119 | ||
|
2
maj 24
|
3456 | ||
|
1
dec. 23
|
1958 | ||
|
1
mar. 24
|
1475 | ||
|
1
jul. 23
|
2782 |