Skip to content

Conversation

@eduezerouali-tecnativa
Copy link
Contributor

@eduezerouali-tecnativa eduezerouali-tecnativa commented Oct 22, 2025

cc @Tecnativa TT58475
ping @pilarvargas-tecnativa @carlos-lopez-tecnativa

Migrated from #1047

Supersedes #1047

eLBati and others added 17 commits October 22, 2025 13:22
ADD website_sale_charge_payment_fee_delivery: link module

ADD website_sale_charge_payment_fee_quote: link module
…o acquirer

If there are no acquirers, gets
```
Error to render compiling AST
TypeError: 'NoneType' object has no attribute '__getitem__'
Template: 929
Path: /templates/t/t/div/div[1]/div/div[2]/input
Node: <input type="hidden" t-att-value="selected_acquirer.id if selected_acquirer else acquirers[0].id" name="selected_acquirer_id" data-oe-id="1278" data-oe-xpath="/data/xpath[3]/input" data-oe-model="ir.ui.view" data-oe-field="arch"/>
```
We avoid this way the warning on runbot and it's more tolerant to
inheritance.
Currently translated at 100.0% (21 of 21 strings)

Translation: e-commerce-14.0/e-commerce-14.0-website_sale_charge_payment_fee
Translate-URL: https://translation.odoo-community.org/projects/e-commerce-14-0/e-commerce-14-0-website_sale_charge_payment_fee/es/
with RecordCapturer(self.env["sale.order"], []) as capture:
self.start_tour("/shop", "payment_fee_tour", login="portal", step_delay=100)
created_order = capture.records
price = 10 / 100 * 99.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this value change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does not change the value, actually is calculate the expected value of created_order.amount_payment_fee. That's why next step it and assetEqual.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, why does the calculation change? Before, it was done with price = 10 / 100 * 49.5

Copy link
Contributor Author

@eduezerouali-tecnativa eduezerouali-tecnativa Oct 29, 2025

Choose a reason for hiding this comment

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

Selección_001 Selección_002

change demo price form 14.0 to 18.0
16.5 * 3 = 49.5 and 33 * 3 = 99

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you avoid depending on demo data to prevent external changes from altering the behavior here?

Comment on lines 22 to 27
res = super()._compute_website_order_line()
website_order_line = self.env["sale.order.line"]
for order in self:
for line in order.website_order_line:
if not line.payment_fee_line:
website_order_line |= line
order.website_order_line = website_order_line
return res
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change this code? I think the older code is clearer and more compact.

"is_published": True,
}
)
transfer_provider._compute_charge_fee_description()
Copy link
Contributor

Choose a reason for hiding this comment

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

You don’t need the _compute_charge_fee_description function; it should be called automatically.

Comment on lines 39 to 50
amount_payment_fee = 0.0
if (
self.env["website"]
.get_current_website()
.show_line_subtotals_tax_selection
== "tax_excluded"
):
for line in order.order_line:
if line.payment_fee_line:
amount_payment_fee += line.price_subtotal
else:
for line in order.order_line:
if line.payment_fee_line:
amount_payment_fee += line.price_total
Copy link
Contributor

Choose a reason for hiding this comment

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

The same here: Why change this code? I think the older code is clearer and more compact.

Comment on lines +26 to +31
browser.location.href =
"/shop/payment?provider_id=" +
providerId +
"&payment_option_id=" +
paymentOptionId;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I see that this redirect reloads the page, and I get this message when switching between different payment providers. Is this correct? I can’t continue from this step.
image

Copy link
Contributor

Choose a reason for hiding this comment

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

I attached a video. I believe the problem occurs when you have two or more payment providers. In this case, I installed Demo and Wire Transfer and selected the second payment option. The window flickers, and internally the sale order changes when another payment method is selected. So, I think the window is not being refreshed correctly.

website_sale_charge_payment_fee.mp4

Choose a reason for hiding this comment

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

