|
3 | 3 | # directory
|
4 | 4 | ##############################################################################
|
5 | 5 | 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 |
7 | 7 | from odoo.exceptions import UserError
|
8 | 8 |
|
9 | 9 |
|
@@ -97,3 +97,22 @@ def _prepare_picking(self):
|
97 | 97 | res = super(PurchaseOrder, self)._prepare_picking()
|
98 | 98 | res['note'] = self.internal_notes
|
99 | 99 | 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