Browse Source

Merge PR #441 into 12.0

Signed-off-by legalsylvain
pull/516/head
OCA-git-bot 4 years ago
parent
commit
f0b0147019
  1. 8
      pos_order_to_sale_order/README.rst
  2. 1
      pos_order_to_sale_order/__init__.py
  3. 20
      pos_order_to_sale_order/__manifest__.py
  4. 164
      pos_order_to_sale_order/i18n/fr.po
  5. 156
      pos_order_to_sale_order/i18n/pos_order_to_sale_order.pot
  6. 3
      pos_order_to_sale_order/models/__init__.py
  7. 50
      pos_order_to_sale_order/models/pos_config.py
  8. 62
      pos_order_to_sale_order/models/sale_order.py
  9. 23
      pos_order_to_sale_order/models/sale_order_line.py
  10. 6
      pos_order_to_sale_order/readme/CONFIGURE.rst
  11. 1
      pos_order_to_sale_order/readme/CONTRIBUTORS.rst
  12. 22
      pos_order_to_sale_order/readme/DESCRIPTION.rst
  13. 23
      pos_order_to_sale_order/readme/USAGE.rst
  14. BIN
      pos_order_to_sale_order/static/description/icon.png
  15. 496
      pos_order_to_sale_order/static/description/index.html
  16. BIN
      pos_order_to_sale_order/static/description/pos_config_form.png
  17. BIN
      pos_order_to_sale_order/static/description/pos_frontend_buttons.png
  18. BIN
      pos_order_to_sale_order/static/description/pos_frontend_order.png
  19. 161
      pos_order_to_sale_order/static/src/js/screens.js
  20. 37
      pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml
  21. 11
      pos_order_to_sale_order/views/assets.xml
  22. 43
      pos_order_to_sale_order/views/view_pos_config.xml

8
pos_order_to_sale_order/README.rst

@ -0,0 +1,8 @@
=======================
PoS Order To Sale Order
=======================
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

1
pos_order_to_sale_order/__init__.py

@ -0,0 +1 @@
from . import models

20
pos_order_to_sale_order/__manifest__.py

@ -0,0 +1,20 @@
# Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "PoS Order To Sale Order",
"version": "12.0.1.0.0",
"author": "GRAP,Odoo Community Association (OCA)",
"category": "Point Of Sale",
"license": "AGPL-3",
"depends": ["point_of_sale"],
"maintainers": ["legalsylvain"],
"development_status": "Production/Stable",
"website": "https://github.com/OCA/pos",
"data": [
"views/view_pos_config.xml",
"views/assets.xml",
],
"qweb": ["static/src/xml/pos_order_to_sale_order.xml"],
}

164
pos_order_to_sale_order/i18n/fr.po

