[FIX] point_of_sale: create picking when invoicing after completing order.

in version 14, if you have anglo-saxon accounting and are posting inventory at the end of the session, and create a PoS order without invoicing it, then leave the session without closing and validating,
and open said order and invoice it outside the session, picking for said order will not be created. So, once the session is closed and validated, there will be an invoiced order without any picking in it.
After this commit Odoo will check if order that is being invoiced already has picking order, and if not, will create one for it.

OPW-2725930

closes odoo/odoo#83787

X-original-commit: 894dfa892c92d55ce9897193b4016a5e1f40858d
Signed-off-by: Masereel Pierre <pim@odoo.com>
This commit is contained in:
Andro Gvivradze
2022-02-01 18:07:11 +00:00
parent 19a079df4c
commit 3f5fd479e8
+8 -2
View File
@@ -146,7 +146,7 @@ class PosOrder(models.Model):
pos_order._compute_total_cost_in_real_time()
if pos_order.to_invoice and pos_order.state == 'paid':
pos_order.action_pos_order_invoice()
pos_order._generate_pos_order_invoice()
return pos_order.id
@@ -610,8 +610,14 @@ class PosOrder(models.Model):
if self.note:
vals.update({'narration': self.note})
return vals
def action_pos_order_invoice(self):
self.write({'to_invoice': True})
res = self._generate_pos_order_invoice()
if self.company_id.anglo_saxon_accounting and self.session_id.update_stock_at_closing:
self._create_order_picking()
return res
def _generate_pos_order_invoice(self):
moves = self.env['account.move']
for order in self: