commit 00455ee04999b1349802e62e944c6578dd3e0370 Author: Luc Pierson Date: Fri Jun 5 18:29:29 2026 +0200 crea initiale 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 0000000..1c2e34f Binary files /dev/null and b/models/__pycache__/__init__.cpython-312.pyc differ diff --git a/models/__pycache__/pos_order.cpython-312.pyc b/models/__pycache__/pos_order.cpython-312.pyc new file mode 100644 index 0000000..186146a Binary files /dev/null and b/models/__pycache__/pos_order.cpython-312.pyc differ 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; + } + }, +});