crea initiale
This commit is contained in:
commit
00455ee049
7 changed files with 52 additions and 0 deletions
1
__init__.py
Normal file
1
__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from . import models
|
||||
16
__manifest__.py
Normal file
16
__manifest__.py
Normal 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
1
models/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
from . import pos_order
|
||||
BIN
models/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
models/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
models/__pycache__/pos_order.cpython-312.pyc
Normal file
BIN
models/__pycache__/pos_order.cpython-312.pyc
Normal file
Binary file not shown.
18
models/pos_order.py
Normal file
18
models/pos_order.py
Normal 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)
|
||||
16
static/src/js/pos_invoice_always.js
Normal file
16
static/src/js/pos_invoice_always.js
Normal 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;
|
||||
}
|
||||
},
|
||||
});
|
||||
Loading…
Reference in a new issue