From 00455ee04999b1349802e62e944c6578dd3e0370 Mon Sep 17 00:00:00 2001 From: Luc Pierson Date: Fri, 5 Jun 2026 18:29:29 +0200 Subject: [PATCH] crea initiale --- __init__.py | 1 + __manifest__.py | 16 ++++++++++++++++ models/__init__.py | 1 + models/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 193 bytes models/__pycache__/pos_order.cpython-312.pyc | Bin 0 -> 970 bytes models/pos_order.py | 18 ++++++++++++++++++ static/src/js/pos_invoice_always.js | 16 ++++++++++++++++ 7 files changed, 52 insertions(+) create mode 100644 __init__.py create mode 100644 __manifest__.py create mode 100644 models/__init__.py create mode 100644 models/__pycache__/__init__.cpython-312.pyc create mode 100644 models/__pycache__/pos_order.cpython-312.pyc create mode 100644 models/pos_order.py create mode 100644 static/src/js/pos_invoice_always.js 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..e203d15 --- /dev/null +++ b/__manifest__.py @@ -0,0 +1,16 @@ +{ + "name": "LUC POS Invoice Always", + "version": "18.0.1.0.0", + "category": "Point of Sale", + "license": "AGPL-3", + "summary": "Force invoice generation by default on every POS order", + "author": "sdbinfo.fr", + "depends": ["point_of_sale"], + "assets": { + "point_of_sale._assets_pos": [ + "luc_pos_invoice_always/static/src/js/pos_invoice_always.js", + ], + }, + "installable": True, + "auto_install": False, +} diff --git a/models/__init__.py b/models/__init__.py new file mode 100644 index 0000000..e9ab911 --- /dev/null +++ b/models/__init__.py @@ -0,0 +1 @@ +from . import pos_order diff --git a/models/__pycache__/__init__.cpython-312.pyc b/models/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1c2e34f2ced645364fe13d0672f929559dff48dd GIT binary patch literal 193 zcmX@j%ge<81anU*Wk~?(#~=<2FhLog1%Qm{3@HpLj5!Rsj8Tk?43$ip%r6;%!kUb? zI1BQNIfRj>$M#9_%yG+~pCvzzpT6(SUx z9>nw@?Xky7{7dv=(L)&o3!cPFB^8P%XEq775BBZvy*KZ@-@G@UlF0-J`So$SQd0na zNMk7a0QBYs*aiXwxllzmsw%cpRc#f40(XEY>p)bhR?K1I>A$P?v8}Iami|*3mdaJ9 zUgk!rOkLu0qv{dr`o+^EfI$}YO2WG#dQ-3w0b3!+Ru!OHC1U-53J4w_)Gq4#Y=g!s zV`t;iYC{PTZQbk+LUz0jE67ef221DWBhP=x2xV*Wy60y-2^THIV}zERh8q-zv}Cd- zK56&v3-u0dLx|WoK_O}aONEG_i^Bg(B}%9^5z~np3Y-_dKzx1K)IxY8h8&_$>5Ab? z5k#~Ft`R42cp~s{xz_Z`MY?DyT=yGw%6JObnOCH~k0XMDx8_r~#P!JJDY{bjgL3V8 zKg{HycpT%R>xdNW%cWiu()ydvRck?xt^~}Pa|rQje$H(avAFuMD|XyvXVuU3HK!J z#1x!gP*x6@TnvxRd!9?38XFN7lY8QNbc={LPY&i$q^^sxg;++M@a5aN#l~euY^Y>4 zKP%M9Ivk`gweB8fu68E3r?#f{w6B@D*1bdB+*o?O)Kg5o&{M%kA4|k0h6NTZgKHk~ zyog1_j>#Qx{egVQL`3KiPTx8Y{^ J2Lz0g{{dO>?l}Me literal 0 HcmV?d00001 diff --git a/models/pos_order.py b/models/pos_order.py new file mode 100644 index 0000000..affcfd6 --- /dev/null +++ b/models/pos_order.py @@ -0,0 +1,18 @@ +from odoo import api, fields, models + + +class PosOrder(models.Model): + _inherit = "pos.order" + + to_invoice = fields.Boolean(default=True) + + @api.model + def _process_order(self, order, existing_order): + # Force to_invoice=True if not explicitly set to False by cashier + if order and "data" in order: + data = order["data"] + # Cashier explicit opt-out preserved (data sent False from frontend) + # Otherwise default to True + if "to_invoice" not in data: + data["to_invoice"] = True + return super()._process_order(order, existing_order) diff --git a/static/src/js/pos_invoice_always.js b/static/src/js/pos_invoice_always.js new file mode 100644 index 0000000..1af6069 --- /dev/null +++ b/static/src/js/pos_invoice_always.js @@ -0,0 +1,16 @@ +/** @odoo-module **/ + +import { patch } from "@web/core/utils/patch"; +import { PosOrder } from "@point_of_sale/app/models/pos_order"; + +patch(PosOrder.prototype, { + setup(vals) { + super.setup(vals); + // Override the default to_invoice=false from the base class. + // For new orders (no vals.to_invoice), default to true. + // For loaded orders (vals.to_invoice explicitly set), preserve the value. + if (vals.to_invoice === undefined) { + this.to_invoice = true; + } + }, +});