[FIX] purchase: default currency from context

closes odoo/odoo#116238

X-original-commit: ba6f90c2d664b7cef7f7ecd619b763ad6fe2138b
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
This commit is contained in:
Saran440
2023-03-23 12:14:51 +01:00
committed by William Henrotin
parent 78b7e9cca9
commit afcf0fba8d
2 changed files with 6 additions and 2 deletions
+3 -2
View File
@@ -286,13 +286,14 @@ class PurchaseOrder(models.Model):
# are taken with the company of the order
# if not defined, with_company doesn't change anything.
self = self.with_company(self.company_id)
default_currency = self._context.get("default_currency_id")
if not self.partner_id:
self.fiscal_position_id = False
self.currency_id = self.env.company.currency_id.id
self.currency_id = default_currency or self.env.company.currency_id.id
else:
self.fiscal_position_id = self.env['account.fiscal.position']._get_fiscal_position(self.partner_id)
self.payment_term_id = self.partner_id.property_supplier_payment_term_id.id
self.currency_id = self.partner_id.property_purchase_currency_id.id or self.env.company.currency_id.id
self.currency_id = default_currency or self.partner_id.property_purchase_currency_id.id or self.env.company.currency_id.id
return {}
@api.onchange('fiscal_position_id', 'company_id')
@@ -103,12 +103,15 @@
<field name="arch" type="xml">
<form string="Purchase Agreements">
<field name="company_id" invisible="1"/>
<field name="currency_id" invisible="1"/>
<header>
<button name="%(action_purchase_requisition_to_so)d" type="action"
string="New Quotation"
context="{'default_currency_id': currency_id}"
attrs="{'invisible': [('state', '!=', 'open')]}"/>
<button name="%(action_purchase_requisition_to_so)d" type="action"
string="New Quotation" class="btn-primary"
context="{'default_currency_id': currency_id}"
attrs="{'invisible': [('state', 'not in', ('in_progress', 'ongoing'))]}"/>
<button name="action_in_progress" states="draft" string="Confirm" type="object" class="btn-primary"/>
<button name="action_open" states="in_progress" string="Validate" type="object" class="btn-primary"/>