add a few pos related addons

This commit is contained in:
Tobias Brunner 2023-08-08 20:00:34 +02:00
parent 956b150467
commit 6ec615d515
Signed by: tobru
SSH key fingerprint: SHA256:kywVhvCA+MIxL6eBgoQa+BfC/ROJqcfD2bpy1PR6Ebk
70 changed files with 2794 additions and 0 deletions

View file

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import models

View file

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
{
'name': "POS auto print kitchen receipt",
'support': "support@easyerps.com",
'license': "LGPL-3",
'summary': """
Auto print kitchen receipt after validate
""",
'author': "EasyERPS",
'website': "https://easyerps.com",
# Categories can be used to filter modules in modules listing
# Check https://github.com/odoo/odoo/blob/14.0/odoo/addons/base/data/ir_module_category_data.xml
# for the full list
'category': 'Point of Sale',
'version': '16.1.1',
# any module necessary for this one to work correctly
'data': [
'views/views.xml',
],
'depends': ['base', 'point_of_sale', 'pos_restaurant'],
'assets': {
'point_of_sale.assets': [
'EasyERPS_pos_auto_print_kitchen_receipt/static/src/js/ReceiptScreen.js',
'EasyERPS_pos_auto_print_kitchen_receipt/static/src/js/Models.js',
'EasyERPS_pos_auto_print_kitchen_receipt/static/src/xml/*.xml',
],
},
'images': ['images/main_screenshot.png'],
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View file

@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import pos

View file

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
from odoo import models, fields, api
class PosConfig(models.Model):
_inherit = 'pos.config'
kitchen_print = fields.Boolean(string='Enable kitchen receipt Printing Button', default=False)
kitchen_print_auto = fields.Boolean(string='Automatic kitchen receipt Printing', default=False)
@api.onchange('pos_module_pos_restaurant')
def _onchange_pos_module_pos_restaurant(self):
if not self.pos_module_pos_restaurant:
self.update({'kitchen_print_auto': False, 'kitchen_print': False})
@api.onchange('pos_is_order_printer')
def _onchange_pos_is_order_printer(self):
if not self.pos_is_order_printer:
self.update({'kitchen_print': False})
class ResConfigSettings(models.TransientModel):
_inherit = 'res.config.settings'
kitchen_print = fields.Boolean(related='pos_config_id.kitchen_print', readonly=False)
kitchen_print_auto = fields.Boolean(related='pos_config_id.kitchen_print_auto', readonly=False)
@api.onchange('pos_module_pos_restaurant')
def _onchange_pos_module_pos_restaurant(self):
if not self.pos_module_pos_restaurant:
self.update({'kitchen_print_auto': False, 'kitchen_print': False})
@api.onchange('pos_is_order_printer')
def _onchange_pos_is_order_printer(self):
if not self.pos_is_order_printer:
self.update({'kitchen_print': False})

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<section class="oe_container">
<div class="oe_spaced">
<h2 class="oe_slogan" style="color:#875A7B;">POS auto print kitchen receipt</h2>
<h2 class="oe_slogan">Auto print kitchen receipt after validate</h2>
<h2 class="oe_slogan">طباعة ايصال المطبخ تلقائيا بعد اعتماد الطلب</h2>
</div>
</section>
<section class="oe_container">
<div class="row">
<div class="col-sm-12">
<h4 style="font-size:24px; font-family:'Lato', 'Open Sans', 'Helvetica', Sans; text-align:center">
<span class="d-none d-sm-inline-block" style="width:10%; margin:32px 20px; border-top:solid 1px; vertical-align:middle; opacity:0.3"></span>
<b>Features</b>
<span class="d-none d-sm-inline-block" style="width:10%; margin:32px 20px; border-top:solid 1px; vertical-align:middle; opacity:0.3"></span>
</h4>
</div>
<div class="col-sm-12">
<div class="alert alert-info" style="margin:32px 0.5em 16px 0.5em;font-size: 20px;">
<ul class="list-unstyled" style="margin-bottom:0">
<li><i class="fa fa-check-square-o text-primary"></i> Auto print kitchen receipt after validate </li>
<li><i class="fa fa-check-square-o text-primary"></i> Button to print kitchen receipt </li>
</ul>
</div>
</div>
</div>
</section>
<section class="mb64">
<div class="mt16 mb16" style="text-align: center;">
<img src="img_1.png" class="img img-responsive center-block" style="border:8px solid lightgray">
<img src="img.png" class="img img-responsive center-block" style="border:8px solid lightgray">
<img src="img_2.png" class="img img-responsive center-block" style="border:8px solid lightgray">
</div>
</div>
</section>
<section class="mb64">
<center class="oe_slogan">
<a href="mailto:support@easyerps.com?subject=Odoo Support / Development&amp;body=" style="border-radius:45px; display:inline-block; color:#ffffff; font-family:'Roboto', sans-serif; font-size:23px; padding:10px 33px; background-color:black; text-decoration:none"><i class="fa fa-envelope"></i>&nbsp; support@easyerps.com</a>
<a href="https://wa.me/966554477623" style="border-radius:45px; display:inline-block; color:#ffffff; font-family:'Roboto', sans-serif; font-size:23px; padding:10px 33px; background-color:black; text-decoration:none"><i class="fa fa-skype"></i>&nbsp; Whatsapp: https://wa.me/966554477623</a>
</center>
</section>
</body>
</html>

View file

@ -0,0 +1,60 @@
odoo.define('EasyERPS_pos_auto_print_kitchen_receipt.Models', function (require) {
"use strict";
const { PosGlobalState, Order, Orderline, Payment } = require('point_of_sale.models');
const Registries = require('point_of_sale.Registries');
const Printer = require('point_of_sale.Printer').Printer;
const core = require('web.core');
const QWeb = core.qweb;
const PosAutoPrintChange = (Order) => class PosRestaurantOrder extends Order {
async printChanges(){
let isPrintSuccessful = true;
const d = new Date();
let hours = '' + d.getHours();
hours = hours.length < 2 ? ('0' + hours) : hours;
let minutes = '' + d.getMinutes();
minutes = minutes.length < 2 ? ('0' + minutes) : minutes;
for (const printer of this.pos.unwatched.printers) {
const changes = this._getPrintingCategoriesChanges(printer.config.product_categories_ids);
if (changes['new'].length > 0 || changes['cancelled'].length > 0) {
const printingChanges = {
new: changes['new'],
cancelled: changes['cancelled'],
table_name: this.pos.config.iface_floorplan ? this.getTable().name : false,
floor_name: this.pos.config.iface_floorplan ? this.getTable().floor.name : false,
name: this.name || 'unknown order',
time: {
hours,
minutes,
},
};
const receipt = QWeb.render('OrderChangeReceipt', { changes: printingChanges,widget:this, pos: this.pos, receipt: this.export_for_printing() });
const result = await printer.print_receipt(receipt);
if (!result.successful) {
isPrintSuccessful = false;
}
}
}
return isPrintSuccessful;
}
is_printChanges(){
for (const printer of this.pos.unwatched.printers) {
const changes = this._getPrintingCategoriesChanges(printer.config.product_categories_ids);
if (changes['new'].length > 0 || changes['cancelled'].length > 0) {
return true
}
}
return false
}
}
Registries.Model.extend(Order, PosAutoPrintChange);
});

View file

@ -0,0 +1,82 @@
odoo.define('EasyERPS_pos_auto_print_kitchen_receipt.ReceiptScreen', function (require) {
'use strict';
const ReceiptScreen = require('point_of_sale.ReceiptScreen');
const Registries = require('point_of_sale.Registries');
const { onMounted, useRef, status } = owl;
const customReceiptScreen = ReceiptScreen =>
class extends ReceiptScreen {
setup() {
super.setup();
onMounted(() => {
var self = this;
setTimeout(async () => {
if (!self.env.pos.config.iface_print_auto){
await self.handleAutoPrintChanges();
}
}, 0);
});
}
// constructor() {
// super(...arguments);
// var self = this;
// // let order = this.env.pos.get_order();
// // this.handleAutoPrintChanges();
// }
// mounted() {
// var self = this;
// setTimeout(async () => {
// if (!self.env.pos.config.iface_print_auto){
// await self.handleAutoPrintChanges();
// }
//
// }, 0);
// super.mounted();
// }
async handleAutoPrint() {
var self = this;
if (!this.env.pos.config.kitchen_print_auto) return super.handleAutoPrint();
if (this._shouldAutoPrint()) {
await this.printReceipt();
await this.handleAutoPrintChanges();
if (this.currentOrder._printed && this._shouldCloseImmediately()) {
this.whenClosing();
}
}
}
async printReceiptAndKitchen(){
await this.printReceipt();
await this.PrintChanges();
}
async handleAutoPrintChanges() {
if (this.env.pos.config.kitchen_print_auto){
await this.PrintChanges()
}
}
async PrintChanges() {
if (!this.is_changePrint){
let order = this.env.pos.get_order();
await order.printChanges();
this.is_changePrint = true
this.render();
}
}
};
Registries.Component.extend(ReceiptScreen, customReceiptScreen);
return ReceiptScreen;
});

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="ReceiptScreen" t-inherit="point_of_sale.ReceiptScreen" t-inherit-mode="extension" owl="1">
<xpath expr="//div[hasclass('buttons')]" position="after">
<div class="buttons" style="display: block !important;">
<t t-if="env.pos.config.kitchen_print and currentOrder.is_printChanges() and !is_changePrint">
<div class="button print" style="margin: inherit;" t-on-click="printReceiptAndKitchen">
<i class="fa fa-print"></i> Print Receipt and Kitchen
</div>
<div class="button print" style="margin: inherit;" t-on-click="PrintChanges">
<i class="fa fa-print"></i> Print Kitchen Receipt
</div>
</t>
</div>
</xpath>
</t>
</templates>

View file

@ -0,0 +1,25 @@
<odoo>
<data>
<record id="pos_config_view_form_inherit_pos" model="ir.ui.view">
<field name="name">res.config.settings.form.inherit.pos</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form"/>
<field name="arch" type="xml">
<xpath expr="//div[@id='auto_printing']//div[hasclass('o_setting_right_pane')]" position="after">
<div class="content-group mt16" attrs="{'invisible': [('pos_module_pos_restaurant', '=', False)]}">
<div>
<field name="kitchen_print_auto" class="oe_inline"/><span class="oe_inline"><b>Print Kitchen receipts automatically once the payment is registered</b></span>
</div>
</div>
</xpath>
<xpath expr="//div[@id='is_order_printer']//div[hasclass('o_setting_right_pane')]" position="after">
<div class="content-group mt16" attrs="{'invisible': [('pos_is_order_printer', '=', False)]}">
<div>
<field name="kitchen_print" class="oe_inline"/><span class="oe_inline"><b>Show Print kitchen receipt Button on Receipt Screen</b></span>
</div>
</div>
</xpath>
</field>
</record>
</data>
</odoo>

View file

@ -0,0 +1,97 @@
===================
POS Edit Order Line
===================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/16.0/pos_edit_order_line
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_edit_order_line
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/184/16.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
This module adds a button "Edit order lines" in main POS interface to allow an easier UX for cashier when editing product price, qty and discount.
On button click, a popup with order lines allows user to input a clear value for each field, instead of having to use the default process of selecting which field to edit, which is not very intuitive and error-prone.
.. image:: https://raw.githubusercontent.com/OCA/pos/16.0/pos_edit_order_line/static/description/pos_edit_order_line.png
:alt: Display Edit Order Line Popup
**Table of contents**
.. contents::
:local:
Configuration
=============
Select PoS > configuration > enable flag "Allow Edit Order Line"
To improve usability when there are more than 3 order lines, we suggest activating the "Large scrollbars" POS setting.
Changelog
=========
14.0.1.0.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Initial release
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_edit_order_line%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* Ooops
* Cetmix
Contributors
~~~~~~~~~~~~
* Ooops404 <https://www.ooops404.com/>
* Cetmix <https://cetmix.com/>
* `Acsone <https://www.acsone.eu/>`_:
* Maxime Franco
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/16.0/pos_edit_order_line>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View file

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

View file

@ -0,0 +1,28 @@
# copyright 2022 Dinar Gabbasov
# Copyright 2022 Ooops404
# Copyright 2022 Cetmix
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
{
"name": "POS Edit Order Line",
"version": "16.0.1.0.1",
"summary": "POS Edit Order Line",
"author": "Ooops, Cetmix, Odoo Community Association (OCA)",
"contributors": "Cetmix",
"license": "LGPL-3",
"category": "Point of Sale",
"website": "https://github.com/OCA/pos",
"depends": ["point_of_sale"],
"external_dependencies": {},
"demo": [],
"data": ["views/res_config_settings_view.xml"],
"assets": {
"point_of_sale.assets": [
"pos_edit_order_line/static/src/css/pos.css",
"pos_edit_order_line/static/src/js/*.js",
"pos_edit_order_line/static/src/xml/*.xml",
],
},
"installable": True,
"application": False,
}

View file

@ -0,0 +1,115 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_edit_order_line
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-03-06 18:23+0000\n"
"Last-Translator: Fernando <fernandolachica@gmail.com>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.14.1\n"
#. module: pos_edit_order_line
#: model:ir.model.fields,field_description:pos_edit_order_line.field_pos_config__allow_edit_order_line
#: model:ir.model.fields,field_description:pos_edit_order_line.field_res_config_settings__pos_allow_edit_order_line
msgid "Allow Edit Order Line"
msgstr "Permitir editar ticket"
#. module: pos_edit_order_line
#: model_terms:ir.ui.view,arch_db:pos_edit_order_line.res_config_settings_view_form
msgid "Allow edit Order Line in popup"
msgstr "Permitir editar ticket en un popup"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0
#, python-format
msgid "Cancel"
msgstr ""
#. module: pos_edit_order_line
#: model:ir.model,name:pos_edit_order_line.model_res_config_settings
msgid "Config Settings"
msgstr "Configuración"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Discount"
msgstr "Descuento"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0
#, python-format
msgid "Edit Order Line"
msgstr "Editar ticket"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderButton.xml:0
#, python-format
msgid "Edit Order Lines"
msgstr "Editar ticket"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0
#, python-format
msgid "Empty Order"
msgstr "Ticket vacío"
#. module: pos_edit_order_line
#: model:ir.model,name:pos_edit_order_line.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Configuración TPV"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Price"
msgstr "Precio"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Product"
msgstr "Producto"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Quantity"
msgstr "Cantidad"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0
#, python-format
msgid "Save"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "UoM"
msgstr "UdM"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0
#, python-format
msgid "You need add some products first"
msgstr "Primero añada productos"

View file

@ -0,0 +1,124 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_edit_order_line
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-03-30 10:23+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.14.1\n"
#. module: pos_edit_order_line
#: model:ir.model.fields,field_description:pos_edit_order_line.field_pos_config__allow_edit_order_line
#: model:ir.model.fields,field_description:pos_edit_order_line.field_res_config_settings__pos_allow_edit_order_line
msgid "Allow Edit Order Line"
msgstr "Abilita la modifica righe ordine con popup"
#. module: pos_edit_order_line
#: model_terms:ir.ui.view,arch_db:pos_edit_order_line.res_config_settings_view_form
msgid "Allow edit Order Line in popup"
msgstr "Abilita la modifica righe ordine con popup"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0
#, python-format
msgid "Cancel"
msgstr "Annulla"
#. module: pos_edit_order_line
#: model:ir.model,name:pos_edit_order_line.model_res_config_settings
msgid "Config Settings"
msgstr "Impostazioni configurazione"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Discount"
msgstr "Sconto"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0
#, python-format
msgid "Edit Order Line"
msgstr "Modifica righe ordine"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderButton.xml:0
#, python-format
msgid "Edit Order Lines"
msgstr "Modifica righe ordine"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0
#, python-format
msgid "Empty Order"
msgstr "Svuota ordine"
#. module: pos_edit_order_line
#: model:ir.model,name:pos_edit_order_line.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Configurazione punto vendita"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Price"
msgstr "Prezzo"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Product"
msgstr "Prodotto"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Quantity"
msgstr "Quantità"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0
#, python-format
msgid "Save"
msgstr "Salva"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "UoM"
msgstr "UdM"
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0
#, python-format
msgid "You need add some products first"
msgstr "È necessario aggiungere prima alcuni prodotti"
#~ msgid "Display Name"
#~ msgstr "Nome visualizzato"
#~ msgid "ID"
#~ msgstr "ID"
#~ msgid "Last Modified on"
#~ msgstr "Ultima modifica il"

View file

@ -0,0 +1,112 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_edit_order_line
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_edit_order_line
#: model:ir.model.fields,field_description:pos_edit_order_line.field_pos_config__allow_edit_order_line
#: model:ir.model.fields,field_description:pos_edit_order_line.field_res_config_settings__pos_allow_edit_order_line
msgid "Allow Edit Order Line"
msgstr ""
#. module: pos_edit_order_line
#: model_terms:ir.ui.view,arch_db:pos_edit_order_line.res_config_settings_view_form
msgid "Allow edit Order Line in popup"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0
#, python-format
msgid "Cancel"
msgstr ""
#. module: pos_edit_order_line
#: model:ir.model,name:pos_edit_order_line.model_res_config_settings
msgid "Config Settings"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Discount"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0
#, python-format
msgid "Edit Order Line"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderButton.xml:0
#, python-format
msgid "Edit Order Lines"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0
#, python-format
msgid "Empty Order"
msgstr ""
#. module: pos_edit_order_line
#: model:ir.model,name:pos_edit_order_line.model_pos_config
msgid "Point of Sale Configuration"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Price"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Product"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "Quantity"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderPopup.js:0
#, python-format
msgid "Save"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/xml/EditOrderPopup.xml:0
#, python-format
msgid "UoM"
msgstr ""
#. module: pos_edit_order_line
#. odoo-javascript
#: code:addons/pos_edit_order_line/static/src/js/EditOrderButton.js:0
#, python-format
msgid "You need add some products first"
msgstr ""

View file

@ -0,0 +1,2 @@
from . import pos_config
from . import res_config_settings

View file

@ -0,0 +1,14 @@
# copyright 2022 Dinar Gabbasov
# Copyright 2022 Ooops404
# Copyright 2022 Cetmix
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from odoo import fields, models
class PosConfig(models.Model):
_inherit = "pos.config"
allow_edit_order_line = fields.Boolean(
default=True,
)

View file

@ -0,0 +1,14 @@
# copyright 2023 Dinar Gabbasov
# Copyright 2023 Ooops404
# Copyright 2023 Cetmix
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl).
from odoo import fields, models
class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"
pos_allow_edit_order_line = fields.Boolean(
related="pos_config_id.allow_edit_order_line",
readonly=False,
)

