Skip to content

Commit

Permalink
Merge branch '14.0-add-website_payment_acquirer_bank_account' of gith…
Browse files Browse the repository at this point in the history
…ub.com:unaiberis/odoo-addons into 14.0-add-website_payment_acquirer_bank_account
  • Loading branch information
unaiberis committed Oct 24, 2024
2 parents b71d76f + ad876c5 commit 44d2855
Show file tree
Hide file tree
Showing 13 changed files with 269 additions and 91 deletions.
2 changes: 1 addition & 1 deletion custom_breeding_apps/views/stock_move_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<attribute name="editable">bottom</attribute>
</tree>
<field name="reference" position="after">
<field name="source_document" />
<field name="source_document" optional="hide" />
</field>
<field name="lot_id" position="before">
<field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-28 09:35+0000\n"
"PO-Revision-Date: 2023-08-28 09:35+0000\n"
"POT-Creation-Date: 2024-10-22 06:20+0000\n"
"PO-Revision-Date: 2024-10-22 06:20+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -177,6 +177,7 @@ msgstr ""

#. module: custom_purchase_import_wizard
#: code:addons/custom_purchase_import_wizard/models/purchase_order_import.py:0
#: code:addons/custom_purchase_import_wizard/models/purchase_order_import.py:0
#, python-format
msgid "Error: More than one shipping method found."
msgstr ""
Expand Down Expand Up @@ -211,6 +212,7 @@ msgstr ""

#. module: custom_purchase_import_wizard
#: code:addons/custom_purchase_import_wizard/models/purchase_order_import.py:0
#: code:addons/custom_purchase_import_wizard/models/purchase_order_import.py:0
#, python-format
msgid "Error: No shipping method found."
msgstr ""
Expand Down Expand Up @@ -355,7 +357,8 @@ msgstr ""

#. module: custom_purchase_import_wizard
#: model:ir.actions.act_window,name:custom_purchase_import_wizard.purchase_order_import_action
#: model:ir.ui.menu,name:custom_purchase_import_wizard.purchase_order_import_menu
#: model:ir.ui.menu,name:custom_purchase_import_wizard.purchase_order_import_menu_config
#: model:ir.ui.menu,name:custom_purchase_import_wizard.purchase_order_import_menu_purchase
msgid "Import Purchase Orders"
msgstr ""

Expand Down Expand Up @@ -451,11 +454,6 @@ msgstr ""
msgid "Next Activity Type"
msgstr ""

#. module: custom_purchase_import_wizard
#: model:ir.model.fields.selection,name:custom_purchase_import_wizard.selection__purchase_order_import_line__action__nothing
msgid "Nothing"
msgstr ""

#. module: custom_purchase_import_wizard
#: model:ir.model.fields,field_description:custom_purchase_import_wizard.field_purchase_order_import__message_needaction_counter
msgid "Number of Actions"
Expand Down Expand Up @@ -577,6 +575,11 @@ msgstr ""
msgid "Shipping Method"
msgstr ""

#. module: custom_purchase_import_wizard
#: model:ir.model.fields,field_description:custom_purchase_import_wizard.field_purchase_order_import__split_size
msgid "Split Size"
msgstr ""

#. module: custom_purchase_import_wizard
#: model:ir.model.fields,field_description:custom_purchase_import_wizard.field_purchase_order_import__state
#: model:ir.model.fields,field_description:custom_purchase_import_wizard.field_purchase_order_import_line__state
Expand Down
21 changes: 12 additions & 9 deletions custom_purchase_import_wizard/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-28 09:36+0000\n"
"PO-Revision-Date: 2023-08-28 09:36+0000\n"
"POT-Creation-Date: 2024-10-22 06:21+0000\n"
"PO-Revision-Date: 2024-10-22 06:21+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -180,6 +180,7 @@ msgstr ""

#. module: custom_purchase_import_wizard
#: code:addons/custom_purchase_import_wizard/models/purchase_order_import.py:0
#: code:addons/custom_purchase_import_wizard/models/purchase_order_import.py:0
#, python-format
msgid "Error: More than one shipping method found."
msgstr "Error: Más de un método de envío encontrado."
Expand All @@ -203,7 +204,7 @@ msgstr "Error: Se ha encontrado más de un almacén con nombre {}."
#: code:addons/custom_purchase_import_wizard/models/purchase_order_import.py:0
#, python-format
msgid "Error: No picking type found."
msgstr "Error: No se ha encontrado ningún tipo de operación."
msgstr "Error: Tipo de operación no encontrado."

#. module: custom_purchase_import_wizard
#: code:addons/custom_purchase_import_wizard/models/purchase_order_import.py:0
Expand All @@ -214,6 +215,7 @@ msgstr "Error: Producto no encontrado."

