|
@@ -185,8 +185,56 @@ class EiruPOS(models.Model):
|
|
|
|
|
|
return customers
|
|
|
|
|
|
- def create_order(self):
|
|
|
- print 'ok'
|
|
|
+ @api.model
|
|
|
+ def process_pos_order(self, cart_items, customer_id):
|
|
|
+ order_line_values = []
|
|
|
+ for item in cart_items:
|
|
|
+ order_line_values.append([0, False, {
|
|
|
+ 'product_id': int(item['id']),
|
|
|
+ 'product_uom_qty': float(item['qty']),
|
|
|
+ 'price_unit': float(item['list_price']),
|
|
|
+ 'discount': 0
|
|
|
+ }])
|
|
|
+
|
|
|
+ order_values = {
|
|
|
+ 'partner_id': customer_id,
|
|
|
+ 'partner_invoice_id': customer_id,
|
|
|
+ 'partner_shipping_id': customer_id,
|
|
|
+ 'order_line': order_line_values,
|
|
|
+ 'picking_policy': 'direct',
|
|
|
+ 'order_policy': 'manual'
|
|
|
+ }
|
|
|
+
|
|
|
+ order = self.env['sale.order'].create(order_values)
|
|
|
+
|
|
|
+ # Process order now
|
|
|
+ order.action_button_confirm()
|
|
|
+ invoice_id = order.action_invoice_create()
|
|
|
+ invoice = {}
|
|
|
+
|
|
|
+ if invoice_id:
|
|
|
+ invoice = self.env['account.invoice'].browse(invoice_id)
|
|
|
+ invoice.signal_workflow('invoice_open')
|
|
|
+
|
|
|
+ for picking in order.picking_ids:
|
|
|
+ picking.force_assign()
|
|
|
+ picking.action_done()
|
|
|
+
|
|
|
+ dummy, view_id = self.env['ir.model.data'].get_object_reference('account_voucher', 'view_vendor_receipt_dialog_form')
|
|
|
+
|
|
|
+ return {
|
|
|
+ 'id': invoice.id,
|
|
|
+ 'view_id': view_id,
|
|
|
+ 'name': invoice.name,
|
|
|
+ 'display_name': invoice.display_name,
|
|
|
+ 'currency_id': invoice.currency_id.id,
|
|
|
+ 'partner_account_id': self.env['res.partner']._find_accounting_partner(invoice.partner_id).id,
|
|
|
+ 'amount': invoice.type in ('out_refund', 'in_refund') and -invoice.residual or invoice.residual,
|
|
|
+ 'reference': invoice.name,
|
|
|
+ 'invoice_type': invoice.type,
|
|
|
+ 'default_type': invoice.type in ('out_invoice', 'out_refund') and 'receipt' or 'payment',
|
|
|
+ 'type': invoice.type in ('out_invoice','out_refund') and 'receipt' or 'payment'
|
|
|
+ } if invoice_id else {}
|
|
|
|
|
|
|
|
|
class eiru_pos_session(models.Model):
|