[FIX] point_of_sale: pos order to invoice wrong value
When a pos order is sent to the server, the field 'to_invoice' is never sent to the server which lead to always having a value to 'false'. We are now sending correctly this value to the server, and we can also base the fact to create an invoice on the value of each order. Because beeing offline could lead to create an order that should be invoiced as one that should not be. closes odoo/odoo#39880 X-original-commit: c8d5b4a0cfc070c05c3f86ae6cc2b7395532c353 Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
This commit is contained in:
@@ -112,7 +112,6 @@ class PosOrder(models.Model):
|
||||
:type existing_order: pos.order.
|
||||
:returns number pos_order id
|
||||
"""
|
||||
to_invoice = order['to_invoice'] if not draft else False
|
||||
order = order['data']
|
||||
pos_session = self.env['pos.session'].browse(order['pos_session_id'])
|
||||
if pos_session.state == 'closing_control' or pos_session.state == 'closed':
|
||||
@@ -138,7 +137,7 @@ class PosOrder(models.Model):
|
||||
except Exception as e:
|
||||
_logger.error('Could not fully process the POS Order: %s', tools.ustr(e))
|
||||
|
||||
if to_invoice:
|
||||
if pos_order.to_invoice and pos_order.state == 'paid':
|
||||
pos_order.action_pos_order_invoice()
|
||||
pos_order.account_move.sudo().with_context(force_company=self.env.user.company_id.id).post()
|
||||
|
||||
|
||||
@@ -2402,6 +2402,7 @@ exports.Order = Backbone.Model.extend({
|
||||
creation_date: this.validation_date || this.creation_date, // todo: rename creation_date in master
|
||||
fiscal_position_id: this.fiscal_position ? this.fiscal_position.id : false,
|
||||
server_id: this.server_id ? this.server_id : false,
|
||||
to_invoice: this.to_invoice ? this.to_invoice : false,
|
||||
};
|
||||
if (!this.is_paid && this.user_id) {
|
||||
json.user_id = this.user_id;
|
||||
|
||||
@@ -389,6 +389,7 @@ class TestPoSCommon(TransactionCase):
|
||||
'statement_ids': payments,
|
||||
'uid': uid,
|
||||
'user_id': self.pos_manager.id,
|
||||
'to_invoice': is_invoiced,
|
||||
},
|
||||
'id': uid,
|
||||
'to_invoice': is_invoiced,
|
||||
|
||||
Reference in New Issue
Block a user