ช่วยเหลือ

2

Default Customer on POS

Avatar
Néstor Gómez Muñoz

In a Point of Sale, by default appears 'Unknown Customer' as client name, so we click on that name, appears a list of customers and select the desired customer to finaly click on the Set Customer button. This is for each sale.

Do you know a way to preset a default customer, say 'Generic Client' avoiding having to select it each time?

I already try on pos.xml, but can only change the name whith out affecting the object.

Regards.

1 ความคิดเห็น
Avatar
Discard
Avatar
Néstor Gómez Muñoz
-

My solucion: Add a field x_default_client, on pos.config model and modified form view to add that field. There I can define which partner will be. On point_of_sale module, on static/src/js/models.js, I added the line this.set_default_client(order) on function 'add_new_order()' and defined that new function 'set_default_client(order)' where is searched the partner using x_default= order.pos.config.x_default_client and setting default_client = this.db.get_partner_by_id(x_default[0]) Some more code to validate and so.

4 Answers
1
Avatar
Emipro Technologies Pvt. Ltd.
Best Answer

One of the trick you can use from the backend to set the generic customer in every pos.order where customer is not set.

First, You need to create one "Generic Customer" through xml.

ie.

<record id="generic_res_partner" model="res.partner">

<field name="name">Generic Customer</field>

<field name="is_company">1</field>

<field name="email">generic@example.com</field>

</record>

Then inherit the pos.order model and change this method like below.

class PosOrder(models.Model):

     _inherit = 'pos.order'

    @api.model

    def _order_fields(self, ui_order):

        order_fields = super(PosOrder, self)._order_fields(ui_order)

        generic_customer = self.env.ref('module_name.generic_res_partner').id

        order_fields['partner_id'] = ui_order.get('partner_id', False) or generic_customer

        return order_fields

 


Avatar
Discard
0
Avatar
Dhivya
Best Answer

Hi, please check this OCA module  https://www.odoo.com/apps/modules/12.0/skit_walkin_customer/  
Hope this help you. 

Avatar
Discard
0
Avatar
Arafat Ali
Best Answer

Hi, is there a way to achieve this in Odoo 11 ?

Avatar
Discard
0
Avatar
Jairo Quezada
Best Answer

Good evening, I'm using Odoo 8 and I would like to facilitate me the code of the solution to establish a customer default at the point of sale .Thank you

3 ความคิดเห็น
Avatar
Discard
Avatar
Néstor Gómez Muñoz
-

--Excerpt from OCB/addons/point_of_sale/static/src/js/models.js, with aproximated line numbers: 460 //creates a new empty order and sets it as the current order 461 add_new_order: function(){ 462 var order = new module.Order({pos:this}); 463 this.get('orders').add(order); 464 this.set('selectedOrder', order); 465 this.set_default_client(order); 466 }, 467 468 // set default client from pos.config 469 set_default_client: function(order) { 470 var default_client; 471 var x_default = order.pos.config.x_default_client; 472 var client_id; 473 if (x_default) { 474 client_id=parseInt(x_default[0]); 475 } 476 default_client = this.db.get_partner_by_id(client_id); 477 if (default_client) { 478 order.set_client(default_client); 479 } 480 },

Avatar
Jairo Quezada
-

Thanks for the help. Very thoughtful of you. Now I'm trying to enable the physical taclado with the post, trying to jquery.hotkeys.js, any ideas for a case? Yelizariev POS_Keyboard module only enables the keypad.

Avatar
Daniel Holden
-

Olá Néstor, I've attempted to follow your instructions to set a default customer for each of my three POS. I managed to create a new field x_default_client and checked that it in fact exists using pgAdmin, I successfully added the field to the form view pos.config and I also added the code to C:\Program Files (x86)\Odoo 8.0-20150511\server\openerp\addons\point_of_sale\static\src\js\models.js However, I have created a client called "Indiferenciado" that has partner_id=30 and I set the x_default_client to 30 on all Points of sale, but they still default to "Unknown Customer" when I open a POS session. What might I be doing wrong?