View file

@ -0,0 +1,2 @@
Select PoS > configuration > enable flag "Allow Edit Order Line"
To improve usability when there are more than 3 order lines, we suggest activating the "Large scrollbars" POS setting.

View file

@ -0,0 +1,5 @@
* Ooops404 <https://www.ooops404.com/>
* Cetmix <https://cetmix.com/>
* `Acsone <https://www.acsone.eu/>`_:
* Maxime Franco

View file

@ -0,0 +1,6 @@
This module adds a button "Edit order lines" in main POS interface to allow an easier UX for cashier when editing product price, qty and discount.
On button click, a popup with order lines allows user to input a clear value for each field, instead of having to use the default process of selecting which field to edit, which is not very intuitive and error-prone.
.. image:: ../static/description/pos_edit_order_line.png
:alt: Display Edit Order Line Popup

View file

@ -0,0 +1,4 @@
14.0.1.0.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Initial release

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -0,0 +1,446 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>POS Edit Order Line</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="pos-edit-order-line">
<h1 class="title">POS Edit Order Line</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_edit_order_line"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_edit_order_line"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/184/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module adds a button “Edit order lines” in main POS interface to allow an easier UX for cashier when editing product price, qty and discount.</p>
<p>On button click, a popup with order lines allows user to input a clear value for each field, instead of having to use the default process of selecting which field to edit, which is not very intuitive and error-prone.</p>
<img alt="Display Edit Order Line Popup" src="https://raw.githubusercontent.com/OCA/pos/16.0/pos_edit_order_line/static/description/pos_edit_order_line.png" />
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="id2">Configuration</a></li>
<li><a class="reference internal" href="#changelog" id="id3">Changelog</a><ul>
<li><a class="reference internal" href="#id1" id="id4">14.0.1.0.0</a></li>
</ul>
</li>
<li><a class="reference internal" href="#bug-tracker" id="id5">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id6">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id7">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id8">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id9">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id2">Configuration</a></h1>
<p>Select PoS &gt; configuration &gt; enable flag “Allow Edit Order Line”
To improve usability when there are more than 3 order lines, we suggest activating the “Large scrollbars” POS setting.</p>
</div>
<div class="section" id="changelog">
<h1><a class="toc-backref" href="#id3">Changelog</a></h1>
<div class="section" id="id1">
<h2><a class="toc-backref" href="#id4">14.0.1.0.0</a></h2>
<ul class="simple">
<li>Initial release</li>
</ul>
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id5">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_edit_order_line%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id6">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id7">Authors</a></h2>
<ul class="simple">
<li>Ooops</li>
<li>Cetmix</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id8">Contributors</a></h2>
<ul class="simple">
<li>Ooops404 &lt;<a class="reference external" href="https://www.ooops404.com/">https://www.ooops404.com/</a>&gt;</li>
<li>Cetmix &lt;<a class="reference external" href="https://cetmix.com/">https://cetmix.com/</a>&gt;</li>
<li><a class="reference external" href="https://www.acsone.eu/">Acsone</a>:<ul>
<li>Maxime Franco</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id9">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_edit_order_line">OCA/pos</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 KiB

