Skip to content

Commit

Permalink
[IMP] stock_picking_accounting_date: Get currency rate based on accou…
Browse files Browse the repository at this point in the history
…nting date
  • Loading branch information
AungKoKoLin1997 committed Jul 11, 2024
1 parent e6f3c42 commit 5200bd1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions stock_picking_accounting_date/models/stock_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,27 @@ def _prepare_account_move_vals(
if self.accounting_date:
am_vals.update({"date": self.accounting_date})
return am_vals

def _get_price_unit(self):
"""Set date for convert price unit multi currency."""
self.ensure_one()
price_unit = super()._get_price_unit()
if (
hasattr(self, "purchase_line_id")
and self.accounting_date
and not self.origin_returned_move_id
and self.purchase_line_id
and self.product_id.id == self.purchase_line_id.product_id.id
):
line = self.purchase_line_id
order = line.order_id
price_unit = line.price_unit
if order.currency_id != order.company_id.currency_id:
price_unit = order.currency_id._convert(
price_unit,
order.company_id.currency_id,
order.company_id,
self.accounting_date,
round=False,
)
return price_unit

0 comments on commit 5200bd1

Please sign in to comment.