[FIX] point_of_sale: param for reconcile orders and payment
It has been argued that a regression took place because of e2efec8e54
Before that commit, everything was reconciled together
After, only payments and orders with a partner set were
While that commit improved performances (there are much less move lines to reconcile),
it introduced an inconvenience business wise because of the noise created
by the unreconciled lines
This commit proposes to cut the pear in half by introducing an ir parameter
to choose between the two options
OPW 1883594
closes #26971
This commit is contained in:
@@ -407,6 +407,12 @@ class PosOrder(models.Model):
|
||||
# for debugging and support purposes
|
||||
_logger.exception('Reconciliation did not work for order %s', order.name)
|
||||
|
||||
def _filtered_for_reconciliation(self):
|
||||
filter_states = ['invoiced', 'done']
|
||||
if self.env['ir.config_parameter'].get_param('point_of_sale.order_reconcile_mode', 'all') == 'partner_only':
|
||||
return self.filtered(lambda order: order.state in filter_states and order.partner_id)
|
||||
return self.filtered(lambda order: order.state in filter_states)
|
||||
|
||||
def _default_session(self):
|
||||
return self.env['pos.session'].search([('state', '=', 'opened'), ('user_id', '=', self.env.uid)], limit=1)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class PosSession(models.Model):
|
||||
if order.state not in ('paid'):
|
||||
raise UserError(_("You cannot confirm all orders of this session, because they have not the 'paid' status"))
|
||||
order.action_pos_order_done()
|
||||
orders_to_reconcile = session.order_ids.filtered(lambda order: order.state in ['invoiced', 'done'] and order.partner_id)
|
||||
orders_to_reconcile = session.order_ids._filtered_for_reconciliation()
|
||||
orders_to_reconcile.sudo()._reconcile_payments()
|
||||
|
||||
config_id = fields.Many2one(
|
||||
|
||||
Reference in New Issue
Block a user