@ -0,0 +1,164 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_order_to_sale_order
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-19 23:40+0000\n"
"PO-Revision-Date: 2020-01-19 23:40+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:15
#, python-format
msgid "Back"
msgstr "Retour"
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:148
#, python-format
msgid "Check your internet connection and try again."
msgstr "Veuillez vérifier votre connexion internet et essayer de nouveau."
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:26
#, python-format
msgid "Create Confirmed Sale Order"
msgstr "Créer une vente confirmée"
#. module: pos_order_to_sale_order
#: model:ir.model.fields,field_description:pos_order_to_sale_order.field_pos_config__iface_create_confirmed_sale_order
msgid "Create Confirmed Sale Orders"
msgstr "Créer des ventes confirmées"
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:29
#, python-format
msgid "Create Delivered Sale Order"
msgstr "Créer une vente livrée"
#. module: pos_order_to_sale_order
#: model:ir.model.fields,field_description:pos_order_to_sale_order.field_pos_config__iface_create_delivered_sale_order
msgid "Create Delivered Sale Orders"
msgstr "Créer des ventes livrées"
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:23
#, python-format
msgid "Create Draft Sale Order"
msgstr "Créer un devis"
#. module: pos_order_to_sale_order
#: model:ir.model.fields,field_description:pos_order_to_sale_order.field_pos_config__iface_create_draft_sale_order
msgid "Create Draft Sale Orders"
msgstr "Créer des devis"
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:6
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:18
#, python-format
msgid "Create Sale Order"
msgstr "Créer une vente"
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:100
#, python-format
msgid "Create Sale Order and discard the current PoS Order?"
msgstr "Créer une vente, et supprimer le ticket de caisse en cours ?"
#. module: pos_order_to_sale_order
#: model:ir.model.fields,field_description:pos_order_to_sale_order.field_pos_config__iface_create_sale_order
msgid "Create Sale Orders"
msgstr "Créer des ventes"
#. module: pos_order_to_sale_order
#: model:ir.model.fields,help:pos_order_to_sale_order.field_pos_config__iface_create_confirmed_sale_order
msgid "If checked, the cashier will have the possibility to create a confirmed Sale Order, based on the current draft PoS Order."
msgstr "En cochant la case, le caissier aura la possibilité de créer une vente confirmée, à partir du ticket de caisse en cours."
#. module: pos_order_to_sale_order
#: model:ir.model.fields,help:pos_order_to_sale_order.field_pos_config__iface_create_delivered_sale_order
msgid "If checked, the cashier will have the possibility to create a confirmed sale Order, based on the current draft PoS Order.\n"
" the according picking will be marked as delivered. Only invoices process will be possible."
msgstr ""
"En cochant la case, le caissier aura la possibilité de créer une vente "
"confirmée, à partir du ticket de caisse en cours.\n"
" Le bon de livraison correspondant sera marqué comme livré. Seul le "
"processus de facturation sera possible."
#. module: pos_order_to_sale_order
#: model:ir.model.fields,help:pos_order_to_sale_order.field_pos_config__iface_create_draft_sale_order
msgid "If checked, the cashier will have the possibility to create a draft Sale Order, based on the current draft PoS Order."
msgstr ""
"En cochant la case, le caissier aura la possibilité de créer une vente en "
"brouillon, à partir du ticket de caisse en cours."
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:29
#, python-format
msgid "No customer defined"
msgstr "Pas de client défini"
#. module: pos_order_to_sale_order
#: code:addons/pos_order_to_sale_order/models/sale_order.py:17
#, python-format
msgid "Point of Sale %s"
msgstr "Point de vente %s"
#. module: pos_order_to_sale_order
#: model:ir.model,name:pos_order_to_sale_order.model_pos_config
msgid "Point of Sale Configuration"
msgstr "Paramétrage du point de vente"
#. module: pos_order_to_sale_order
#: model:ir.model,name:pos_order_to_sale_order.model_sale_order
msgid "Sale Order"
msgstr "Bon de commande"
#. module: pos_order_to_sale_order
#: model_terms:ir.ui.view,arch_db:pos_order_to_sale_order.view_pos_config_form
msgid "Sale Order Creations"
msgstr "Créations de Vente"
#. module: pos_order_to_sale_order
#: model:ir.model,name:pos_order_to_sale_order.model_sale_order_line
msgid "Sales Order Line"
msgstr "Ligne de bons de commande"
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:147
#, python-format
msgid "The order could not be sent"
msgstr "La commande n'a pas pu être envoyée"
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:103
#, python-format
msgid "This operation will permanently discard the current PoS Order and create a Sale Order, based on the current order lines."
msgstr ""
"Cette opération va supprimer définitivement le ticket de caisse en cours, et "
"créer une vente, en se basant sur les lignes du ticket en cours."
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:30
#, python-format
msgid "You should select a customer in order to create a Sale Order."
msgstr "Vous devez sélectionner un client, afin de créer une vente."

156
pos_order_to_sale_order/i18n/pos_order_to_sale_order.pot

