From 74578471f8dfc17fab11d0cda487e2aa446c0fa7 Mon Sep 17 00:00:00 2001 From: sngohodoo Date: Tue, 16 Jun 2026 11:07:39 +0530 Subject: [PATCH 1/2] [ADD] account_supplier_portal: add bill upload button for vendors Vendors currently have to email their invoices, which creates manual data entry work for the internal team. This adds a new action button to the portal webpage that is only visible to vendor users. This gives them the entry point to upload their files directly through the portal. Project: [PSIN]INTERNSHIP ONBOARDING Task: Supplier Portal --- account_supplier_portal/__init__.py | 1 + account_supplier_portal/__manifest__.py | 13 +++++++++++++ account_supplier_portal/controllers/__init__.py | 1 + account_supplier_portal/controllers/main.py | 9 +++++++++ .../views/account_supplier_portal_view.xml | 10 ++++++++++ .../views/portal_templates.xml | 15 +++++++++++++++ 6 files changed, 49 insertions(+) create mode 100644 account_supplier_portal/__init__.py create mode 100644 account_supplier_portal/__manifest__.py create mode 100644 account_supplier_portal/controllers/__init__.py create mode 100644 account_supplier_portal/controllers/main.py create mode 100644 account_supplier_portal/views/account_supplier_portal_view.xml create mode 100644 account_supplier_portal/views/portal_templates.xml diff --git a/account_supplier_portal/__init__.py b/account_supplier_portal/__init__.py new file mode 100644 index 00000000000..e046e49fbe2 --- /dev/null +++ b/account_supplier_portal/__init__.py @@ -0,0 +1 @@ +from . import controllers diff --git a/account_supplier_portal/__manifest__.py b/account_supplier_portal/__manifest__.py new file mode 100644 index 00000000000..aa054aa7fd1 --- /dev/null +++ b/account_supplier_portal/__manifest__.py @@ -0,0 +1,13 @@ +{ + "name": "Supplier Portal", + "application": False, + "installable": True, + "author": "sngoh", + "depends": ["base", "website", "account"], + "auto_install": True, + "license": "LGPL-3", + "data": [ + "views/portal_templates.xml", + "views/account_supplier_portal_view.xml", + ], +} diff --git a/account_supplier_portal/controllers/__init__.py b/account_supplier_portal/controllers/__init__.py new file mode 100644 index 00000000000..12a7e529b67 --- /dev/null +++ b/account_supplier_portal/controllers/__init__.py @@ -0,0 +1 @@ +from . import main diff --git a/account_supplier_portal/controllers/main.py b/account_supplier_portal/controllers/main.py new file mode 100644 index 00000000000..c59e975ea7d --- /dev/null +++ b/account_supplier_portal/controllers/main.py @@ -0,0 +1,9 @@ +from odoo import http +from odoo.http import request + + +class SupplierPortalController(http.Controller): + @http.route("/my/supplier/upload_bill", type="http", auth="public", website=True) + def uploadBill(self, page=1): + + return request.render("account_supplier_portal.account_supplier_portal_view") diff --git a/account_supplier_portal/views/account_supplier_portal_view.xml b/account_supplier_portal/views/account_supplier_portal_view.xml new file mode 100644 index 00000000000..185a1631504 --- /dev/null +++ b/account_supplier_portal/views/account_supplier_portal_view.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/account_supplier_portal/views/portal_templates.xml b/account_supplier_portal/views/portal_templates.xml new file mode 100644 index 00000000000..6ecc21a1442 --- /dev/null +++ b/account_supplier_portal/views/portal_templates.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file From 3771a897cc0ed959b2649e7217c06e79e04503a7 Mon Sep 17 00:00:00 2001 From: sngohodoo Date: Tue, 16 Jun 2026 15:17:23 +0530 Subject: [PATCH 2/2] [IMP] account_supplier_portal: allow vendors to upload bills and create drafts Manually entering vendor bills from emails takes up too much time for the internal accounting team. now vendors can submit their own invoices directly. Vendors can now open a dedicated portal page, select their associated company, and upload their PDF and XML files. The system then automatically creates a draft vendor bill in the backend. Project: [PSIN]INTERNSHIP ONBOARDING Task: Supplier Portal --- account_supplier_portal/__manifest__.py | 1 + account_supplier_portal/controllers/main.py | 72 ++++++++++++++++++- .../data/supplier_portal_data.xml | 45 ++++++++++++ .../views/account_supplier_portal_view.xml | 44 +++++++++++- 4 files changed, 158 insertions(+), 4 deletions(-) create mode 100644 account_supplier_portal/data/supplier_portal_data.xml diff --git a/account_supplier_portal/__manifest__.py b/account_supplier_portal/__manifest__.py index aa054aa7fd1..537613f4d27 100644 --- a/account_supplier_portal/__manifest__.py +++ b/account_supplier_portal/__manifest__.py @@ -7,6 +7,7 @@ "auto_install": True, "license": "LGPL-3", "data": [ + "data/supplier_portal_data.xml", "views/portal_templates.xml", "views/account_supplier_portal_view.xml", ], diff --git a/account_supplier_portal/controllers/main.py b/account_supplier_portal/controllers/main.py index c59e975ea7d..1ee6ec04739 100644 --- a/account_supplier_portal/controllers/main.py +++ b/account_supplier_portal/controllers/main.py @@ -1,9 +1,75 @@ +import base64 + from odoo import http from odoo.http import request class SupplierPortalController(http.Controller): - @http.route("/my/supplier/upload_bill", type="http", auth="public", website=True) - def uploadBill(self, page=1): + @http.route( + "/my/supplier/upload_bill", + type="http", + auth="public", + methods=["get"], + website=True, + ) + def supplierPortal(self): + user = request.env.user + + return request.render( + "account_supplier_portal.account_supplier_portal_view", + { + "allowed_companies": user.partner_id.parent_id, + }, + ) + + @http.route( + "/my/supplier/upload_bill", + type="http", + auth="public", + methods=["post"], + website=True, + ) + def submitBill(self, **kwargs): + + partner_id = int(kwargs.get("partner_id")) + pdf_file = kwargs.get("pdf_file") + xml_file = kwargs.get("xml_file") + + bill_vals = { + "move_type": "in_invoice", # Inbound Vendor Bill + "state": "draft", + "partner_id": partner_id, + } + new_bill = request.env["account.move"].sudo().create(bill_vals) + + attachments_to_create = [] + + if pdf_file: + attachments_to_create.append( + { + "name": pdf_file.filename, + "datas": base64.b64encode(pdf_file.read()), + "res_model": "account.move", + "res_id": new_bill.id, + } + ) + + if xml_file: + attachments_to_create.append( + { + "name": xml_file.filename, + "datas": base64.b64encode(xml_file.read()), + "res_model": "account.move", + "res_id": new_bill.id, + } + ) + + if attachments_to_create: + request.env["ir.attachment"].sudo().create(attachments_to_create) + + new_bill.sudo().message_post( + body="Vendor Bill submitted via Supplier Portal.", + attachment_ids=[att.id for att in new_bill.attachment_ids], + ) - return request.render("account_supplier_portal.account_supplier_portal_view") + return request.redirect("/supplier-portal-bill-added") diff --git a/account_supplier_portal/data/supplier_portal_data.xml b/account_supplier_portal/data/supplier_portal_data.xml new file mode 100644 index 00000000000..cde0769ba56 --- /dev/null +++ b/account_supplier_portal/data/supplier_portal_data.xml @@ -0,0 +1,45 @@ + + + + + Bill Added + qweb + /supplier-portal-bill-added + + True + account_supplier_portal.bill_added_page + + + +
+
+
+
+
+
+
+ +
+ +

Bill Successfully Uploaded

+

+ Your vendor bill has been received. +

+ + +
+
+
+
+
+
+
+
+
+
+ +
diff --git a/account_supplier_portal/views/account_supplier_portal_view.xml b/account_supplier_portal/views/account_supplier_portal_view.xml index 185a1631504..5a0033f875c 100644 --- a/account_supplier_portal/views/account_supplier_portal_view.xml +++ b/account_supplier_portal/views/account_supplier_portal_view.xml @@ -3,7 +3,49 @@