-
-
Notifications
You must be signed in to change notification settings - Fork 815
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
base: 16.0
Are you sure you want to change the base?
Conversation
422192e
to
23a9399
Compare
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
purchase_currency/__manifest__.py
Outdated
{ | ||
"name": "Purchase Currency", | ||
"version": "16.0.1.0.0", | ||
"category": "Purchases", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_purchase_service_create
The current company is taken from the sale.order.line record. I think is correct situation.
@@ -0,0 +1,4 @@ | |||
Go to the Settings -> Purchase: | |||
|
|||
- Select a currency avaibale for the company in the "Default Purchase Currency" field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Select a currency avaibale for the company in the "Default Purchase Currency" field | |
- Set "Default Purchase Currency" with an available currency |
purchase_currency/readme/CONTEXT.rst
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
purchase_currency/readme/USAGE.rst
Outdated
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this valid?
Yes this is valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality LGTM
775aa42
to
3643a60
Compare
@geomer198 can you fix the test? |
3643a60
to
2d7aabe
Compare
@HviorForgeFlow There are rebel modules in the repository, so it runs two pairs of tests. The current module is not compatible with these modules, so only one pair of tests failed. |
2d7aabe
to
7d994a8
Compare
Set default currency for the company purchase orders and vendor bills.