@ -0,0 +1,156 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_order_to_sale_order
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-01-19 23:45+0000\n"
"PO-Revision-Date: 2020-01-19 23:45+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:15
#, python-format
msgid "Back"
msgstr ""
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:148
#, python-format
msgid "Check your internet connection and try again."
msgstr ""
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:26
#, python-format
msgid "Create Confirmed Sale Order"
msgstr ""
#. module: pos_order_to_sale_order
#: model:ir.model.fields,field_description:pos_order_to_sale_order.field_pos_config__iface_create_confirmed_sale_order
msgid "Create Confirmed Sale Orders"
msgstr ""
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:29
#, python-format
msgid "Create Delivered Sale Order"
msgstr ""
#. module: pos_order_to_sale_order
#: model:ir.model.fields,field_description:pos_order_to_sale_order.field_pos_config__iface_create_delivered_sale_order
msgid "Create Delivered Sale Orders"
msgstr ""
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:23
#, python-format
msgid "Create Draft Sale Order"
msgstr ""
#. module: pos_order_to_sale_order
#: model:ir.model.fields,field_description:pos_order_to_sale_order.field_pos_config__iface_create_draft_sale_order
msgid "Create Draft Sale Orders"
msgstr ""
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:6
#: code:addons/pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml:18
#, python-format
msgid "Create Sale Order"
msgstr ""
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:100
#, python-format
msgid "Create Sale Order and discard the current PoS Order?"
msgstr ""
#. module: pos_order_to_sale_order
#: model:ir.model.fields,field_description:pos_order_to_sale_order.field_pos_config__iface_create_sale_order
msgid "Create Sale Orders"
msgstr ""
#. module: pos_order_to_sale_order
#: model:ir.model.fields,help:pos_order_to_sale_order.field_pos_config__iface_create_confirmed_sale_order
msgid "If checked, the cashier will have the possibility to create a confirmed Sale Order, based on the current draft PoS Order."
msgstr ""
#. module: pos_order_to_sale_order
#: model:ir.model.fields,help:pos_order_to_sale_order.field_pos_config__iface_create_delivered_sale_order
msgid "If checked, the cashier will have the possibility to create a confirmed sale Order, based on the current draft PoS Order.\n"
" the according picking will be marked as delivered. Only invoices process will be possible."
msgstr ""
#. module: pos_order_to_sale_order
#: model:ir.model.fields,help:pos_order_to_sale_order.field_pos_config__iface_create_draft_sale_order
msgid "If checked, the cashier will have the possibility to create a draft Sale Order, based on the current draft PoS Order."
msgstr ""
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:29
#, python-format
msgid "No customer defined"
msgstr ""
#. module: pos_order_to_sale_order
#: code:addons/pos_order_to_sale_order/models/sale_order.py:17
#, python-format
msgid "Point of Sale %s"
msgstr ""
#. module: pos_order_to_sale_order
#: model:ir.model,name:pos_order_to_sale_order.model_pos_config
msgid "Point of Sale Configuration"
msgstr ""
#. module: pos_order_to_sale_order
#: model:ir.model,name:pos_order_to_sale_order.model_sale_order
msgid "Sale Order"
msgstr ""
#. module: pos_order_to_sale_order
#: model_terms:ir.ui.view,arch_db:pos_order_to_sale_order.view_pos_config_form
msgid "Sale Order Creations"
msgstr ""
#. module: pos_order_to_sale_order
#: model:ir.model,name:pos_order_to_sale_order.model_sale_order_line
msgid "Sales Order Line"
msgstr ""
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:147
#, python-format
msgid "The order could not be sent"
msgstr ""
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:103
#, python-format
msgid "This operation will permanently discard the current PoS Order and create a Sale Order, based on the current order lines."
msgstr ""
#. module: pos_order_to_sale_order
#. openerp-web
#: code:addons/pos_order_to_sale_order/static/src/js/screens.js:30
#, python-format
msgid "You should select a customer in order to create a Sale Order."
msgstr ""

3
pos_order_to_sale_order/models/__init__.py

@ -0,0 +1,3 @@
from . import sale_order
from . import sale_order_line
from . import pos_config

50
pos_order_to_sale_order/models/pos_config.py

@ -0,0 +1,50 @@
# Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, fields, models
class PosConfig(models.Model):
_inherit = "pos.config"
iface_create_sale_order = fields.Boolean(
string="Create Sale Orders",
compute="_compute_iface_create_sale_order",
store=True)
iface_create_draft_sale_order = fields.Boolean(
string="Create Draft Sale Orders",
default=True,
help="If checked, the cashier will have the possibility to create"
" a draft Sale Order, based on the current draft PoS Order.",
)
iface_create_confirmed_sale_order = fields.Boolean(
string="Create Confirmed Sale Orders",
default=True,
help="If checked, the cashier will have the possibility to create"
" a confirmed Sale Order, based on the current draft PoS Order.",
)
iface_create_delivered_sale_order = fields.Boolean(
string="Create Delivered Sale Orders",
default=True,
help="If checked, the cashier will have the possibility to create"
" a confirmed sale Order, based on the current draft PoS Order.\n"
" the according picking will be marked as delivered. Only invoices"
" process will be possible.",
)
@api.depends(
"iface_create_draft_sale_order",
"iface_create_confirmed_sale_order",
"iface_create_delivered_sale_order",
)
def _compute_iface_create_sale_order(self):
for config in self:
config.iface_create_sale_order = any([
config.iface_create_draft_sale_order,
config.iface_create_confirmed_sale_order,
config.iface_create_delivered_sale_order,
])

