Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
95 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
oct 25
827
3
oct 25
2580
4
oct 25
906
1
sept 25
704
1
jul 25
2053