View file

@ -0,0 +1,61 @@
/* The Edit Order Line Popup */
.pos .edit-order-popup .popup {
max-width: 600px;
}
.pos .edit-order-popup .full-content {
overflow: auto;
}
.pos .edit-order-popup .order-line-list {
font-size: 16px;
width: 100%;
}
.pos .edit-order-popup .order-line-list th,
.pos .edit-order-popup .order-line-list td {
padding: 12px 8px;
}
.pos .edit-order-popup .order-line-list tr {
transition: all 150ms linear;
background: rgb(230, 230, 230);
}
.pos .edit-order-popup .order-line-list thead > tr,
.pos .edit-order-popup .order-line-list tr:nth-child(even) {
background: rgb(247, 247, 247);
}
.pos .edit-order-popup .order-line-list tr.highlight {
transition: all 150ms linear;
background: rgb(110, 200, 155) !important;
color: white;
}
.pos .edit-order-popup .order-line-list tr.lowlight {
transition: all 150ms linear;
background: rgb(216, 238, 227);
}
.pos .edit-order-popup .order-line-list tr.lowlight:nth-child(even) {
transition: all 150ms linear;
background: rgb(227, 246, 237);
}
.pos .edit-order-popup .subwindow .subwindow-container {
height: 250px;
display: list-item;
}
.pos .edit-order-popup input.required {
outline: none;
box-shadow: 0px 0px 0px 2px red;
}
@media screen and (max-width: 768px) {
.pos .edit-order-popup .order-line-list td {
overflow: hidden;
white-space: nowrap;
}
}