62
pos_order_to_sale_order/models/sale_order.py

@ -0,0 +1,62 @@
# Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, models
class SaleOrder(models.Model):
_inherit = "sale.order"
@api.model
def _prepare_from_pos(self, order_data):
PosSession = self.env["pos.session"]
session = PosSession.browse(order_data["pos_session_id"])
return {
"partner_id": order_data["partner_id"],
"origin": _("Point of Sale %s") % (session.name),
"client_order_ref": order_data["name"],
"user_id": order_data["user_id"],
"pricelist_id": order_data["pricelist_id"],
"fiscal_position_id": order_data["fiscal_position_id"],
}
@api.model
def create_order_from_pos(self, order_data, action):
SaleOrderLine = self.env["sale.order.line"]
# Create Draft Sale order
order_vals = self._prepare_from_pos(order_data)
sale_order = self.create(order_vals.copy())
sale_order.onchange_partner_id()
# we rewrite data, because onchange could alter some
# custom data (like pricelist)
sale_order.write(order_vals)
# create Sale order lines
for order_line_data in order_data["lines"]:
# Create Sale order lines
order_line_vals = SaleOrderLine._prepare_from_pos(
sale_order, order_line_data[2])
sale_order_line = SaleOrderLine.create(
order_line_vals.copy())
sale_order_line.product_id_change()
# we rewrite data, because onchange could alter some
# data (like quantity, or price)
sale_order_line.write(order_line_vals)
# Confirm Sale Order
if action in ["confirmed", "delivered"]:
sale_order.action_confirm()
# mark picking as delivered
if action == "delivered":
# Mark all moves are delivered
for move in sale_order.mapped(
"picking_ids.move_ids_without_package"):
move.quantity_done = move.product_uom_qty
sale_order.mapped("picking_ids").button_validate()
return {
"sale_order_id": sale_order.id,
}

23
pos_order_to_sale_order/models/sale_order_line.py

@ -0,0 +1,23 @@
# Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
@api.model
def _prepare_from_pos(self, sale_order, order_line_data):
ProductProduct = self.env["product.product"]
product = ProductProduct.browse(order_line_data["product_id"])
return {
"order_id": sale_order.id,
"product_id": order_line_data["product_id"],
"name": product.name,
"product_uom_qty": order_line_data["qty"],
"discount": order_line_data["discount"],
"price_unit": order_line_data["price_unit"],
"tax_id": order_line_data["tax_ids"],
}

6
pos_order_to_sale_order/readme/CONFIGURE.rst

@ -0,0 +1,6 @@
* Go to Point Of Sale / Configuration / Point of Sale
* Check the box 'Create Sale Orders'
* Select the desired default behaviour
.. figure:: ../static/description/pos_config_form.png
:width: 800 px

