Skip to content

Commit 29b730a

Browse files
[IMP] Implemented code to pass CI tests
1 parent 66bf67c commit 29b730a

File tree

4 files changed

+62
-58
lines changed

4 files changed

+62
-58
lines changed

ecommerce_first_last_name/controllers/main.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22

33
from odoo.addons.website_sale.controllers.main import WebsiteSale
4-
from odoo.tools.translate import _
54

65
_logger = logging.getLogger(__name__)
76

@@ -18,16 +17,10 @@ def _validate_address_values(
1817
**kwargs,
1918
):
2019
"""Raise validation save time"""
21-
invalid_fields, missing_fields, error_messages = super()._validate_address_values(
22-
address_values,
23-
partner_sudo,
24-
address_type,
25-
use_delivery_as_billing,
26-
required_fields,
27-
is_main_address,
28-
**kwargs
20+
invalid_fields, missing_fields, error_messages = (
21+
super()._validate_address_values(address_values, partner_sudo, address_type, use_delivery_as_billing, required_fields, is_main_address, **kwargs)
2922
)
30-
# Change first or last name
23+
# Change first or last name
3124
if partner_sudo and not partner_sudo._can_edit_name():
3225
full_name = partner_sudo.name or ""
3326
old_first, old_last = (full_name.split(" ", 1) + [""])[:2]
@@ -48,7 +41,7 @@ def _validate_address_values(
4841
invalid_fields.add("name")
4942
# Case 3: only last name changed
5043
elif last_name_changed and not first_name_changed:
51-
invalid_fields.discard("name")
44+
invalid_fields.discard("name")
5245
invalid_fields.add("last_name")
5346

5447
return invalid_fields, missing_fields, error_messages

ecommerce_first_last_name/static/src/js/website_sale.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ websiteSaleAddress.include({
3636
companyInput.required = isCompany;
3737
if (!isCompany) {
3838
companyInput.required = false;
39-
// companyInput.value = ""; // clear if switching back to individual
4039
}
4140
}
4241
},

ecommerce_first_last_name/views/templates.xml

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<!-- /shop/address route -->
44
<template id="address_inherit" inherit_id="website_sale.address" priority="110">
55
<!-- Hide the B2B section (VAT, Company, etc.) -->
6-
<xpath expr="//t[@t-if='website._display_partner_b2b_fields()']" position="replace"/>
6+
<xpath
7+
expr="//t[@t-if='website._display_partner_b2b_fields()']"
8+
position="replace"
9+
/>
710
<!-- Show the type wise fields -->
811
<xpath
912
expr="//form[hasclass('checkout_autoformat')]/div/div[1]"
@@ -65,50 +68,56 @@
6568
</div>
6669
<!-- Company Section -->
6770
<!-- <t t-if="website._display_partner_b2b_fields()"> -->
68-
<div class="w-100"/>
69-
<!-- <t t-if="show_vat"> -->
70-
<t t-set="vat_warning" t-value="partner_sudo.vat and not can_edit_vat"/>
71-
<div id="company_name_div" class="col-lg-6 mb-2 d-none">
72-
<label
73-
class="col-form-label fw-normal label-optional"
74-
for="o_company_name"
75-
>
76-
Company Name
77-
</label>
78-
<input
79-
id="o_company_name"
80-
type="text"
81-
name="company_name"
82-
t-att-value="partner_sudo.commercial_company_name"
83-
t-att-readonly="'1' if vat_warning else None"
84-
class="form-control"
85-
/>
86-
<small t-if="vat_warning" class="form-text text-muted d-block d-lg-none">
87-
Changing company name is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.
88-
</small>
89-
</div>
90-
<div id="div_vat" class="col-lg-6 mb-2 d-none">
91-
<label class="col-form-label fw-normal label-optional" for="o_vat">
92-
TIN / VAT
93-
</label>
94-
<input
95-
type="text"
96-
id="o_vat"
97-
name="vat"
98-
t-att-value="partner_sudo.vat"
99-
t-att-readonly="'1' if vat_warning else None"
100-
class="form-control"
101-
/>
102-
<small t-if="vat_warning" class="form-text text-muted d-block d-lg-none">
103-
Changing VAT number is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.
104-
</small>
105-
</div>
106-
<div t-if="vat_warning" class="col-12 d-none d-lg-block mb-1">
107-
<small class="form-text text-muted">
108-
Changing company name or VAT number is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.
109-
</small>
110-
</div>
111-
<!-- </t> -->
71+
<div class="w-100" />
72+
<!-- <t t-if="show_vat"> -->
73+
<t t-set="vat_warning" t-value="partner_sudo.vat and not can_edit_vat" />
74+
<div id="company_name_div" class="col-lg-6 mb-2 d-none">
75+
<label
76+
class="col-form-label fw-normal label-optional"
77+
for="o_company_name"
78+
>
79+
Company Name
80+
</label>
81+
<input
82+
id="o_company_name"
83+
type="text"
84+
name="company_name"
85+
t-att-value="partner_sudo.commercial_company_name"
86+
t-att-readonly="'1' if vat_warning else None"
87+
class="form-control"
88+
/>
89+
<small
90+
t-if="vat_warning"
91+
class="form-text text-muted d-block d-lg-none"
92+
>
93+
Changing company name is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.
94+
</small>
95+
</div>
96+
<div id="div_vat" class="col-lg-6 mb-2 d-none">
97+
<label class="col-form-label fw-normal label-optional" for="o_vat">
98+
TIN / VAT
99+
</label>
100+
<input
101+
type="text"
102+
id="o_vat"
103+
name="vat"
104+
t-att-value="partner_sudo.vat"
105+
t-att-readonly="'1' if vat_warning else None"
106+
class="form-control"
107+
/>
108+
<small
109+
t-if="vat_warning"
110+
class="form-text text-muted d-block d-lg-none"
111+
>
112+
Changing VAT number is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.
113+
</small>
114+
</div>
115+
<div t-if="vat_warning" class="col-12 d-none d-lg-block mb-1">
116+
<small class="form-text text-muted">
117+
Changing company name or VAT number is not allowed once document(s) have been issued for your account. Please contact us directly for this operation.
118+
</small>
119+
</div>
120+
<!-- </t> -->
112121
<!-- </t> -->
113122
</xpath>
114123
</template>

payment_bitcoin/controllers/portal.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ def portal_order_page(
2727
**kw,
2828
)
2929
order = request.env["sale.order"].sudo().browse(order_id)
30-
last_transaction = order.transaction_ids[-1]
30+
if order and order.transaction_ids:
31+
last_transaction = order.transaction_ids[-1]
32+
else:
33+
return res
3134
if last_transaction and last_transaction.provider_code == "bitcoin":
3235
lang_code = (
3336
request.env.context.get("lang") or order.partner_id.lang or "en_US"

0 commit comments

Comments
 (0)