View file

@ -0,0 +1,75 @@
odoo.define("pos_edit_order_line.EditOrderButton", function (require) {
"use strict";
const PosComponent = require("point_of_sale.PosComponent");
const ProductScreen = require("point_of_sale.ProductScreen");
const {useListener} = require("@web/core/utils/hooks");
const Registries = require("point_of_sale.Registries");
const {_lt} = require("web.core");
class EditOrderButton extends PosComponent {
setup() {
super.setup();
useListener("click", this.onClick);
}
async onClick() {
var self = this;
var order = this.env.pos.get_order();
var order_lines = order.get_orderlines();
if (!order_lines.length) {
return this.showPopup("ErrorPopup", {
title: _lt("Empty Order"),
body: _lt("You need add some products first"),
});
}
var array = [];
_.each(order_lines, function (line) {
array.push({
id: line.id,
discount: line.discount,
price: line.get_unit_price(),
quantity: line.quantity,
uom: self.env.pos.units_by_id[line.product.uom_id[0]].name,
name: line.get_full_product_name(),
});
});
const {confirmed, payload} = await this.showPopup("EditOrderPopup", {
title: this.env._t("Edit Order Line"),
array: array,
});
if (confirmed) {
await self.apply_changes(payload);
}
}
async apply_changes(payload) {
var order = this.env.pos.get_order();
_.each(payload, function (changes, id) {
var line = order.get_orderline(parseInt(id, 10));
_.each(changes, function (value, key) {
if (key === "quantity") {
line.set_quantity(value);
} else if (key === "price") {
line.set_unit_price(value);
} else if (key === "discount") {
line.set_discount(value);
}
});
});
if (!_.isEmpty(payload)) {
this.env.posbus.trigger("change");
}
}
}
EditOrderButton.template = "EditOrderButton";
ProductScreen.addControlButton({
component: EditOrderButton,
condition: function () {
return this.env.pos.config.allow_edit_order_line;
},
});
Registries.Component.add(EditOrderButton);
return EditOrderButton;
});

View file

@ -0,0 +1,44 @@
odoo.define("pos_edit_order_line.EditOrderLineInput", function (require) {
"use strict";
const {useState} = owl;
const PosComponent = require("point_of_sale.PosComponent");
const Registries = require("point_of_sale.Registries");
class EditOrderLineInput extends PosComponent {
setup() {
super.setup();
this.state = useState({
quantityInput: this.props.item.quantity,
priceInput: this.props.item.price,
discountInput: this.props.item.discount,
});
this.changes = {
quantityInput: this.props.item.quantity,
priceInput: this.props.item.price,
discountInput: this.props.item.discount,
};
}
onChange() {
const id = this.props.item.id;
const value = parseFloat(event.target.value.trim());
if (isNaN(value)) {
$(event.target).addClass("required");
} else {
$(event.target).removeClass("required");
}
if (this.props.item[event.target.name] !== value) {
this.changes[event.target.name] = value;
this.trigger("onchange", {id, changes: this.changes});
}
}
onFocus(event) {
$(event.target).select();
}
}
EditOrderLineInput.template = "EditOrderLineInput";
Registries.Component.add(EditOrderLineInput);
return EditOrderLineInput;
});

View file

@ -0,0 +1,71 @@
odoo.define("pos_edit_order_line.EditOrderPopup", function (require) {
"use strict";
const {useState} = owl;
const AbstractAwaitablePopup = require("point_of_sale.AbstractAwaitablePopup");
const Registries = require("point_of_sale.Registries");
const {_lt} = require("@web/core/l10n/translation");
class EditOrderPopup extends AbstractAwaitablePopup {
setup() {
super.setup();
this._id = 0;
this.state = useState({array: this._initialize(this.props.array)});
this.changes = {};
}
_nextId() {
return this._id++;
}
_emptyItem() {
return {
text: "",
_id: this._nextId(),
};
}
_initialize(array) {
// If no array is provided, we initialize with one empty item.
if (array.length === 0) return [this._emptyItem()];
// Put _id for each item. It will serve as unique identifier of each item.
return array.map((item) =>
Object.assign(
{},
{_id: this._nextId()},
typeof item === "object" ? item : {text: item}
)
);
}
_onchange(event) {
const {id, changes} = event.detail;
this.changes[id] = changes;
}
getPayload() {
return this.changes;
}
async confirm() {
var allowConfirmChanges = true;
_.each(Object.values(this.changes), (updates) =>
_.each(Object.values(updates), (value) => {
if (isNaN(value)) {
allowConfirmChanges = false;
}
})
);
if (allowConfirmChanges) {
this.env.posbus.trigger("close-popup", {
popupId: this.props.id,
response: {confirmed: true, payload: await this.getPayload()},
});
}
}
}
EditOrderPopup.template = "EditOrderPopup";
EditOrderPopup.defaultProps = {
confirmText: _lt("Save"),
cancelText: _lt("Cancel"),
array: [],
};
Registries.Component.add(EditOrderPopup);
return EditOrderPopup;
});

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-name="EditOrderButton" owl="1">
<span class="control-button js_edit_order">
<i class="fa fa-pencil-square-o" />
<span> </span>
<span>Edit Order Lines</span>
</span>
</t>
</templates>

View file

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-name="EditOrderLineInput" owl="1">
<tr t-attf-class="order-line" t-att-data-id="props.item.id">
<td>
<t t-esc="props.item.name" />
</td>
<td>
<input
t-model="state.quantityInput"
t-on-change="onChange"
type="number"
name="quantity"
/>
</td>
<td>
<t t-esc="props.item.uom" />
</td>
<td>
<input
t-model="state.priceInput"
t-on-change="onChange"
type="number"
name="price"
/>
</td>
<td t-if="env.pos.config.manual_discount">
<input
t-model="state.discountInput"
t-on-change="onChange"
type="number"
name="discount"
/>
</td>
</tr>
</t>
</templates>

View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
<t t-name="EditOrderPopup" owl="1">
<div role="dialog" class="modal-dialog edit-order-popup">
<div class="popup popup-text">
<header class="title">
<t t-esc="props.title" />
</header>
<main class="full-content">
<div class="order-line-window">
<section class="subwindow list">
<div class="subwindow-container">
<div class="subwindow-container-fix scrollable-y">
<table class="order-line-list">
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>UoM</th>
<th>Price</th>
<th
t-if="env.pos.config.manual_discount"
>Discount</th>
</tr>
</thead>
<tbody
class="order-line-list-contents"
t-on-onchange="_onchange"
>
<t
t-foreach="state.array"
t-as="item"
t-key="item._id"
>
<EditOrderLineInput item="item" />
</t>
</tbody>
</table>
</div>
</div>
</section>
</div>
</main>
<footer class="footer">
<div class="button confirm" t-on-click="confirm">
<t t-esc="props.confirmText" />
</div>
<div class="button cancel" t-on-click="cancel">
<t t-esc="props.cancelText" />
</div>
</footer>
</div>
</div>
</t>
</templates>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="point_of_sale.res_config_settings_view_form" />
<field name="arch" type="xml">
<div id="pos_interface_section" position="inside">
<div class="col-12 col-lg-6 o_setting_box" id="allow_edit_order_line">
<div class="o_setting_left_pane">
<field name="pos_allow_edit_order_line" />
</div>
<div class="o_setting_right_pane">
<label for="pos_allow_edit_order_line" />
<div class="text-muted">
Allow edit Order Line in popup
</div>
</div>
</div>
</div>
</field>
</record>
</odoo>