1
pos_order_to_sale_order/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Sylvain LE GAL (https://www.twitter.com/legalsylvain)

22
pos_order_to_sale_order/readme/DESCRIPTION.rst

@ -0,0 +1,22 @@
This module extends the functionality of point of sale to allow sale orders
creation from the Point of Sale.
In the POS UI, button has been added to create a sale order and discard
the current POS order.
This module is usefull in many cases, for exemple :
* take orders with a very simple interface
* if you have some customers that come every day in your shop, but want to
have a unique invoice at the end of the month. With that module, you can
create a sale order and deliver products every time to keep your stock value
correct, and to create a unique invoice, when you want.
**Technical Notes**
* Some hooks are defined in the JS file, to define custom behaviour after
having created the sale order.
* Some prepare functions are available in the ``sale.order`` model and
``sale.order.line`` models to overload the creation of the sale order.

23
pos_order_to_sale_order/readme/USAGE.rst

@ -0,0 +1,23 @@
* Open your Point of sale
* create a new order and select products
* select a customer
* then, click on the "Create Sale Order" button
.. figure:: ../static/description/pos_frontend_order.png
:width: 800 px
Three options are available:
* **Create a draft Order**
A new sale order in a draft mode will be created that can be changed later.
* **Create a Confirmed Order**
A new sale order will be created and confirmed.
* **Create Delivered Picking** (by default)
A new sale order will be created and confirmed. the associated picking
will be marked as delivered.
.. figure:: ../static/description/pos_frontend_buttons.png
:width: 800 px

BIN
pos_order_to_sale_order/static/description/icon.png

After

Width: 180  |  Height: 180  |  Size: 19 KiB

496
pos_order_to_sale_order/static/description/index.html

@ -0,0 +1,496 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
<title>PoS Order To Sale Order</title>
<style type="text/css">
/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/
/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
border: 0 }
table.borderless td, table.borderless th {
/* Override padding for "table.docutils td" with "! important".
The right padding separates the table cells. */
padding: 0 0.5em 0 0 ! important }
.first {
/* Override more specific margin styles with "! important". */
margin-top: 0 ! important }
.last, .with-subtitle {
margin-bottom: 0 ! important }
.hidden {
display: none }
.subscript {
vertical-align: sub;
font-size: smaller }
.superscript {
vertical-align: super;
font-size: smaller }
a.toc-backref {
text-decoration: none ;
color: black }
blockquote.epigraph {
margin: 2em 5em ; }
dl.docutils dd {
margin-bottom: 0.5em }
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
overflow: hidden;
}
/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
font-weight: bold }
*/
div.abstract {
margin: 2em 5em }
div.abstract p.topic-title {
font-weight: bold ;
text-align: center }
div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
margin: 2em ;
border: medium outset ;
padding: 1em }
div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
font-weight: bold ;
font-family: sans-serif }
div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
color: red ;
font-weight: bold ;
font-family: sans-serif }
/* Uncomment (and remove this text!) to get reduced vertical space in
compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
margin-bottom: 0.5em }
div.compound .compound-last, div.compound .compound-middle {
margin-top: 0.5em }
*/
div.dedication {
margin: 2em 5em ;
text-align: center ;
font-style: italic }
div.dedication p.topic-title {
font-weight: bold ;
font-style: normal }
div.figure {
margin-left: 2em ;
margin-right: 2em }
div.footer, div.header {
clear: both;
font-size: smaller }
div.line-block {
display: block ;
margin-top: 1em ;
margin-bottom: 1em }
div.line-block div.line-block {
margin-top: 0 ;
margin-bottom: 0 ;
margin-left: 1.5em }
div.sidebar {
margin: 0 0 0.5em 1em ;
border: medium outset ;
padding: 1em ;
background-color: #ffffee ;
width: 40% ;
float: right ;
clear: right }
div.sidebar p.rubric {
font-family: sans-serif ;
font-size: medium }
div.system-messages {
margin: 5em }
div.system-messages h1 {
color: red }
div.system-message {
border: medium outset ;
padding: 1em }
div.system-message p.system-message-title {
color: red ;
font-weight: bold }
div.topic {
margin: 2em }
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
margin-top: 0.4em }
h1.title {
text-align: center }
h2.subtitle {
text-align: center }
hr.docutils {
width: 75% }
img.align-left, .figure.align-left, object.align-left, table.align-left {
clear: left ;
float: left ;
margin-right: 1em }
img.align-right, .figure.align-right, object.align-right, table.align-right {
clear: right ;
float: right ;
margin-left: 1em }
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
table.align-center {
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left }
.align-center {
clear: both ;
text-align: center }
.align-right {
text-align: right }
/* reset inner alignment in figures */
div.align-right {
text-align: inherit }
/* div.align-center * { */
/* text-align: left } */
.align-top {
vertical-align: top }
.align-middle {
vertical-align: middle }
.align-bottom {
vertical-align: bottom }
ol.simple, ul.simple {
margin-bottom: 1em }
ol.arabic {
list-style: decimal }
ol.loweralpha {
list-style: lower-alpha }
ol.upperalpha {
list-style: upper-alpha }
ol.lowerroman {
list-style: lower-roman }
ol.upperroman {
list-style: upper-roman }
p.attribution {
text-align: right ;
margin-left: 50% }
p.caption {
font-style: italic }
p.credits {
font-style: italic ;
font-size: smaller }
p.label {
white-space: nowrap }
p.rubric {
font-weight: bold ;
font-size: larger ;
color: maroon ;
text-align: center }
p.sidebar-title {
font-family: sans-serif ;
font-weight: bold ;
font-size: larger }
p.sidebar-subtitle {
font-family: sans-serif ;
font-weight: bold }
p.topic-title {
font-weight: bold }
pre.address {
margin-bottom: 0 ;
margin-top: 0 ;
font: inherit }
pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
span.classifier {
font-family: sans-serif ;
font-style: oblique }
span.classifier-delimiter {
font-family: sans-serif ;
font-weight: bold }
span.interpreted {
font-family: sans-serif }
span.option {
white-space: nowrap }
span.pre {
white-space: pre }
span.problematic {
color: red }
span.section-subtitle {
/* font-size relative to parent (h1..h6 element) */
font-size: 80% }
table.citation {
border-left: solid 1px gray;
margin-left: 1px }
table.docinfo {
margin: 2em 4em }
table.docutils {
margin-top: 0.5em ;
margin-bottom: 0.5em }
table.footnote {
border-left: solid 1px black;
margin-left: 1px }
table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
padding-left: 0.5em ;
padding-right: 0.5em ;
vertical-align: top }
table.docutils th.field-name, table.docinfo th.docinfo-name {
font-weight: bold ;
text-align: left ;
white-space: nowrap ;
padding-left: 0 }
/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
border: 0px;
border-top: 2px solid;
border-bottom: 2px solid;
border-collapse: collapse;
}
table.docutils.booktabs * {
border: 0px;
}
table.docutils.booktabs th {
border-bottom: thin solid;
text-align: left;
}
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
font-size: 100% }
ul.auto-toc {
list-style-type: none }
</style>
</head>
<body>
<div class="document" id="pos-order-to-sale-order">
<h1 class="title">PoS Order To Sale Order</h1>
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Production/Stable" src="https://img.shields.io/badge/maturity-Production%2FStable-green.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/pos/tree/8.0/pos_order_to_sale_order"><img alt="OCA/pos" src="https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/pos-8-0/pos-8-0-pos_order_to_sale_order"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/184/8.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module extends the functionality of point of sale to allow sale orders
creation from the Point of Sale.</p>
<p>In the POS UI, buttons has been added to create a sale order and discard
the current POS order.</p>
<p>This module is usefull in many cases, for exemple :</p>
<ul class="simple">
<li>take orders with a very simple interface</li>
<li>if you have some customers that come every day in your shop, but want to
have a unique invoice at the end of the month. With that module, you can
create a sale order and deliver products every time to keep your stock value
correct, and to create a unique invoice, when you want.</li>
</ul>
<p>Three options are available:</p>
<ul class="simple">
<li><strong>Create a draft Order</strong>
A new sale order in a draft mode will be created that can be changed later.</li>
</ul>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/pos/8.0/pos_order_to_sale_order/static/description/pos_create_picking_option_1.png" src="https://raw.githubusercontent.com/OCA/pos/8.0/pos_order_to_sale_order/static/description/pos_create_picking_option_1.png" style="width: 800px;" />
</div>
<ul class="simple">
<li><strong>Create a Confirmed Order</strong>
A new sale order will be created and confirmed.</li>
</ul>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/pos/8.0/pos_order_to_sale_order/static/description/pos_create_picking_option_2.png" src="https://raw.githubusercontent.com/OCA/pos/8.0/pos_order_to_sale_order/static/description/pos_create_picking_option_2.png" style="width: 800px;" />
</div>
<ul class="simple">
<li><strong>Create Delivered Picking</strong> (by default)
A new sale order will be created and confirmed. the associated picking
will be marked as delivered.</li>
</ul>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/pos/8.0/pos_order_to_sale_order/static/description/pos_create_picking_option_3.png" src="https://raw.githubusercontent.com/OCA/pos/8.0/pos_order_to_sale_order/static/description/pos_create_picking_option_3.png" style="width: 800px;" />
</div>
<p><strong>Technical Notes</strong></p>
<ul class="simple">
<li>Some hooks are defined in the JS file, to define custom behaviour after
having created the sale order (and the stock picking).</li>
<li>Some prepare functions are available in the sale.order model, to overload
the creation of the sale order.</li>
<li>You could be interested by another module, pos_sale_order, that completely
alter Point of Sale module, avoiding creating Pos Orders, and creating
allways Sale Orders.
This module is a WIP state, and is available here:
<a class="reference external" href="https://github.com/OCA/pos/pull/35">https://github.com/OCA/pos/pull/35</a></li>
</ul>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a></li>
<li><a class="reference internal" href="#known-issues-roadmap" id="id2">Known issues / Roadmap</a></li>
<li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="id4">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="id5">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="configuration">
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
<p>To configure this module, you need to:</p>
<ul class="simple">
<li>Go to Point Of Sale / Configuration / Point of Sale</li>
<li>Check the box ‘Create Sale Orders’</li>
<li>Select the desired default behaviour</li>
</ul>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/pos/8.0/pos_order_to_sale_order/static/description/pos_config_form.png" src="https://raw.githubusercontent.com/OCA/pos/8.0/pos_order_to_sale_order/static/description/pos_config_form.png" style="width: 800px;" />
</div>
</div>
<div class="section" id="known-issues-roadmap">
<h1><a class="toc-backref" href="#id2">Known issues / Roadmap</a></h1>
<ul class="simple">
<li>Because of the poor design of the Odoo Point of Sale, some basic features
are not available by default, like pricelist, fiscal position, etc …
For that reason, unit price will be recomputed by default, when creating the
sale order, and the unit price of the current bill will not be used.</li>
</ul>
<p>Note that this problem is fixed if <tt class="docutils literal">pos_pricelist</tt> is installed.
(same repository) In that cases, the pricelist, the unit prices and the taxes
will be the same in the order, as in the displayed bill.</p>
<div class="figure">
<img alt="https://raw.githubusercontent.com/OCA/pos/8.0/pos_order_to_sale_order/static/description/pos_create_picking_confirm.png" src="https://raw.githubusercontent.com/OCA/pos/8.0/pos_order_to_sale_order/static/description/pos_create_picking_confirm.png" style="width: 800px;" />
</div>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/pos/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/pos/issues/new?body=module:%20pos_order_to_sale_order%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#id4">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#id5">Authors</a></h2>
<ul class="simple">
<li>GRAP</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#id6">Contributors</a></h2>
<ul class="simple">
<li>Sylvain LE GAL (<a class="reference external" href="https://www.twitter.com/legalsylvain">https://www.twitter.com/legalsylvain</a>)</li>
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#id7">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external" href="https://github.com/legalsylvain"><img alt="legalsylvain" src="https://github.com/legalsylvain.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/pos/tree/8.0/pos_order_to_sale_order">OCA/pos</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
</div>
</body>
</html>

BIN
pos_order_to_sale_order/static/description/pos_config_form.png

After

Width: 990  |  Height: 414  |  Size: 37 KiB

BIN
pos_order_to_sale_order/static/description/pos_frontend_buttons.png

After

Width: 585  |  Height: 346  |  Size: 18 KiB

BIN
pos_order_to_sale_order/static/description/pos_frontend_order.png

After

Width: 435  |  Height: 332  |  Size: 36 KiB

161
pos_order_to_sale_order/static/src/js/screens.js

@ -0,0 +1,161 @@
/** ***************************************************************************
Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
******************************************************************************/
odoo.define('pos_order_to_sale_order.screens', function (require) {
"use strict";
var screens = require('point_of_sale.screens');
var gui = require('point_of_sale.gui');
var core = require('web.core');
var framework = require('web.framework');
var rpc = require('web.rpc');
var _t = core._t;
/** **********************************************************************
New Widget CreateSaleOrderButtonWidget:
* On click, display a new screen to select the action to do
*/
var CreateSaleOrderButtonWidget = screens.ActionButtonWidget.extend({
template: 'CreateSaleOrderButtonWidget',
button_click: function () {
if (this.pos.get_order().get_client()) {
this.gui.show_screen('create_sale_order');
} else {
this.gui.show_popup('error', {
'title': _t('No customer defined'),
'body': _t(
'You should select a customer in order to create' +
' a Sale Order.'),
});
}
},
is_visible: function () {
return this.pos.get_order().orderlines.length > 0;
},
});
screens.define_action_button({
'name': 'create_sale_order',
'widget': CreateSaleOrderButtonWidget,
'condition': function () {
return this.pos.config.iface_create_sale_order;
},
});
screens.OrderWidget.include({
update_summary: function () {
this._super();
if (this.getParent().action_buttons &&
this.getParent().action_buttons.create_sale_order) {
this.getParent().action_buttons.create_sale_order.renderElement();
}
},
});
/** **********************************************************************
New ScreenWidget CreateSaleOrderScreenWidget:
* On show, display all buttons, depending on the pos configuration
*/
var CreateSaleOrderScreenWidget = screens.ScreenWidget.extend({
template: 'CreateSaleOrderScreenWidget',
auto_back: true,
show: function(){
var self = this;
this._super();
this.renderElement();
this.$('.back').click(function(){
self.gui.back();
});
if (!this.pos.config.iface_create_draft_sale_order) {
this.$('#button-create-draft-order').addClass('oe_hidden');
}
if (!this.pos.config.iface_create_confirmed_sale_order) {
this.$('#button-create-confirmed-order').addClass('oe_hidden');
}
if (!this.pos.config.iface_create_delivered_sale_order) {
this.$('#button-create-delivered-order').addClass('oe_hidden');
}
this.$('.paymentmethod').click(function(event){
self.click_sale_order_button(event.currentTarget.attributes.action.nodeValue);
});
},
click_sale_order_button: function(action) {
var self = this;
this.gui.show_popup('confirm', {
'title': _t(
'Create Sale Order and discard the current' +
' PoS Order?'),
'body': _t(
"This operation will permanently discard the current PoS" +
" Order and create a Sale Order, based on the" +
" current order lines."),
confirm: function(){
framework.blockUI();
rpc.query({
model: 'sale.order',
method: 'create_order_from_pos',
args: [self.pos.get('selectedOrder').export_as_JSON(), action],
}).then(function (result) {
self.hook_create_sale_order_success(result);
}).fail(function (error, event) {
self.hook_create_sale_order_error(error, event);
});
},
});
},
/**
* Overloadable function to make custom action after Sale order
* Creation succeeded
*/
hook_create_sale_order_success: function (result) {
framework.unblockUI();
this.pos.get('selectedOrder').destroy();
},
/**
* Overloadable function to make custom action after Sale order
* Creation failed
*/
hook_create_sale_order_error: function (error, event) {
framework.unblockUI();
event.preventDefault();
if (error.code === 200) {
// Business Logic Error, not a connection problem
this.gui.show_popup('error-traceback', {
'title': error.data.message,
'body': error.data.debug,
});
} else {
// Connexion problem
this.gui.show_popup('error', {
'title': _t('The order could not be sent'),
'body': _t('Check your internet connection and try again.'),
});
}
},
});
gui.define_screen({
'name': 'create_sale_order',
'widget': CreateSaleOrderScreenWidget,
'condition': function () {
return this.pos.config.iface_create_sale_order;
},
});
});

37
pos_order_to_sale_order/static/src/xml/pos_order_to_sale_order.xml

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<template>
<t t-name="CreateSaleOrderButtonWidget">
<span class="control-button order-split" t-att-style='widget.is_visible() ? "display: block;" : "display: none;"'>
<i class="fa fa-download"></i>Create Sale Order
</span>
</t>
<t t-name="CreateSaleOrderScreenWidget">
<div class="screen">
<div class="screen-content">
<div class="top-content">
<span class='button back'>
<i class='fa fa-angle-double-left'></i>
Back
</span>
<h1>Create Sale Order</h1>
</div>
<div class="centered-content">
<div class="paymentmethods">
<div class="button paymentmethod"
id="button-create-draft-order" action="draft">
Create Draft Sale Order
</div><div class="button paymentmethod"
id="button-create-confirmed-order" action="confirmed">
Create Confirmed Sale Order
</div><div class="button paymentmethod"
id="button-create-delivered-order" action="delivered">
Create Delivered Sale Order
</div>
</div>
</div>
</div>
</div>
</t>
</template>

11
pos_order_to_sale_order/views/assets.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_order_to_sale_order/static/src/js/screens.js"></script>
</xpath>
</template>
</odoo>

43
pos_order_to_sale_order/views/view_pos_config.xml

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_pos_config_form" model="ir.ui.view">
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml">
<xpath expr="//h2[@name='order']" position="before">
<h2 name="create_sale_order">Sale Order Creations</h2>
<div class="row mt16 o_settings_container">
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="iface_create_draft_sale_order"/>
</div>
<div class="o_setting_right_pane">
<label for="iface_create_draft_sale_order"/>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="iface_create_confirmed_sale_order"/>
</div>
<div class="o_setting_right_pane">
<label for="iface_create_confirmed_sale_order"/>
</div>
</div>
<div class="col-12 col-lg-6 o_setting_box">
<div class="o_setting_left_pane">
<field name="iface_create_delivered_sale_order"/>
</div>
<div class="o_setting_right_pane">
<label for="iface_create_delivered_sale_order"/>
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save