#. module: custom_purchase_import_wizard
#: code:addons/custom_purchase_import_wizard/models/purchase_order_import.py:0
#: code:addons/custom_purchase_import_wizard/models/purchase_order_import.py:0
#, python-format
msgid "Error: No shipping method found."
msgstr "Error: Método de envío no encontrado."
Expand Down Expand Up @@ -359,7 +361,8 @@ msgstr "Importar líneas de pedido de compra"

#. module: custom_purchase_import_wizard
#: model:ir.actions.act_window,name:custom_purchase_import_wizard.purchase_order_import_action
#: model:ir.ui.menu,name:custom_purchase_import_wizard.purchase_order_import_menu
#: model:ir.ui.menu,name:custom_purchase_import_wizard.purchase_order_import_menu_config
#: model:ir.ui.menu,name:custom_purchase_import_wizard.purchase_order_import_menu_purchase
msgid "Import Purchase Orders"
msgstr "Importar pedidos de compra"

Expand Down Expand Up @@ -455,11 +458,6 @@ msgstr "Resumen de la siguiente actividad"
msgid "Next Activity Type"
msgstr "Resumen de la siguiente actividad"

#. module: custom_purchase_import_wizard
#: model:ir.model.fields.selection,name:custom_purchase_import_wizard.selection__purchase_order_import_line__action__nothing
msgid "Nothing"
msgstr "Nada"

#. module: custom_purchase_import_wizard
#: model:ir.model.fields,field_description:custom_purchase_import_wizard.field_purchase_order_import__message_needaction_counter
msgid "Number of Actions"
Expand Down Expand Up @@ -581,6 +579,11 @@ msgstr "Coste de envío"
msgid "Shipping Method"
msgstr "Método de envío"

#. module: custom_purchase_import_wizard
#: model:ir.model.fields,field_description:custom_purchase_import_wizard.field_purchase_order_import__split_size
msgid "Split Size"
msgstr ""

#. module: custom_purchase_import_wizard
#: model:ir.model.fields,field_description:custom_purchase_import_wizard.field_purchase_order_import__state
#: model:ir.model.fields,field_description:custom_purchase_import_wizard.field_purchase_order_import_line__state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@
</record>

<menuitem
id="purchase_order_import_menu"
id="purchase_order_import_menu_config"
action="purchase_order_import_action"
parent="base_import_wizard.base_import_menu"
sequence="10"
/>

<menuitem
id="purchase_order_import_menu"
id="purchase_order_import_menu_purchase"
action="purchase_order_import_action"
parent="purchase.menu_procurement_management"
sequence="5"
Expand Down
14 changes: 14 additions & 0 deletions purchase_open_qty_totals/views/purchase_order_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,18 @@
</field>
</field>
</record>

<record id="purchase_order_kpis_tree" model="ir.ui.view">
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_kpis_tree" />
<field name="arch" type="xml">
<field name="origin" position="after">
<field name="qty_ordered" optional="show" />
<field name="qty_received" optional="show" />
<field name="qty_to_receive" optional="show" />
<field name="qty_invoiced" optional="show" />
<field name="qty_to_invoice" optional="show" />
</field>
</field>
</record>
</odoo>
3 changes: 2 additions & 1 deletion purchase_order_shipping_method/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Purchase Order Shipping Method",
"version": "14.0.1.0.0",
"version": "14.0.1.1.0",
"category": "Sales",
"license": "AGPL-3",
"author": "AvanzOSC",
Expand All @@ -25,4 +25,5 @@
"views/transport_carrier_lines_to_invoice_view.xml",
],
"installable": True,
"pre_init_hook": "pre_init_hook",
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 Berezi Amubieta - AvanzOSC
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import logging

from openupgradelib import openupgrade

_logger = logging.getLogger(__name__)


@openupgrade.migrate()
def migrate(env, version):
cr = env.cr
if not openupgrade.column_exists(cr, "stock_picking", "total_done_qty"):
cr.execute(
"""
ALTER TABLE stock_picking
ADD COLUMN total_done_qty float;
"""
)
cr.execute(
"""
UPDATE stock_picking
SET total_done_qty = (SELECT SUM(qty_done)
FROM stock_move_line
WHERE stock_move_line.picking_id = stock_picking.id)
"""
)
9 changes: 6 additions & 3 deletions purchase_order_shipping_method/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,21 @@ class StockPicking(models.Model):
)
license_plate = fields.Char(string="Transport License Plate")
total_done_qty = fields.Float(
string="Total Done Quantity", compute="_compute_total_done_qty"
string="Total Done Quantity", compute="_compute_total_done_qty", store=True
)
transport_price = fields.Float(
string="Transport Price", compute="_compute_transport_price"
)

