Skip to Content
āđ€āļĄāļ™āļđ
āļ„āļļāļ“āļ•āđ‰āļ­āļ‡āļĨāļ‡āļ—āļ°āđ€āļšāļĩāļĒāļ™āđ€āļžāļ·āđˆāļ­āđ‚āļ•āđ‰āļ•āļ­āļšāļāļąāļšāļ„āļ­āļĄāļĄāļđāļ™āļīāļ•āļĩāđ‰
āļ„āļģāļ–āļēāļĄāļ™āļĩāđ‰āļ–āļđāļāļ•āļąāđ‰āļ‡āļ„āđˆāļēāļŠāļ–āļēāļ™āļ°
1 āļ•āļ­āļšāļāļĨāļąāļš
658 āļĄāļļāļĄāļĄāļ­āļ‡

On my situation, i had add a new field in pos.order.line (it's 'selected_location_id')
class PosOrderLinesExtended(models.Model):

_inherit = 'pos.order.line'


selected_location_id = fields.Many2one('stock.location', string="POS Location")

@api.model

def _load_pos_data_fields(self, config_id):

data = super()._load_pos_data_fields(config_id)

print("dataaaa",data)

data += ['selected_location_id']

return data


def create(self, vals):

_logger.info("ðŸ“Ĩ pos.order.line vals nháš­n đưáŧĢc: %s", vals)

return super().create(vals)


In pos, i create a new Component to select stock location with some location have a field to checck select on pos,

patch(PosStore.prototype, {

async addLineToOrder(vals, order, opts = {}, configure = true) {

const location = await makeAwaitable(this.dialog, LocationPopup);

if (location) {

vals.selected_location_id = location.id;

}

const line = await super.addLineToOrder(vals, order, opts, configure);

line.selected_location_id = location?.id;

console.log("lineeeeeee",line)

return line;

}

});


but when i validate the posorder in pos, it not give back select a location to field  in pos.order.line

all of my module custom in this link:
https://github.com/IdalisNguyen/POS-Select-Location.git

Someone explain to me why I can't get the data from above pos to return to the variable below model?
Thanks you for your attention

āļ­āļ§āļ•āļēāļĢ
āļĨāļ°āļ—āļīāđ‰āļ‡
āļ„āļģāļ•āļ­āļšāļ—āļĩāđˆāļ”āļĩāļ—āļĩāđˆāļŠāļļāļ”

Hii,


Add this patch in your JS, for example in pos_select_location/static/src/js/pos_loader_patch.js:

import { PosGlobalState } from 'point_of_sale.models';

import { patch } from 'web.utils';


patch(PosGlobalState.prototype, {

    _loaderParams() {

        const params = super._loaderParams();

        if (!params.pos_order_line_fields.includes('selected_location_id')) {

            params.pos_order_line_fields.push('selected_location_id');

        }

        return params;

    },

});

This ensures selected_location_id is part of the order lines fields that are sent to backend.


Clear browser cache & upgrade module

./odoo-bin -u pos_select_location -d your_db


i hope it is use full

āļ­āļ§āļ•āļēāļĢ
āļĨāļ°āļ—āļīāđ‰āļ‡
Related Posts āļ•āļ­āļšāļāļĨāļąāļš āļĄāļļāļĄāļĄāļ­āļ‡ āļāļīāļˆāļāļĢāļĢāļĄ
1
āļŠ.āļ„. 25
180
0
āļž.āļĒ. 24
2051
0
āļ˜.āļ„. 22
2745
1
āļž.āļĒ. 24
2369
1
āļž.āļĒ. 24
2186