Skip to Content
Menu
This question has been flagged
2 Replies
73 Views

In order to pay vendors their exact bill amount, my user is struggling with entering in an exact unit price as it sometimes calculates an inaccurate extended amount (ie. off by a penny due to rounding).  Can I allow for entry of the extend amount and the system just back fills in the unit price?  When you have decimal quantities, entering extended amounts rather than unit prices seems much easier.  Thanks.

Avatar
Discard
Best Answer

Hi,


To allow users to enter the extended amount on vendor bill lines in Odoo and have the system back-calculate the unit price, you need to customize the account.move.line model and its form view. Create a custom module that depends on the account module. Add an extended_amount field to the account.move.line model and override the onchange method to calculate the price_unit based on the extended_amount and quantity.


In the module's view file, inherit the account.view_move_line_form view and add the extended_amount field before the price_unit field. Be mindful of rounding issues and consider disabling the price_unit field for clarity. Also, add a recompute rule to the price_subtotal field to ensure it is correctly calculated after the price_unit is updated. Install the module to apply the changes.


Python


from odoo import models, fields, api


class AccountMoveLine(models.Model):

    _inherit = 'account.move.line'


    extended_amount = fields.Monetary(string="Extended Amount", currency_field='currency_id')


    @api.onchange('extended_amount', 'quantity')

    def _onchange_extended_amount(self):

        if self.quantity and self.extended_amount:

            self.price_unit = self.extended_amount / self.quantity

        else:

            self.price_unit = 0.0



Hope it helps

Avatar
Discard
Best Answer

You can probably achieve the same level of control by using the Accounting Firms mode.

See https://www.odoo.com/documentation/19.0/applications/finance/accounting.html#fiduciaries

Avatar
Discard
Related Posts Replies Views Activity
2
Oct 25
824
3
Oct 25
2567
4
Oct 25
902
1
Sep 25
702
1
Jul 25
2052