@api.depends(
"move_line_ids_without_package", "move_line_ids_without_package.qty_done"
)
def _compute_total_done_qty(self):
for picking in self:
picking.total_done_qty = 0
if picking.move_ids_without_package:
if picking.move_line_ids_without_package:
picking.total_done_qty = sum(
picking.move_ids_without_package.mapped("quantity_done")
picking.move_line_ids_without_package.mapped("qty_done")
)

def _compute_transport_price(self):
Expand Down
6 changes: 1 addition & 5 deletions stock_picking_create_repair/models/repair_fee.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,4 @@ def _put_amount_untaxed_in_price_in_sale_budget(self):
and x.repair_id.sale_order_id
and x.repair_id.sale_order_id.is_repair
):
fee.repair_id.price_in_sale_budget = (
0
if not fee.repair_id.product_qty
else fee.repair_id.amount_untaxed / fee.repair_id.product_qty
)
fee.repair_id.price_in_sale_budget = fee.repair_id.amount_untaxed
6 changes: 1 addition & 5 deletions stock_picking_create_repair/models/repair_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,4 @@ def _put_amount_untaxed_in_price_in_sale_budget(self):
and x.repair_id.sale_order_id
and x.repair_id.sale_order_id.is_repair
):
line.repair_id.price_in_sale_budget = (
0
if not line.repair_id.product_qty
else line.repair_id.amount_untaxed / line.repair_id.product_qty
)
line.repair_id.price_in_sale_budget = line.repair_id.amount_untaxed
72 changes: 54 additions & 18 deletions website_payment_acquirer_bank_account/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def create_new_bank_account(self, **kwargs):

msg_payment_mode_missing = _("Payment mode ID is missing")
msg_invalid_bank_account = _(
"The bank account number must have exactly 20 digits."
"The bank account number must start with 'ES' followed by 22 digits."
)
msg_bank_account_exists = _("The bank account already exists")
msg_success = _("Bank account saved successfully")
Expand All @@ -31,11 +31,18 @@ def create_new_bank_account(self, **kwargs):
f"/shop/payment?message={msg_payment_mode_missing}&status=400"
)

payment_mode_id = int(payment_mode_id)
sale_order_id = http.request.session.get("sale_order_id")

if len(new_bank_account) != 20 or not new_bank_account.isdigit():
_logger.warning("The bank account number must have exactly 20 digits.")
# Convert the bank account to uppercase
new_bank_account = new_bank_account.upper()

# Validate that the bank account starts with 'ES' and is followed by exactly 22 digits
if not (
new_bank_account.startswith("ES")
and len(new_bank_account) == 24
and new_bank_account[2:].isdigit()
):
_logger.warning(
"The bank account must start with 'ES' followed by 22 digits."
)
return http.request.redirect(
f"/shop/payment?message={msg_invalid_bank_account}&status=400"
)
Expand All @@ -54,23 +61,52 @@ def create_new_bank_account(self, **kwargs):

partner_id = http.request.env.user.partner_id.id

http.request.env["res.partner.bank"].sudo().create(
{
"acc_number": new_bank_account,
"partner_id": partner_id,
}
# Remove any existing bank accounts for this partner
http.request.env["res.partner.bank"].sudo().search(
[("partner_id", "=", partner_id)]
).unlink()

# Create the new bank account
new_bank_account_record = (
http.request.env["res.partner.bank"]
.sudo()
.create(
{
"acc_number": new_bank_account,
"partner_id": partner_id,
}
)
)

sale_order = http.request.env["sale.order"].sudo().browse(sale_order_id)
sale_order.write(
{
"payment_mode_id": payment_mode_id,
# "bank_account_id": new_bank_account_record.id,
}
# Retrieve the sale_order_id from the session
sale_order_id = (
kwargs.get("sale_order_id")
or http.request.session.get("sale_order_id")
or http.request.env["website"].sudo().sale_get_order()
)
if not sale_order_id:
_logger.warning("Sale order ID was not provided.")
return http.request.redirect(
f"/shop/payment?message=Sale order ID missing&status=400"
)

sale_order = http.request.env["sale.order"].sudo().browse(sale_order_id)
if not sale_order.exists():
_logger.warning("Sale order not found: %s", sale_order_id)
return http.request.redirect(
f"/shop/payment?message=Sale order not found&status=400"
)

if sale_order and payment_mode_id:
sale_order.write(
{
"payment_mode_id": int(payment_mode_id),
}
)

_logger.info(
"Bank account created and successfully assigned to order ID: %s",
"New bank account created and old ones removed for partner ID: %s. Assigned to order ID: %s",
partner_id,
sale_order_id,
)

Expand Down
Loading

0 comments on commit 44d2855

Please sign in to comment.