Skip to content

Commit

Permalink
[IMP] make sale confirm optional
Browse files Browse the repository at this point in the history
  • Loading branch information
bealdav committed Feb 19, 2016
1 parent 342587f commit 62557ae
Showing 1 changed file with 22 additions and 34 deletions.
56 changes: 22 additions & 34 deletions pos_sale_order/point_of_sale.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# POS To Sale Order module for Odoo
# Copyright (C) 2014 AKRETION (<http://www.akretion.com>).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# coding: utf-8
# © 2016 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

import time

Expand All @@ -43,6 +26,12 @@ class SaleOrder(models.Model):
readonly=True)
payment_ids = fields.Many2many(readonly=True)

@api.multi
def confirm_sale_from_pos(self):
" Make sale confirmation optional "
self.ensure_one()
return True


class PosOrder(models.Model):
_inherit = 'pos.order'
Expand Down Expand Up @@ -135,24 +124,22 @@ def create_from_ui(self, orders):
order.id,
self._payment_fields(payments[2]),
)

session = self.env['pos.session'].browse(
ui_order['pos_session_id'])
if session.sequence_number <= ui_order['sequence_number']:
session.write(
{'sequence_number': ui_order['sequence_number'] + 1})
session.refresh()

order.signal_workflow('order_confirm')

if to_invoice:
invoice_obj = self.env['account.invoice']
invoice = invoice_obj.browse(order.invoice_ids.id)
order.signal_workflow('manual_invoice')
invoice.signal_workflow('invoice_open')
invoice.write({'sale_ids': [(6, 0, [order.id])]})

order_ids.append(order.id)
if order.confirm_sale_from_pos():
order.signal_workflow('order_confirm')
if to_invoice:
invoice_obj = self.env['account.invoice']
invoice = invoice_obj.browse(order.invoice_ids.id)
order.signal_workflow('manual_invoice')
invoice.signal_workflow('invoice_open')
invoice.write({'sale_ids': [(6, 0, [order.id])]})
order_ids.append(order.id)

return order_ids

Expand All @@ -172,9 +159,10 @@ def _prepare_payment_vals(self, order_id, data):
account_def = property_obj.get('property_account_receivable',
'res.partner')
args['account_id'] = ((
order.partner_id and order.partner_id.property_account_receivable
and order.partner_id.property_account_receivable.id)
or (account_def and account_def.id) or False)
order.partner_id and
order.partner_id.property_account_receivable and
order.partner_id.property_account_receivable.id) or
(account_def and account_def.id) or False)

if not args['account_id']:
if not args['partner_id']:
Expand Down

0 comments on commit 62557ae

Please sign in to comment.