[IMP] point_of_sale: Show customer only and increase customer ranking.
Following the removing of the vendor and customer field, when we wanted to display customer in the back end, we saw all. We added a default filter when clicking on the menu button that displays only customer with a customer rank higher than 0. We also increase their customer ranks everytime they make an order in the front end. closes odoo/odoo#41769 Task-id: 2092483 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
@@ -366,6 +366,21 @@ class PosOrder(models.Model):
|
||||
raise UserError(_("Order %s is not fully paid.") % self.name)
|
||||
|
||||
self.write({'state': 'paid'})
|
||||
|
||||
if self.partner_id:
|
||||
try:
|
||||
with self.env.cr.savepoint():
|
||||
self.env.cr.execute("SELECT 'customer_rank' FROM res_partner WHERE ID=%s FOR UPDATE NOWAIT",
|
||||
(self.partner_id.id,))
|
||||
self.env.cr.execute("UPDATE res_partner SET customer_rank = customer_rank +1 WHERE ID=%s",
|
||||
(self.partner_id.id,))
|
||||
self.env.cache.remove(self.partner_id, self.partner_id._fields['customer_rank'])
|
||||
except psycopg2.DatabaseError as e:
|
||||
if e.pgcode == '55P03':
|
||||
_logger.debug('Another transaction already locked partner rows. Cannot update partner ranks.')
|
||||
else:
|
||||
raise e
|
||||
|
||||
return True
|
||||
|
||||
def action_pos_order_invoice(self):
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<menuitem id="menu_point_of_sale_customer"
|
||||
name="Customers"
|
||||
parent="menu_point_of_sale"
|
||||
action="base.action_partner_customer_form"
|
||||
action="account.res_partner_action_customer"
|
||||
sequence="100"/>
|
||||
|
||||
<!-- Reporting menu -->
|
||||
|
||||
Reference in New Issue
Block a user