Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1884 Widoki

I wanted to show a floor name on the POS receipt odoo 16 through custom module under the Served by. what will be the code.

i added this in py file


class PosOrder(models.Model):
"""To write the product addons to backend """
_inherit = 'pos.order'

floor_name = fields.Many2one('restaurant.floor', string='Floor')

@api.model
def _order_fields(self, ui_order):
res = super(PosOrder, self)._order_fields(ui_order)
res['floor_name'] = ui_order.get('floor_name', False)
return res

this in js file

	​/** @odoo-module */
import Registries from 'point_of_sale.Registries';
import {Order, Orderline, PosGlobalState } from 'point_of_sale.models';
import utils from 'web.utils';
var round_pr = utils.round_precision;

const PosAddonsOrderline = (Orderline) =>
class PosSaleOrderline extends Orderline {
​get_floor_name() {
const selectedTable = this.pos.tables_by_id[this.table_id];
const selectedFloor = selectedTable ? this.pos.floors_by_id[selectedTable.floor_name[0]] : null;
return selectedFloor ? { id: selectedFloor.id, name: selectedFloor.name } : null;
}
export_for_printing() {
var a = {
​floor_name: this.get_floor_name(),
​};
​return a
}
Registries.Model.extend(Orderline, PosAddonsOrderline);

this is my xml




floor :




and getting this error.
column pos_order.floor_name does not exist LINE 1: ...ges", "pos_order"."crm_team_id" AS "crm_team_id", "pos_order...

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,

To display the floor name on the POS receipt, extend the Orderline from point_of_sale and include the floor name in the export_for_printing method. Check if the order has a table assigned, and if so, include the floor name in the exported data.

JS:
/** @odoo-module */
import { Orderline } from 'point_of_sale.models';
import Registries from 'point_of_sale.Registries';

const CustomOrderlines = (Orderline) => class CustomOrderlines extends Orderline {
    export_for_printing() {
var result = super.export_for_printing(...arguments);
result.floor_name = this.pos.config.iface_floorplan ? this.order.getTable().floor.name : false;
return result;
    }
}
Registries.Model.extend(Orderline, CustomOrderlines)

Inherit the OrderLinesReceipts template, then find the appropriate place to insert floor_name. Add a condition to check if the floor_name exists and display it on the receipt if it does.

XML:
<t t-name="OrderLinesReceipts" t-inherit="point_of_sale.OrderLinesReceipt"
   t-inherit-mode="extension" owl="1">
    <xpath expr="//t[@t-foreach='receipt.orderlines']" position="inside">
            <div class="responsive-price">
                    <t t-if="line.floor_name">
                        <span><t t-esc="line.floor_name"/></span>
                    </t>
            </div>
        <br/>
    </xpath>
</t>


Hope it helps

Awatar
Odrzuć
Autor

i tried this but it didnt let the pos open.
and can you please tell me how to hide the company name at the top under the logo.

<xpath expr="//t[@t-esc='receipt.company.name']" position="replace">
</xpath>

Powiązane posty Odpowiedzi Widoki Czynność
1
paź 24
1268
1
sie 24
997
0
sie 24
1456
1
kwi 23
3612
0
sty 16
4244