View file

@ -0,0 +1,84 @@
=====================
POS Order Remove Line
=====================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github
:target: https://github.com/OCA/pos/tree/16.0/pos_order_remove_line
:alt: OCA/pos
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_order_remove_line
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/184/16.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
The module adds the possibility to delete a POS Order Line from the POS interface.
**Table of contents**
.. contents::
:local:
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/pos/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/pos/issues/new?body=module:%20pos_order_remove_line%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues.
Credits
=======
Authors
~~~~~~~
* Roberto Fichera
Contributors
~~~~~~~~~~~~
* Roberto Fichera <roberto.fichera@levelprime.com>
* Iván Todorovich <ivan.todorovich@gmail.com>
* Foram Shah <foram.shah@initos.com>
* Juan Bonilla <juancarlos.bonilla@factorlibre.com>
Maintainers
~~~~~~~~~~~
This module is maintained by the OCA.
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
.. |maintainer-robyf70| image:: https://github.com/robyf70.png?size=40px
:target: https://github.com/robyf70
:alt: robyf70
Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
|maintainer-robyf70|
This module is part of the `OCA/pos <https://github.com/OCA/pos/tree/16.0/pos_order_remove_line>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View file

@ -0,0 +1,2 @@
# Copyright 2023 LevelPrime
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)

View file

@ -0,0 +1,21 @@
# Copyright 2023 LevelPrime
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
{
"name": "POS Order Remove Line",
"summary": "Add button to remove POS order line.",
"author": "Roberto Fichera, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/pos",
"category": "Point of Sale",
"maintainers": ["robyf70"],
"version": "16.0.1.1.0",
"license": "LGPL-3",
"depends": ["point_of_sale"],
"assets": {
"point_of_sale.assets": [
"pos_order_remove_line/static/src/js/*.js",
"pos_order_remove_line/static/src/css/*.scss",
"pos_order_remove_line/static/src/xml/*xml",
]
},
}

View file

@ -0,0 +1,14 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"

View file

@ -0,0 +1,13 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

View file

@ -0,0 +1,4 @@
* Roberto Fichera <roberto.fichera@levelprime.com>
* Iván Todorovich <ivan.todorovich@gmail.com>
* Foram Shah <foram.shah@initos.com>
* Juan Bonilla <juancarlos.bonilla@factorlibre.com>

View file

@ -0,0 +1 @@
The module adds the possibility to delete a POS Order Line from the POS interface.

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View file

@ -0,0 +1,424 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<title>POS Order Remove Line</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="pos-order-remove-line">
<h1 class="title">POS Order Remove Line</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_order_remove_line"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/pos-16-0/pos-16-0-pos_order_remove_line"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/184/16.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>The module adds the possibility to delete a POS Order Line from the POS interface.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="id1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id5">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id1">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_order_remove_line%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id2">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id3">Authors</a></h2>
<ul class="simple">
<li>Roberto Fichera</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id4">Contributors</a></h2>
<ul class="simple">
<li>Roberto Fichera &lt;<a class="reference external" href="mailto:roberto.fichera&#64;levelprime.com">roberto.fichera&#64;levelprime.com</a>&gt;</li>
<li>Iván Todorovich &lt;<a class="reference external" href="mailto:ivan.todorovich&#64;gmail.com">ivan.todorovich&#64;gmail.com</a>&gt;</li>
<li>Foram Shah &lt;<a class="reference external" href="mailto:foram.shah&#64;initos.com">foram.shah&#64;initos.com</a>&gt;</li>
<li>Juan Bonilla &lt;<a class="reference external" href="mailto:juancarlos.bonilla&#64;factorlibre.com">juancarlos.bonilla&#64;factorlibre.com</a>&gt;</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id5">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/robyf70"><img alt="robyf70" src="https://github.com/robyf70.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/16.0/pos_order_remove_line">OCA/pos</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,11 @@
/*
* Copyright 2023 LevelPrime
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
*/
.remove-line-button {
float: right;
padding: 0 5px 0 10px;
cursor: pointer;
margin-left: 6px;
}

View file

@ -0,0 +1,32 @@
/** @odoo-module **/
/*
* Copyright 2023 LevelPrime
* License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
*/
import Orderline from "point_of_sale.Orderline";
import Registries from "point_of_sale.Registries";
const PosOrderline = (Orderline) =>
class extends Orderline {
async removeLine(ev) {
const order = this.env.pos.get_order();
if (order) {
ev.stopPropagation();
ev.preventDefault();
this.selectLine();
const selected_line = order.get_selected_orderline();
selected_line.set_quantity("remove");
order.remove_orderline(selected_line);
this.checkRewardLines(order);
}
}
// Dependecy-less suport to pos_loyalty
checkRewardLines(order) {
const anyRewardLine = order.orderlines.some((line) => line.is_reward_line);
if (anyRewardLine) {
order._updateRewards();
}
}
};
Registries.Component.extend(Orderline, PosOrderline);

View file

@ -0,0 +1,13 @@
<!--
~ Copyright 2023 LevelPrime
~ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
-->
<templates id="template" xml:space="preserve">
<t t-inherit="point_of_sale.Orderline" t-inherit-mode="extension">
<xpath expr="//span[hasclass('price')]" position="before">
<button class="remove-line-button" t-on-click="removeLine">
<i class="fa fa-trash-o" />
</button>
</xpath>
</t>
</templates>

Binary file not shown.

View file

@ -0,0 +1,30 @@
==================================================================
Restriction of POS User
==================================================================
Allows setting the allowed Points of Sale for POS users and restricts access for other Points.
Restrictions work only for users with role **Point of Sale / User**.
After configuration, users will be able to see only the allowed Points of Sale, POS orders, and POS payments that related to these Points.
Users with role **Point of Sale / Manager** can view all Points of Sale, POS orders, and Pos payments.
Configuration
=============
Goto **Settings** \> **Users and Companies** \> **Users**.
Choose a user and set allowed Points of Sale on the tab **Access Rights**.
Support and development
=======================
Contact us:
* support@garazd.biz
* https://garazd.biz/page/contactus

View file

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

View file

@ -0,0 +1,29 @@
# Copyright © 2018 Garazd Creation (https://garazd.biz)
# @author: Yurii Razumovskyi (support@garazd.biz)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.html).
{
'name': 'Restriction of POS User',
'version': '16.0.1.0.0',
'category': 'Point of Sale',
'author': 'Garazd Creation',
'website': 'https://garazd.biz/shop',
'license': 'LGPL-3',
'summary': 'Only allowed points of sale for POS users',
'images': ['static/description/banner.png', 'static/description/icon.png'],
'depends': [
'point_of_sale',
],
'data': [
'security/pos_user_restrict_security.xml',
'views/res_users_views.xml',
],
'demo': [
'demo/point_of_sale_demo.xml',
'demo/res_users_demo.xml',
],
'support': 'support@garazd.biz',
'application': False,
'installable': True,
'auto_install': False,
}

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="pos_config_second" model="pos.config">
<field name="name">Shop 2</field>
<field name="iface_start_categ_id" ref="point_of_sale.pos_category_desks"/>
<field name="start_category">True</field>
</record>
</odoo>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="partner_pos" model="res.partner">
<field name="name">POS User</field>
<field name="company_id" ref="base.main_company"/>
<field name="street">3575 Buena Vista Avenue</field>
<field name="city">Kharkiv</field>
<field name="zip">61000</field>
<field name="country_id" ref="base.ua"/>
<field name="tz">Europe/Kiev</field>
<field name="email">pos.user@example.com</field>
<field name="phone">(057)-123-2334</field>
</record>
<record id="user_pos" model="res.users">
<field name="partner_id" ref="pos_user_restrict.partner_pos"/>
<field name="login">pos</field>
<field name="password">pos</field>
<field name="company_id" ref="base.main_company"/>
<field name="groups_id" eval="[Command.set([ref('base.group_user'), ref('base.group_partner_manager'), ref('point_of_sale.group_pos_user')])]"/>
</record>
</odoo>

View file

@ -0,0 +1,11 @@
.. _changelog:
Changelog
=========
`16.0.1.0.0`
------------
- Migration from 15.0.

View file

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

View file

@ -0,0 +1,22 @@
# Copyright © 2018 Garazd Creation (<https://garazd.biz>)
# @author: Yurii Razumovskyi (<support@garazd.biz>)
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.html).
from odoo import fields, models
class ResUsers(models.Model):
_inherit = 'res.users'
pos_config_ids = fields.Many2many(
comodel_name='pos.config',
string='Allowed POS',
help="Allowed Points of Sales for the user. "
"POS managers can use all POS.",
)
def write(self, values):
res = super(ResUsers, self).write(values)
if self.ids and 'pos_config_ids' in values:
self.env['ir.rule'].clear_caches()
return res

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright © 2018 Garazd Creation (<https://garazd.biz>)
@author: Yurii Razumovskyi (<support@garazd.biz>)
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.html). -->
<odoo noupdate="1">
<record id="point_of_sale_rule_user_config" model="ir.rule">
<field name="name">Show only allowed POS configs for User</field>
<field name="model_id" ref="point_of_sale.model_pos_config"/>
<field name="domain_force">[('id', 'in', user.pos_config_ids.ids)]</field>
<field name="groups" eval="[(4, ref('point_of_sale.group_pos_user'))]"/>
</record>
<record id="point_of_sale_rule_manager_config" model="ir.rule">
<field name="name">All POS configs for Manager.</field>
<field name="model_id" ref="point_of_sale.model_pos_config"/>
<field name="domain_force">[(1, '=', 1)]</field>
<field name="groups" eval="[(4, ref('point_of_sale.group_pos_manager'))]"/>
</record>
<record id="point_of_sale_rule_user_session" model="ir.rule">
<field name="name">Show POS Sessions only for allowed POS configs.</field>
<field name="model_id" ref="point_of_sale.model_pos_session"/>
<field name="domain_force">[('config_id', 'in', user.pos_config_ids.ids)]</field>
<field name="groups" eval="[(4, ref('point_of_sale.group_pos_user'))]"/>
</record>
<record id="point_of_sale_rule_manager_session" model="ir.rule">
<field name="name">Show All POS Sessions for Manager.</field>
<field name="model_id" ref="point_of_sale.model_pos_session"/>
<field name="domain_force">[(1, '=', 1)]</field>
<field name="groups" eval="[(4, ref('point_of_sale.group_pos_manager'))]"/>
</record>
<record id="point_of_sale_rule_user_order" model="ir.rule">
<field name="name">Show POS Orders only for allowed POS configs.</field>
<field name="model_id" ref="point_of_sale.model_pos_order"/>
<field name="domain_force">[('config_id', 'in', user.pos_config_ids.ids)]</field>
<field name="groups" eval="[(4, ref('point_of_sale.group_pos_user'))]"/>
</record>
<record id="point_of_sale_rule_manager_order" model="ir.rule">
<field name="name">Show All POS Orders for Manager.</field>
<field name="model_id" ref="point_of_sale.model_pos_order"/>
<field name="domain_force">[(1, '=', 1)]</field>
<field name="groups" eval="[(4, ref('point_of_sale.group_pos_manager'))]"/>
</record>
<record id="point_of_sale_rule_user_payment" model="ir.rule">
<field name="name">Show POS Payments only for allowed POS configs.</field>
<field name="model_id" ref="point_of_sale.model_pos_payment"/>
<field name="domain_force">[('session_id.config_id', 'in', user.pos_config_ids.ids)]</field>
<field name="groups" eval="[(4, ref('point_of_sale.group_pos_user'))]"/>
</record>
<record id="point_of_sale_rule_manager_payment" model="ir.rule">
<field name="name">Show All POS Payments for Manager.</field>
<field name="model_id" ref="point_of_sale.model_pos_payment"/>
<field name="domain_force">[(1, '=', 1)]</field>
<field name="groups" eval="[(4, ref('point_of_sale.group_pos_manager'))]"/>
</record>
</odoo>

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

@ -0,0 +1,277 @@
<section class="oe_container" style="font-family: 'Montserrat', 'Odoo Unicode Support Noto', sans-serif;">
<div class="row mt8">
<div class="col-4 text-center d-md-none">
<div class="my-2 mx-sm-2" style="color: #6F649A;"><i class="fa fa-check-circle"></i> Community</div>
</div>
<div class="col-4 text-center d-md-none">
<div class="my-2 mx-sm-2" style="color: #694D65;"><i class="fa fa-check-circle"></i> Enterprise</div>
</div>
<div class="col-4 text-center d-md-none">
<div class="my-2 mx-sm-2" style="color: #407876;"><i class="fa fa-check-circle"></i> Odoo.sh</div>
</div>
<div class="col-12 text-right d-none d-md-block">
<div class="float-right oe_right m-2" style="background-color: #407876; border-color: #407876; color: #FFFFFF; padding: 5px 28px; border-radius: 15px 0 15px 0; opacity: 1;"><i class="fa fa-check"></i> Odoo.sh</div>
<div class="float-right oe_right m-2" style="background-color: #694D65; border-color: #694D65; color: #FFFFFF; padding: 5px 28px; border-radius: 15px 0 15px 0; opacity: 1;"><i class="fa fa-check"></i> Enterprise</div>
<div class="float-right oe_right m-2" style="background-color: #6F649A; border-color: #6F649A; color: #FFFFFF; padding: 5px 28px; border-radius: 15px 0 15px 0; opacity: 1;"><i class="fa fa-check"></i> Community</div>
</div>
</div>
</section>
<section class="oe_container" style="font-family: 'Montserrat', 'Odoo Unicode Support Noto', sans-serif;">
<div class="row oe_spaced">
<h2 class="h1 col-12 text-center" style="color: #154577; font-weight: 900; font-family: 'Montserrat', 'Odoo Unicode Support Noto', sans-serif;">Manage POS user&#39;s access rights to Points, Sessions, and Orders.</h2>
</div>
</section>
<section class="oe_container" style="font-family: 'Montserrat', 'Odoo Unicode Support Noto', sans-serif;">
<div class="row oe_spaced">
<div class="col-12">
<div class="h2 text-left ml8" style="color: #FEA621; font-family: 'Montserrat', 'Odoo Unicode Support Noto', sans-serif;"><i class="fa fa-newspaper-o mr8"></i>Description</div>
<div class="media p-2 pt-4 border-top border-right overflow-hidden" style="border-color: #FEA621 !important; border-radius: 0 15px 0 0;">
<div class="py-2 px-md-5 lead w-100" style="line-height: 2.5rem;"><p>In cases, when your business needs to restrict access to some Points of Sales for your employees, this module allows solving these requirements.</p>
<ul class="fa-ul">
<li><span class="fa-li"><i class="fa fa-check text-primary"></i></span>Restrictions work only for users with the role "Point of Sale / User".</li>
<li><span class="fa-li"><i class="fa fa-check text-primary"></i></span>After configuration, users will be able to see only allowed Points of Sale, POS orders and payments related to them.</li>
<li><span class="fa-li"><i class="fa fa-check text-primary"></i></span>Users with the role "Point of Sale / Manager" have full access to all Points of Sale, POS orders, sessions and payments.</li>
<li><span class="fa-li"><i class="fa fa-check text-primary"></i></span>Simply configurable from the user settings form.</li>
</ul></div>
</div>
</div>
</div>
</section>
<section class="oe_container" style="font-family: 'Montserrat', 'Odoo Unicode Support Noto', sans-serif;">
<div class="row oe_spaced">
<div class="col-12">
<div class="h2 text-left ml8" style="color: #FEA621; font-family: 'Montserrat', 'Odoo Unicode Support Noto', sans-serif;"><i class="fa fa-check-square-o mr8"></i>Features</div>
<div class="s_features_grid p-2 pt-4 border-top border-right o_colored_level bg-light" data-snippet="s_features_grid" data-name="Features Grid" style="border-color: #FEA621 !important; border-radius: 0 15px 0 0;">
<div class="container p-0">
<div class="row px-md-5">
<div class="col-lg-6 s_col_no_bgcolor pb24">
<div class="row">
<div class="col-lg-12 o_colored_level" data-name="Box">
<i class="s_features_grid_icon fa fa-2x float-left mr8 mr-3 bg-warning fa-smile-o rounded-circle" style="line-height:5rem; height:5rem; width:5rem; text-align:center; float:left;"></i>
<div class="s_features_grid_content">
<div class="h4">Easy &amp; Simple</div>
<p>Easy to activate and configure</p>
</div>
</div>
</div>
</div>
<div class="col-lg-6 s_col_no_bgcolor pb24">
<div class="row">
<div class="col-lg-12 o_colored_level" data-name="Box">
<i class="s_features_grid_icon fa fa-2x float-left mr8 mr-3 bg-warning fa-check-square-o rounded-circle" style="line-height:5rem; height:5rem; width:5rem; text-align:center; float:left;"></i>
<div class="s_features_grid_content">
<div class="h4">Tested</div>
<p>Include unit tests</p>
</div>
</div>
</div>
</div>
<div class="col-lg-6 s_col_no_bgcolor pb24">
<div class="row">
<div class="col-lg-12 o_colored_level" data-name="Box">
<i class="s_features_grid_icon fa fa-2x float-left mr8 mr-3 bg-warning fa-support rounded-circle" style="line-height:5rem; height:5rem; width:5rem; text-align:center; float:left;"></i>
<div class="s_features_grid_content">
<div class="h4">Support</div>
<p>Free 30 days support and 180 days bug-fixing</p>
</div>
</div>
</div>
</div>
<div class="col-lg-6 s_col_no_bgcolor pb24">
<div class="row">
<div class="col-lg-12 o_colored_level" data-name="Box">
<i class="s_features_grid_icon fa fa-2x float-left mr8 mr-3 bg-dark fa-search rounded-circle" style="line-height:5rem; height:5rem; width:5rem; text-align:center; float:left;"></i>
<div class="s_features_grid_content">
<div class="h4">Try me</div>
<p>Demo &amp; Test. Click on the "Live Preview" button</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="row oe_spaced">
<div class="col-sm-12 col-xs-12">
<div class="col-12 offset-md-3 col-md-6 offset-lg-4 col-lg-4 text-center">
<h3 class="oe_slogan" style="background-color: #fea621; border-color: #fea621; color: #FFFFFF; padding: 5px 28px; border-radius: 15px 0 15px 0; opacity: 1;">Configuration</h3>
</div>
<p class="lead ml32">To configure please follow these steps:</p>
<ul class="ml32">
<li>Go to the <span class="font-weight-bold">Settings</span> - <span class="font-weight-bold">Users</span> menu.</li>
<li>Set up the <span class="font-weight-bold">Allowed POS</span> in the user form.</li>
<li>Changes will be applied immediately after saving.</li>
</ul>
<div class="p-0 offset-1 col-10 offset-xl-2 col-xl-8 oe_demo oe_screenshot oe_spaced">
<img src="user_settings_pos.jpg" style="width: 100%; max-width: 100%;" alt="Restrict POS Users to allowed Points of Sale in Odoo 16.0 Restriction of POS User configuration" title="Limit POS Users to allowed Points of Sale in Odoo 16.0">
</div>
</div>
</div>
</section>
<section class="oe_container" style="font-family: 'Montserrat','Odoo Unicode Support Noto',sans-serif;">
<div class="row oe_spaced">
<div class="col-12">
<div class="h2 text-left pl-2" style="color: #FEA621; font-family: 'Montserrat', 'Odoo Unicode Support Noto', sans-serif;">Related Modules</div>
<div class="mb-3 border-top border-right bg-light" style="border-color: #FEA621 !important; border-radius: 0 15px 0 0;">
<div id="related_modules" class="carousel slide mt-2 mx-3" data-ride="carousel" data-interval="15000" data-pause="hover">
<div class="carousel-inner">
<div class="carousel-item active" style="min-height: 0px;">
<div class="col-xs-12 col-sm-4 col-md-4 my-4 px-3" style="float:left">
<a href="https://apps.odoo.com/apps/modules/16.0/website_sale_facebook_pixel/" target="_blank">
<div class="card shadow-sm border rounded deep-1 deep_hover">
<img class="img img-responsive center-block border-bottom w-100" src="banner_website_sale_facebook_pixel.png" alt="Odoo App Facebook Pixel eCommerce" title="Facebook Pixel eCommerce | eCommerce Facebook Pixel | Meta Pixel | Track Events | Website events tracking | Integration | Add eCommerce events to product and category website pages">
<div class="card-body">
<div class="card-title h5 text-nowrap text-truncate" title="Facebook Pixel eCommerce">Facebook Pixel eCommerce</div>
<p class="card-text small text-nowrap text-truncate" title="eCommerce Facebook Pixel | Meta Pixel | Track Events | Website events tracking | Integration | Add eCommerce events to product and category website pages">eCommerce Facebook Pixel | Meta Pixel | Track Events | Website events tracking | Integration | Add eCommerce events to product and category website pages</p>
</div>
</div>
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 my-4 px-3" style="float:left">
<a href="https://apps.odoo.com/apps/modules/16.0/website_sale_google_analytics_4/" target="_blank">
<div class="card shadow-sm border rounded deep-1 deep_hover">
<img class="img img-responsive center-block border-bottom w-100" src="banner_website_sale_google_analytics_4.png" alt="Odoo App Google Analytics 4 eCommerce" title="Google Analytics 4 eCommerce | Google Analytics 4 for eCommerce | GA4 Retail and Ecommerce Events">
<div class="card-body">
<div class="card-title h5 text-nowrap text-truncate" title="Google Analytics 4 eCommerce">Google Analytics 4 eCommerce</div>
<p class="card-text small text-nowrap text-truncate" title="Google Analytics 4 for eCommerce | GA4 Retail and Ecommerce Events">Google Analytics 4 for eCommerce | GA4 Retail and Ecommerce Events</p>
</div>
</div>
</a>
</div>
<div class="col-xs-12 col-sm-4 col-md-4 my-4 px-3" style="float:left">
<a href="https://apps.odoo.com/apps/modules/16.0/facebook_shop/" target="_blank">
<div class="card shadow-sm border rounded deep-1 deep_hover">
<img class="img img-responsive center-block border-bottom w-100" src="banner_facebook_shop.png" alt="Odoo App Facebook Catalog Feeds" title="Facebook Catalog Feeds | Product catalogue to advertise or sell items on Facebook and Instagram. Data Feed | Data Import | Data Source | FB Product Catalog | Odoo Instagram Feed">
<div class="card-body">
<div class="card-title h5 text-nowrap text-truncate" title="Facebook Catalog Feeds">Facebook Catalog Feeds</div>
<p class="card-text small text-nowrap text-truncate" title="Product catalogue to advertise or sell items on Facebook and Instagram. Data Feed | Data Import | Data Source | FB Product Catalog | Odoo Instagram Feed">Product catalogue to advertise or sell items on Facebook and Instagram. Data Feed | Data Import | Data Source | FB Product Catalog | Odoo Instagram Feed</p>
</div>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="oe_container" style="font-family: 'Montserrat', 'Odoo Unicode Support Noto', sans-serif; background-color: #FEA621; border-color: #fea621; padding: 12px 28px; border-radius: 15px 0 15px 0;">
<div class="row my-2">
<div class="col-lg-4 text-center mb-5 mb-lg-0">
<div class="h3 p-2 mb-2 font-weight-bold">Contact Us</div>
<div class="lead text-white pb-2">Support, customizations, and development</div>
<div class="w-100 w-md-75 w-lg-100 my-1 pl-3 text-nowrap text-truncate btn btn-dark rounded">
<i class="fa fa-envelope fa-fw" style="font-size:1.2rem;"></i>
<a href="mailto:support@garazd.biz" target="_blank">support@garazd.biz</a>
</div>
<div class="w-100 w-md-75 w-lg-100 my-1 pl-3 text-nowrap text-truncate btn btn-dark rounded">
<i class="fa fa-skype fa-fw" style="font-size:1.2rem;"></i>
<span>Skype: </span>
<a href="skype:live:7f0648d653072c5f?chat" target="_blank">GarazdCreation</a>
</div>
<div class="w-100 w-md-75 w-lg-100 m-auto my-1 pl-3 text-nowrap text-truncate btn-light border border-dark rounded" style="line-height: 2.4rem;">
<a href="https://garazd.biz/contactus" target="_blank">https://garazd.biz/contactus</a>
</div>
</div>
<div class="col-12 col-lg-4 border-left border-right">
<div class="h3 p-2 mb-3 text-center font-weight-bold">Our expertise</div>
<div class="text-left">
<div class="my-3 pl-3 text-nowrap text-truncate lead text-white" data-container="body" data-toggle="popover" data-placement="top" data-content="Garazd Creation is official Odoo Partner with the status 'Learning Partner'.">
<i class="fa fa-handshake-o fa-fw"></i> Odoo Learning Partner
</div>
<div class="my-3 pl-3 text-nowrap text-truncate lead text-white" data-container="body" data-toggle="popover" data-placement="top" data-content="Odoo Community Association member.">
<i class="fa fa-group fa-fw"></i> OCA Member
</div>
<div class="my-3 pl-3 text-nowrap text-truncate lead text-white" data-container="body" data-toggle="popover" data-placement="top" data-content="Garazd Creation with Odoo since 2014.">
<i class="fa fa-calendar-check-o fa-fw"></i> With Odoo since 2014
</div>
<div class="my-3 pl-3 lead text-white" data-container="body" data-toggle="popover" data-placement="top" data-content="Over 7,000 app downloads and purchases in Odoo Apps Store.">
<i class="fa fa-download fa-fw"></i> Over 7,000 app downloads and purchases
</div>
</div>
</div>
<div class="col-12 col-lg-4 mt-5 mt-lg-0">
<div class="h3 p-2 text-center font-weight-bold">Explore our apps</div>
<div class="text-center mb-3">
<a href="https://apps.odoo.com/apps/browse?repo_maintainer_id=119796" target="_blank">
<div class="text-black bg-warning shadow-sm rounded">
<i class="fa fa-compass fa-4x py-0"></i>
</div>
</a>
</div>
<div class="h3 p-2 text-center font-weight-bold">Watch and subscribe</div>
<div class="text-center">
<a href="https://www.youtube.com/channel/UCjHB3t-qc6SQmbgnS8bSPOA?sub_confirmation=1" target="_blank">
<div class="text-black bg-warning shadow-sm rounded">
<i class="fa fa-youtube-play fa-4x py-0"></i>
</div>
</a>
</div>
</div>
</div>
</section>
<section class="oe_container" style="font-family: 'Montserrat', 'Odoo Unicode Support Noto', sans-serif;">
<div class="row mt-5 mb-4 align-items-center">
<div class="col-4 text-left">Version: 16.0.1.0.0</div>
<div class="col-4 text-center">
<a class="btn btn-primary rounded" data-toggle="collapse" href="#changelog" role="button" aria-expanded="false" aria-controls="changelog" title="Click to view 'Changelog'">
<span><i class="fa fa-code-fork d-none d-sm-inline"></i> Changelog</span>
</a>
</div>
<div class="col-4 text-right" style="text-align: right;"><small>Module design is reserved</small><br/>Copyright &copy; <a href="https://garazd.biz/" target="_blank">Garazd Creation</a></div>
<div class="offset-sm-1 offset-md-2 col-sm-11 col-md-10">
<div class="collapse mt-5 ml-sm-3" id="changelog">
<ul class="list-unstyled">
<li class="media">
<i class="fa fa-code-fork fa-3x mr-3"></i>
<div class="media-body mb-3">
<div class="mt-0 mb-1"><span class="badge badge-dark">16.0.1.0.0</span> <span class="h5">2022-09-14</span></div>
<div>Migration from 15.0.</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</section>
<section class="oe_container" style="font-family: 'Montserrat','Odoo Unicode Support Noto',sans-serif;">
<div class="row py-3" style="border-top: 1px solid #fea621;" id="odoo-app-rating">
<div class="col d-flex justify-content-center text-center" style="color: #FEA621;">
<i class="fa fa-fw fa-thumbs-o-up display-1"></i>
<span class="my-auto mx-5 display-4">
<a href="https://apps.odoo.com/apps/modules/16.0/pos_user_restrict/#odoo-app-rating" class="btn btn-lg btn-warning text-white rounded">Rate the app</a>
- support us to do more!
</span>
<i class="fa fa-fw fa-angle-double-down display-1"></i>
</div>
</div>
</section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

View file

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

View file

@ -0,0 +1,30 @@
from odoo import Command
from odoo.tests.common import TransactionCase
from odoo.tests import tagged
from odoo.exceptions import AccessError
@tagged('post_install', '-at_install')
class TestPosUser(TransactionCase):
def setUp(self):
super(TestPosUser, self).setUp()
self.user_pos = self.env.ref('pos_user_restrict.user_pos')
self.user_demo = self.env.ref('base.user_demo')
self.user_admin = self.env.ref('base.user_demo')
self.pos_1 = self.env.ref('point_of_sale.pos_config_main')
self.pos_2 = self.env.ref('pos_user_restrict.pos_config_second')
def test_01_no_allowed_pos(self):
with self.assertRaises(AccessError):
self.pos_1.with_user(self.user_pos).read(['name'])
with self.assertRaises(AccessError):
self.pos_2.with_user(self.user_pos).read(['name'])
def test_02_pos_1_allowed(self):
self.user_pos.pos_config_ids = [Command.link(self.pos_1.id)]
# Check the access to POS 1
self.pos_1.with_user(self.user_pos).read(['name'])
# Check the access to POS 2
with self.assertRaises(AccessError):
self.pos_2.with_user(self.user_pos).read(['name'])

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_users_form" model="ir.ui.view">
<field name="name">res.users.form.inherit.pos.user.restrict</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<xpath expr="//page[@name='access_rights']/group" position="after">
<group string="Points of Sale" groups="point_of_sale.group_pos_user">
<field
name="pos_config_ids"
widget="many2many_tags"
/>
</group>
</xpath>
</field>
</record>
</odoo>