Skip to content

Commit a7611b2

Browse files
committed
[FIX] purchase_stock_ux: price_unit rounding in stock move
1 parent f2347d0 commit a7611b2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

purchase_stock_ux/models/purchase_order.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# directory
44
##############################################################################
55
from odoo import models, fields, api, _
6-
from odoo.tools.float_utils import float_compare
6+
from odoo.tools.float_utils import float_compare, float_round
77
from odoo.exceptions import UserError
88

99

@@ -97,3 +97,22 @@ def _prepare_picking(self):
9797
res = super(PurchaseOrder, self)._prepare_picking()
9898
res['note'] = self.internal_notes
9999
return res
100+
101+
def _get_stock_move_price_unit(self):
102+
self.ensure_one()
103+
order = self.order_id
104+
price_unit = super(PurchaseOrder, self)._get_stock_move_price_unit()
105+
price_unit = self.price_unit
106+
price_unit_prec = self.env['decimal.precision'].precision_get('Product Price')
107+
if self.taxes_id:
108+
qty = self.product_qty or 1
109+
price_unit = self.taxes_id.with_context(round=False, round_base=False).compute_all(
110+
price_unit, currency=self.order_id.currency_id, quantity=qty, product=self.product_id, partner=self.order_id.partner_id
111+
)['total_void']
112+
price_unit = price_unit / qty
113+
if self.product_uom.id != self.product_id.uom_id.id:
114+
price_unit *= self.product_uom.factor / self.product_id.uom_id.factor
115+
if order.currency_id != order.company_id.currency_id:
116+
price_unit = order.currency_id._convert(
117+
price_unit, order.company_id.currency_id, self.company_id, self.date_order or fields.Date.today(), round=False)
118+
return float_round(price_unit, precision_digits=price_unit_prec)

0 commit comments

Comments
 (0)