Skip to content

Commit

Permalink
Merge PR #2399 into 15.0
Browse files Browse the repository at this point in the history
Signed-off-by HviorForgeFlow
  • Loading branch information
OCA-git-bot committed Sep 3, 2024
2 parents eaafe84 + 49af243 commit 0a773e1
Show file tree
Hide file tree
Showing 12 changed files with 737 additions and 0 deletions.
78 changes: 78 additions & 0 deletions purchase_stock_manual_currency/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
==============================
Purchase Stock Manual Currency
==============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:fe95182a164ac1b1eba2e5f70221421995ea14531c420a67e465d56590668837
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/15.0/purchase_stock_manual_currency
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-15-0/purchase-workflow-15-0-purchase_stock_manual_currency
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module integrates `purchase_manual_currency` with purchase stock
management, ensuring that manually set currency rates on purchase orders are
applied to stock moves, stock valuation layers, and product costs.

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20purchase_stock_manual_currency%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* ForgeFlow

Contributors
~~~~~~~~~~~~

* Laura Cazorla <[email protected]>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/15.0/purchase_stock_manual_currency>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions purchase_stock_manual_currency/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)

from . import models
15 changes: 15 additions & 0 deletions purchase_stock_manual_currency/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)

{
"name": "Purchase Stock Manual Currency",
"version": "15.0.1.0.0",
"category": "Purchase Management",
"summary": "Extends manual currency from purchase to stock moves",
"author": "ForgeFlow, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/purchase-workflow",
"license": "AGPL-3",
"depends": ["purchase_stock", "purchase_manual_currency"],
"data": [],
"installable": True,
}
4 changes: 4 additions & 0 deletions purchase_stock_manual_currency/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)

from . import stock_move
32 changes: 32 additions & 0 deletions purchase_stock_manual_currency/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 ForgeFlow, S.L.
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0)

from odoo import fields, models


class StockMove(models.Model):
_inherit = "stock.move"

def _get_price_unit(self):
# If the purchase order is in manual currency, we need to convert the
# price unit to the company currency by using the manual rate, instead
# of the default rate.
self.ensure_one()
price_company_curr = super(StockMove, self)._get_price_unit()
p_order = self.purchase_line_id.order_id
if p_order and p_order.manual_currency:
company_curr = p_order.company_id.currency_id
po_curr = p_order.currency_id
date = fields.Date.context_today(self)
# Convert the price back to the PO's currency
price_po_curr = company_curr._convert(
price_company_curr, po_curr, p_order.company_id, date, round=False
)
# Convert the price to the company currency, using the manual rate
rate = (
p_order.manual_currency_rate
if p_order.type_currency == "inverse_company_rate"
else (1.0 / p_order.manual_currency_rate)
)
price_company_curr = price_po_curr * rate
return price_company_curr
1 change: 1 addition & 0 deletions purchase_stock_manual_currency/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Laura Cazorla <[email protected]>
3 changes: 3 additions & 0 deletions purchase_stock_manual_currency/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This module integrates `purchase_manual_currency` with purchase stock
management, ensuring that manually set currency rates on purchase orders are
applied to stock moves, stock valuation layers, and product costs.
Loading

0 comments on commit 0a773e1

Please sign in to comment.