Skip to content

Commit

Permalink
[FIX] purchase_stock_ux: price_unit rounding in stock move
Browse files Browse the repository at this point in the history
  • Loading branch information
mav-adhoc committed Aug 14, 2024
1 parent f2347d0 commit a7611b2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion purchase_stock_ux/models/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# directory
##############################################################################
from odoo import models, fields, api, _
from odoo.tools.float_utils import float_compare
from odoo.tools.float_utils import float_compare, float_round
from odoo.exceptions import UserError


Expand Down Expand Up @@ -97,3 +97,22 @@ def _prepare_picking(self):
res = super(PurchaseOrder, self)._prepare_picking()
res['note'] = self.internal_notes
return res

def _get_stock_move_price_unit(self):
self.ensure_one()
order = self.order_id
price_unit = super(PurchaseOrder, self)._get_stock_move_price_unit()
price_unit = self.price_unit
price_unit_prec = self.env['decimal.precision'].precision_get('Product Price')
if self.taxes_id:
qty = self.product_qty or 1
price_unit = self.taxes_id.with_context(round=False, round_base=False).compute_all(
price_unit, currency=self.order_id.currency_id, quantity=qty, product=self.product_id, partner=self.order_id.partner_id
)['total_void']
price_unit = price_unit / qty
if self.product_uom.id != self.product_id.uom_id.id:
price_unit *= self.product_uom.factor / self.product_id.uom_id.factor
if order.currency_id != order.company_id.currency_id:
price_unit = order.currency_id._convert(
price_unit, order.company_id.currency_id, self.company_id, self.date_order or fields.Date.today(), round=False)
return float_round(price_unit, precision_digits=price_unit_prec)

0 comments on commit a7611b2

Please sign in to comment.