From 84ae87fdcf2c6067424eba0d66803337e726823a Mon Sep 17 00:00:00 2001 From: "admin.suherdy" Date: Tue, 2 Dec 2025 16:18:44 +0700 Subject: [PATCH] first commit --- __init__.py | 1 + __manifest__.py | 16 +++++++ __pycache__/__init__.cpython-312.pyc | Bin 0 -> 225 bytes models/__init__.py | 1 + models/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 237 bytes .../__pycache__/res_partner.cpython-312.pyc | Bin 0 -> 1668 bytes models/res_partner.py | 27 +++++++++++ static/src/js/partner_editor.js | 30 +++++++++++++ static/src/xml/partner_editor.xml | 42 ++++++++++++++++++ 9 files changed, 117 insertions(+) create mode 100644 __init__.py create mode 100644 __manifest__.py create mode 100644 __pycache__/__init__.cpython-312.pyc create mode 100644 models/__init__.py create mode 100644 models/__pycache__/__init__.cpython-312.pyc create mode 100644 models/__pycache__/res_partner.cpython-312.pyc create mode 100644 models/res_partner.py create mode 100644 static/src/js/partner_editor.js create mode 100644 static/src/xml/partner_editor.xml diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/__manifest__.py b/__manifest__.py new file mode 100644 index 0000000..f80bc44 --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,16 @@ +{ + 'name': 'POS Customer Orders', + 'version': '17.0.1.0.0', + 'category': 'Point of Sale', + 'summary': 'Show last 2 orders in POS Customer Details', + 'depends': ['point_of_sale'], + 'data': [], + 'assets': { + 'point_of_sale.assets_prod': [ + 'pos_customer_orders/static/src/xml/**/*', + 'pos_customer_orders/static/src/js/**/*', + ], + }, + 'installable': True, + 'application': False, +} diff --git a/__pycache__/__init__.cpython-312.pyc b/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a45d1f88e8e717ba087f5a9a79b5a146a992348c GIT binary patch literal 225 zcmXwzF$%&!5Jh(q2qFj;dWbZ;SlNhp0d={STi%*U4loSf{fr=X~#j`78RtYszpEC=e=PVGkfel*SL>IE6m3gr@S_H0p(m zIlGA0(0m_MLDneW6~$25aHsL*5@p4z0wHxu=@Qokf83Vvg%v{3e1M-GEoB#j- literal 0 HcmV?d00001 diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..91fed54 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1 @@ +from . import res_partner diff --git a/models/__pycache__/__init__.cpython-312.pyc b/models/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a32b79ee837b2d67aa8ad7b9f9c04dd63ddaaf20 GIT binary patch literal 237 zcmXwzv1-FW42DlOl+Y5$+P;C8J34hKAx{uGcR8+>zy{yR=-yQ zB$`5?Jrq)%lt3VDDJ{kQE0SX`(Mj9AG|*FSYSa&sQ{U`LIMf>0x9|Ptea)Nq=GS;U zf?$3AqhfRgg#KW{Y)MmQavqog!U%H>)Z{8$ldtd`;?YM4^LG#y2v?V9M#ujn@W)m~ z?1&}l8DmSlCpRrj8n!2BEkkG6Z1GcOvJ1=r5mezYs_>Yr2t=&=S7MUG>8F|BE}O-J=jLEUnQ2f>tvmQ6`9fG&a*kwqDlC zHLFR=cDqI>?kF8ix30h6)LNRU=$2yO^3{%0vrHYvwQOO_di$NS-nJd9sbOrHcA1?u z00<2VY?p)CF2m%h(`! WPTQj>^;yiSRhhHT#>4&%$ZhmAwLHl6bN9A~ zsm)PpXPDY?6RY?3zFmD1f9pwX$4$TPrZeLZN-Gm2rXyd;<4u&?_;)?ASQzI~a%sGV zGP%K-{uy`a)ZlXevb%nIw0>^5e$HJjj8@MMSI@fn*G73|m{+D6;{;kOKHR>){ZCxZ zZjECovoemNm9;^&Uv-Ob{FMAIIV$cBi@PphxB9o-jnfaU``c_txY`=wfs)n|mA$f$%sh0o^Z!ys+wb zqN;ikRfW>F8wB{6s@`a84c2fVg`o}M0u6_>%II|BZn4E&l_CDSDIu literal 0 HcmV?d00001 diff --git a/models/res_partner.py b/models/res_partner.py new file mode 100644 index 0000000..331ebae --- /dev/null +++ b/models/res_partner.py @@ -0,0 +1,27 @@ +from odoo import models, api + +class ResPartner(models.Model): + _inherit = 'res.partner' + + @api.model + def get_pos_last_orders(self, partner_id): + orders = self.env['pos.order'].search( + [('partner_id', '=', partner_id)], + order='date_order desc', + limit=2 + ) + return [{ + 'id': order.id, + 'name': order.name, + 'pos_reference': order.pos_reference, + 'date_order': order.date_order, + 'amount_total': order.amount_total, + 'note': order.note, + 'lines': [{ + 'id': line.id, + 'product_name': line.product_id.name, + 'qty': line.qty, + 'price_unit': line.price_unit, + 'price_subtotal_incl': line.price_subtotal_incl, + } for line in order.lines], + } for order in orders] diff --git a/static/src/js/partner_editor.js b/static/src/js/partner_editor.js new file mode 100644 index 0000000..4b8fffb --- /dev/null +++ b/static/src/js/partner_editor.js @@ -0,0 +1,30 @@ +/** @odoo-module */ + +import { PartnerDetailsEdit } from "@point_of_sale/app/screens/partner_list/partner_editor/partner_editor"; +import { patch } from "@web/core/utils/patch"; +import { useService } from "@web/core/utils/hooks"; +import { onWillStart, useState } from "@odoo/owl"; + +patch(PartnerDetailsEdit.prototype, { + setup() { + super.setup(); + this.orm = useService("orm"); + this.state = useState({ ...this.state, lastOrders: [] }); + + onWillStart(async () => { + await this.fetchLastOrders(); + }); + }, + + async fetchLastOrders() { + const partnerId = this.props.partner.id; + if (partnerId) { + try { + const orders = await this.orm.call("res.partner", "get_pos_last_orders", [partnerId]); + this.state.lastOrders = orders; + } catch (error) { + console.error("Error fetching orders:", error); + } + } + } +}); diff --git a/static/src/xml/partner_editor.xml b/static/src/xml/partner_editor.xml new file mode 100644 index 0000000..ffb8527 --- /dev/null +++ b/static/src/xml/partner_editor.xml @@ -0,0 +1,42 @@ + + + + + +
+
+

Last Orders

+ +
+ +
+
+
+ +
+

Total:

+ Note: +
+ Products: +
    + +
  • + x + () +
  • +
    +
+
+
+
+
+
+ +
No orders found for this customer.
+
+
+
+
+
+ +