Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] purchase_currency #2508

Open
wants to merge 3 commits into
base: 16.0
Choose a base branch
from

Conversation

geomer198
Copy link

Set default currency for the company purchase orders and vendor bills.

@geomer198 geomer198 force-pushed the 16.0-t4226-purchase_currency-add branch 2 times, most recently from 2d45f77 to 75f9052 Compare January 7, 2025 19:57
@geomer198 geomer198 force-pushed the 16.0-t4226-purchase_currency-add branch from 422192e to 23a9399 Compare January 7, 2025 20:15
Comment on lines 10 to 19
@api.model
def default_get(self, fields_list):
result = super().default_get(fields_list)
# Check currency_id field exists
if "currency_id" not in fields_list:
return result
default_purchase_currency = self.env.company.default_purchase_currency_id
if default_purchase_currency:
result["currency_id"] = default_purchase_currency.id
return result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@api.model
def default_get(self, fields_list):
result = super().default_get(fields_list)
# Check currency_id field exists
if "currency_id" not in fields_list:
return result
default_purchase_currency = self.env.company.default_purchase_currency_id
if default_purchase_currency:
result["currency_id"] = default_purchase_currency.id
return result
currency_id = fields.Many2one(default=lambda self: self._default_currency_id())
def _default_currency_id(self):
company = self.env.company
return company.default_purchase_currency_id or company.currency_id

Copy link
Member

@GabbasovDinar GabbasovDinar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

{
"name": "Purchase Currency",
"version": "16.0.1.0.0",
"category": "Purchases",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"category": "Purchases",
"category": "Purchase",


def _purchase_service_prepare_order_values(self, supplierinfo):
result = super()._purchase_service_prepare_order_values(supplierinfo)
supplier_currency = supplierinfo.partner_id.property_purchase_currency_id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we explicit with_company(self.company_id) to be extra sure to get the currect currency? supplierinfo should already have the company context from previous _purchase_service_create, maybe we should doublecheck to make sure

@@ -0,0 +1,4 @@
Go to the Settings -> Purchase:

- Select a currency avaibale for the company in the "Default Purchase Currency" field

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Select a currency avaibale for the company in the "Default Purchase Currency" field
- Set "Default Purchase Currency" with an available currency

@@ -0,0 +1 @@
This module is useful when a company is operating in muli-currency environment and most of purchases are made in currency other that the main currency set in the company settings.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This module is useful when a company is operating in muli-currency environment and most of purchases are made in currency other that the main currency set in the company settings.
This module is useful when a company operates in a muli-currency environment and most of the purchases are made in a currency other than the main currency of the company.

@@ -0,0 +1 @@
Set default currency for the company purchase orders and vendor bills.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Set default currency for the company purchase orders and vendor bills.
Set default currency for the company purchase orders.

Would it just be purchase orders? Given that the currency carried itself to vendor bill, I don't think saying we are applying customization to both is valid.

Once module is configured, the default currency will be set:

1. As the default value for the "Currency" field in Requst For Quotation
2. As the default Journal Currency in Vendor Bill.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this valid?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants