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
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
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 ?
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
Aanmelden| Gerelateerde posts | Antwoorden | Weergaven | Activiteit | |
|---|---|---|---|---|
|  | 1 dec. 24  | 2579 | ||
|  | 2 okt. 25  | 4040 | ||
|  | 1 dec. 23  | 2313 | ||
|  | 1 mrt. 24  | 1475 | ||
|  | 1 jul. 23  | 3339 | 
