crea initiale

This commit is contained in:
Luc Pierson 2026-06-05 18:29:29 +02:00
commit 00455ee049
7 changed files with 52 additions and 0 deletions

1
__init__.py Normal file
View file

@ -0,0 +1 @@
from . import models

16
__manifest__.py Normal file
View file

@ -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,
}

1
models/__init__.py Normal file
View file

@ -0,0 +1 @@
from . import pos_order

Binary file not shown.

Binary file not shown.

18
models/pos_order.py Normal file
View file

@ -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)

View file

@ -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;
}
},
});