@carlos-lopez-tecnativa @eduezerouali-tecnativa we added this function in the migration to resolve the problem, could you add and test, thanks:
_prepareTransactionRouteParams() {
const transactionRouteParams = this._super(...arguments);
// eslint-disable-next-line no-undef
const cartValueEl = document.querySelector(".oe_currency_value");
const cartValue = cartValueEl?.textContent || "0";
transactionRouteParams.amount = Number(cartValue);
return transactionRouteParams;
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Alexgars73 That problem was already solve or you are talking about express checkout?

Choose a reason for hiding this comment

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

@eduezerouali-tecnativa i'm getting the same error that @carlos-lopez-tecnativa mentioned "The cart has been updated. Please refresh the page".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Alexgars73 try on runboat, it is working fine.
Selección_012
Selección_013

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 18.0-mig-website_sale_charge_payment_fee branch 3 times, most recently from e9cb772 to 1d1663f Compare October 29, 2025 16:51
@eduezerouali-tecnativa
Copy link
Contributor Author

@carlos-lopez-tecnativa thanks for your review! changes you requested done. Couldn't replicate what your error. Could you give more details about that?

order.amount_payment_fee = sum(
order.order_line.filtered("payment_fee_line").mapped("price_total")
order.order_line.filtered("payment_fee_line").mapped(
"price_subtotal"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why price_subtotal??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be price_total

charge_fee_description = fields.Text(
"Fee Description", compute="_compute_charge_fee_description"
)
charge_fee_product_id = fields.Many2one("product.product", string="Fee Product")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this product should have a domain that allows selecting only records of type service. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with you. Makes sense, as I can't see a possible scenario where that fee could be a good

Comment on lines +26 to +31
browser.location.href =
"/shop/payment?provider_id=" +
providerId +
"&payment_option_id=" +
paymentOptionId;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I attached a video. I believe the problem occurs when you have two or more payment providers. In this case, I installed Demo and Wire Transfer and selected the second payment option. The window flickers, and internally the sale order changes when another payment method is selected. So, I think the window is not being refreshed correctly.

website_sale_charge_payment_fee.mp4

Copy link
Contributor

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Choose a reason for hiding this comment

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

Working fine, just a doubt about the class change. I just want to understand the change. Other than that, LGTM.

with RecordCapturer(self.env["sale.order"], []) as capture:
self.start_tour("/shop", "payment_fee_tour", login="portal", step_delay=100)
created_order = capture.records
price = 10 / 100 * 99.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you avoid depending on demo data to prevent external changes from altering the behavior here?

@http.route(
"/shop/payment", type="http", auth="public", website=True, sitemap=False
)
def shop_payment(self, **post):
Copy link
Contributor

Choose a reason for hiding this comment

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

This class PaymentPortal, doesn’t have the shop_payment function in the payment module. This method is added in the website_sale module. Why did you change the class to inherit from it instead of inheriting from the WebsiteSale class?

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 18.0-mig-website_sale_charge_payment_fee branch from b1edf83 to b9e382d Compare November 4, 2025 10:57
@eduezerouali-tecnativa
Copy link
Contributor Author

@carlos-lopez-tecnativa Changes done, no it does not depends on demo data for test.

@Reyes4711-S73
Copy link

@eduezerouali-tecnativa I tested and it is not working well when you try to pay directly with X payment.
image
If you press the button pay with demo, it doesn't apply the fee charge.
image
Otherwise, if you continue with the checkout and you fill all the billing addres and shipping address, the fee is charged.
image
image

<field name="inherit_id" ref="payment.payment_provider_form" />
<field name="arch" type="xml">
<xpath expr="//notebook" position="inside">
<page string="Charge payment fee">
Copy link
Contributor

Choose a reason for hiding this comment

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

@eduezerouali-tecnativa I tested and it is not working well when you try to pay directly with X payment. image

@Reyes4711-S73 The case you mean is when the payment provider supports express checkout, but in this case, it’s out of scope for this module.
@eduezerouali-tecnativa You can add it to the ROADMAP and hide the page in this case.
I don’t know which payment providers support express checkout apart from Demo, which is never used in the real world.

image image
Suggested change
<page string="Charge payment fee">
<page string="Charge payment fee" invisible="allow_express_checkout">

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implemented your suggestions, anyways i think that stripe used it too. Also add it to roadmap. Thanks :)

)
cls.product_product_optional = cls.env["product.template"].create(
{
"name": "Oprional",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"name": "Oprional",
"name": "Optional",

"is_published": True,
"sale_ok": True,
"taxes_id": [Command.clear()],
"optional_product_ids": [Command.set(cls.product_product_optional.ids)],
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the optional product really necessary? Why?

Copy link
Contributor Author

@eduezerouali-tecnativa eduezerouali-tecnativa Nov 5, 2025

Choose a reason for hiding this comment

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

not really necessary, i did that,just to not adjust the tour. Anyways i did adjust the tour. :)

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 18.0-mig-website_sale_charge_payment_fee branch from d20d908 to 9c7ddf1 Compare November 5, 2025 14:04
Copy link
Contributor

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Choose a reason for hiding this comment

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

LGTM

@pedrobaeza
Copy link
Member

/ocabot migration website_sale_charge_payment_fee

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone Nov 5, 2025
@OCA-git-bot OCA-git-bot mentioned this pull request Nov 5, 2025
40 tasks
@eduezerouali-tecnativa
Copy link
Contributor Author

@pilarvargas-tecnativa please could you review

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.