Skip to content

Commit 196b7e1

Browse files
[MIG] purchase_manual_currency: Migration to 17.0
1 parent ca66d13 commit 196b7e1

File tree

5 files changed

+32
-47
lines changed

5 files changed

+32
-47
lines changed

purchase_manual_currency/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
{
55
"name": "Purchase - Manual Currency",
6-
"version": "15.0.1.0.0",
6+
"version": "17.0.1.0.0",
77
"category": "Purchase Management",
88
"summary": "Allows to manual currency of Purchase",
99
"author": "Ecosoft, Odoo Community Association (OCA)",

purchase_manual_currency/models/purchase.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,15 @@
1010
class PurchaseOrder(models.Model):
1111
_inherit = "purchase.order"
1212

13-
manual_currency = fields.Boolean(
14-
readonly=True,
15-
states={"draft": [("readonly", False)]},
16-
)
13+
manual_currency = fields.Boolean()
1714
is_manual = fields.Boolean(compute="_compute_currency")
1815
type_currency = fields.Selection(
1916
selection=lambda self: self._get_label_currency_name(),
2017
default=lambda self: self._get_label_currency_name()[0][0],
21-
readonly=True,
22-
states={"draft": [("readonly", False)]},
2318
)
2419
manual_currency_rate = fields.Float(
2520
digits="Manual Currency",
2621
tracking=True,
27-
readonly=True,
28-
states={"draft": [("readonly", False)]},
2922
help="Set new currency rate to apply on the invoice\n."
3023
"This rate will be taken in order to convert amounts between the "
3124
"currency on the purchase order and last currency",
@@ -118,13 +111,9 @@ def action_refresh_currency(self):
118111
return True
119112

120113
@api.model
121-
def _fields_view_get(
122-
self, view_id=None, view_type="form", toolbar=False, submenu=False
123-
):
114+
def get_view(self, view_id=None, view_type="form", **options):
124115
"""Change string name to company currency"""
125-
result = super()._fields_view_get(
126-
view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu
127-
)
116+
result = super().get_view(view_id=view_id, view_type=view_type, options=options)
128117
if view_type == "form":
129118
company_currency_name = (
130119
self.env["res.company"].browse(self._context.get("company_id"))

purchase_manual_currency/tests/test_purchase_manual_currency.py

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ def test_01_purchase_manual_currency(self):
2828
self.purchase_order.order_line[0].subtotal_company_currency,
2929
)
3030
self.assertFalse(self.purchase_order.currency_diff)
31+
32+
# Activate Multi Currency Group
33+
multi_currency_group = self.env.ref("base.group_multi_currency")
34+
self.env.user.groups_id |= multi_currency_group
35+
3136
# Change currency
3237
self.assertEqual(self.purchase_order.manual_currency_rate, 0.0)
3338
with Form(self.purchase_order) as p:

purchase_manual_currency/views/purchase_views.xml

+13-18
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,27 @@
1010
<label
1111
for="manual_currency"
1212
groups="base.group_multi_currency"
13-
attrs="{'invisible': [('is_manual', '=', False)]}"
13+
invisible="not is_manual"
1414
/>
15-
<div
16-
groups="base.group_multi_currency"
17-
attrs="{'invisible': [('is_manual', '=', False)]}"
18-
>
19-
<field name="manual_currency" />
15+
<div groups="base.group_multi_currency" invisible="not is_manual">
16+
<field name="manual_currency" readonly="state != 'draft'" />
2017
<label for="manual_currency_rate" invisible='1' />
21-
<div
22-
class="o_row"
23-
attrs="{'invisible': [('manual_currency', '=', False)]}"
24-
>
25-
<field name="manual_currency_rate" />
18+
<div class="o_row" invisible="not manual_currency">
19+
<field
20+
name="manual_currency_rate"
21+
readonly="state != 'draft'"
22+
/>
2623
<field
2724
name="type_currency"
28-
attrs="{'required': [('manual_currency', '=', True)]}"
25+
required="manual_currency"
26+
readonly="state != 'draft'"
2927
/>
3028
<button
3129
aria-label="Opened"
3230
type="object"
3331
name="action_refresh_currency"
3432
class="btn-link"
35-
states="draft"
33+
invisible="state != 'draft'"
3634
>
3735
<i title="Update Currency" class="fa fa-fw fa-refresh" />
3836
</button>
@@ -46,11 +44,8 @@
4644
<field name="subtotal_company_currency" />
4745
<field name="company_currency_id" invisible="1" />
4846
</xpath>
49-
<xpath expr="//field[@name='tax_totals_json']" position="before">
50-
<field
51-
name="total_company_currency"
52-
attrs="{'invisible': [('currency_diff', '=', False)]}"
53-
/>
47+
<xpath expr="//field[@name='tax_totals']" position="before">
48+
<field name="total_company_currency" invisible="not currency_diff" />
5449
<field name="company_currency_id" invisible="1" />
5550
<field name="currency_diff" invisible="1" />
5651
</xpath>

purchase_manual_currency/views/res_config_settings_views.xml

+10-14
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,18 @@
88
ref="purchase.res_config_settings_view_form_purchase"
99
/>
1010
<field name="arch" type="xml">
11-
<xpath expr="//div[@name='invoicing_settings_container']" position="inside">
11+
<xpath
12+
expr="//block[@name='invoicing_settings_container']"
13+
position="inside"
14+
>
1215
<div class="col-xs-12 col-md-6 o_setting_box">
13-
<div class="o_setting_left_pane" />
14-
<div class="o_setting_right_pane">
15-
<label
16-
for="manual_currency_po_inv"
17-
string="Bill Manual Currency"
18-
/>
19-
<div class="text-muted">
16+
<setting title="Bill Manual Currency" id="bill_manual_currency">
2017
<field
21-
name="manual_currency_po_inv"
22-
class="o_light_label mt16"
23-
widget="radio"
24-
/>
25-
</div>
26-
</div>
18+
name="manual_currency_po_inv"
19+
class="o_light_label mt16"
20+
widget="radio"
21+
/>
22+
</setting>
2723
</div>
2824
</xpath>
2925
</field>

0 commit comments

Comments
 (0)