From a61b82aac5cb9f0d70d0782bb03d11e82bd23349 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 12 Mar 2018 19:04:33 +0100 Subject: [PATCH 1/6] [ADD] pos_stock_picking_invoice_link: New Module --- pos_stock_picking_invoice_link/README.rst | 59 +++++++++++++++ pos_stock_picking_invoice_link/__init__.py | 3 + .../__manifest__.py | 19 +++++ .../models/__init__.py | 3 + .../models/pos_order.py | 30 ++++++++ .../static/description/icon.png | Bin 0 -> 4776 bytes .../tests/__init__.py | 3 + .../test_point_of_sale_stock_invoice_link.py | 70 ++++++++++++++++++ 8 files changed, 187 insertions(+) create mode 100644 pos_stock_picking_invoice_link/README.rst create mode 100644 pos_stock_picking_invoice_link/__init__.py create mode 100644 pos_stock_picking_invoice_link/__manifest__.py create mode 100644 pos_stock_picking_invoice_link/models/__init__.py create mode 100644 pos_stock_picking_invoice_link/models/pos_order.py create mode 100644 pos_stock_picking_invoice_link/static/description/icon.png create mode 100644 pos_stock_picking_invoice_link/tests/__init__.py create mode 100644 pos_stock_picking_invoice_link/tests/test_point_of_sale_stock_invoice_link.py diff --git a/pos_stock_picking_invoice_link/README.rst b/pos_stock_picking_invoice_link/README.rst new file mode 100644 index 00000000..37bc18b2 --- /dev/null +++ b/pos_stock_picking_invoice_link/README.rst @@ -0,0 +1,59 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: https://www.gnu.org/licenses/agpl + :alt: License: AGPL-3 + +============================== +POS Stock Picking Invoice Link +============================== + +Links POS generated stock moves and pickings to its corresponding invoice +lines. + +Usage +===== + +* Create a POS order with stockable products and invoice option checked. +* If you open invoice form in the backend, you must see the related picking in + the Pickings tab. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/184/10.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smash it by providing detailed and welcomed feedback. + +Credits +======= + +Images +------ + +* Odoo Community Association: `Icon `_. + +Contributors +------------ + +* David (https://www.tecnativa.com) + +Do not contact contributors directly about support or help with technical issues. + +Maintainer +---------- + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit https://odoo-community.org. diff --git a/pos_stock_picking_invoice_link/__init__.py b/pos_stock_picking_invoice_link/__init__.py new file mode 100644 index 00000000..cde864ba --- /dev/null +++ b/pos_stock_picking_invoice_link/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import models diff --git a/pos_stock_picking_invoice_link/__manifest__.py b/pos_stock_picking_invoice_link/__manifest__.py new file mode 100644 index 00000000..b9174456 --- /dev/null +++ b/pos_stock_picking_invoice_link/__manifest__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Tecnativa S.L. - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +{ + 'name': 'POS Stock Picking Invoice Link', + 'version': '10.0.1.0.0', + 'category': 'Point of Sale', + 'author': 'Tecnativa,' + 'Odoo Community Association (OCA)', + 'website': 'https://github.com/OCA/pos', + 'license': 'AGPL-3', + 'depends': [ + 'point_of_sale', + 'stock_picking_invoice_link', + ], + 'application': False, + 'installable': True, +} diff --git a/pos_stock_picking_invoice_link/models/__init__.py b/pos_stock_picking_invoice_link/models/__init__.py new file mode 100644 index 00000000..39beeb1f --- /dev/null +++ b/pos_stock_picking_invoice_link/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import pos_order diff --git a/pos_stock_picking_invoice_link/models/pos_order.py b/pos_stock_picking_invoice_link/models/pos_order.py new file mode 100644 index 00000000..16418e9a --- /dev/null +++ b/pos_stock_picking_invoice_link/models/pos_order.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Copyright 2018 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import models + + +class PosOrder(models.Model): + _inherit = 'pos.order' + + def _prepare_invoice(self): + res = super(PosOrder, self)._prepare_invoice() + res.update({ + 'picking_ids': [(6, 0, self.picking_id.ids)], + }) + return res + + def _action_create_invoice_line(self, line=False, invoice_id=False): + invoice_line = super( + PosOrder, self)._action_create_invoice_line(line, invoice_id) + if not line: + return invoice_line + move = self.env['stock.move'].search([ + ('picking_id', '=', self.picking_id.id), + ('name', '=', line.name)]) + if move: + invoice_line.write({ + 'move_line_ids': [(6, 0, move.ids)], + }) + return invoice_line diff --git a/pos_stock_picking_invoice_link/static/description/icon.png b/pos_stock_picking_invoice_link/static/description/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..f5deaa3f7766cf075c65bbe2c793c68b85cbb22d GIT binary patch literal 4776 zcmdT|XH*kww+>C3fS`gR3epb>p<|;8A_{~eEd)c6A|!+=ErcQp7!c{bC>WZw!=VZR zMM|Xi8hVi?5(qtT2haKL{d3p%4-L+=c?Dv_Oz4!CHW%fJadb*k{Ox#Q$5Qs(V zp}GMGMCA#bFBqr+%wje_XPY(}U zH=E!dMi7WYT}xf{iTBt#(Mj)#eMal1b8XF(s`>?5I@+KXW--xs5iO!xvW_9z1ubhZ zFN0KsGyyTFJBY*mDOX{O6t0+a>>Sb+F25^dUhX_7?@%Y$a!DlRfnHs6{{*|kPcH|D ztW+HMkXoc7_8jiYEuw#IL#7G--I?R1Uvv9%lzZacclQgE! zP{E%@fA}_r-ID5gS)q)HaB-AY7&G=P3j-;(UBq77ckbDtX+XOR$|4|i(Ank@AACBb zv(S*uZh=eKzK9{xbh<$&MMus;hgW{G7*SF&!oZDAzPB-7s7>YmmF6WIq62JnQCPF} zE;%UsK~qib3e$Qdrs3m2|_7Yk!$Jilz1RFn{v zx)INuG8V*oMi<{mUtFb)zhP^WUyvs$G!BvQ>J&lptQafrt+{Pk#M&l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_I7dYU^z7K#uG(kDWSkng306*zBNMXq0EW=RoRY2A8 z00_+g{6YSI!sluHmxC-$EzW-&oQ4PSmi#N;!0F?8|36w0psat%sE2Jlpv&S6UpWCy YdtHD2mBn=w_}2u|($G~eR Date: Fri, 22 Jun 2018 16:06:11 +0000 Subject: [PATCH 2/6] [UPD] Update pos_stock_picking_invoice_link.pot --- .../i18n/pos_stock_picking_invoice_link.pot | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pos_stock_picking_invoice_link/i18n/pos_stock_picking_invoice_link.pot diff --git a/pos_stock_picking_invoice_link/i18n/pos_stock_picking_invoice_link.pot b/pos_stock_picking_invoice_link/i18n/pos_stock_picking_invoice_link.pot new file mode 100644 index 00000000..03d8dee5 --- /dev/null +++ b/pos_stock_picking_invoice_link/i18n/pos_stock_picking_invoice_link.pot @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * pos_stock_picking_invoice_link +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \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_stock_picking_invoice_link +#: model:ir.model,name:pos_stock_picking_invoice_link.model_pos_order +msgid "Point of Sale Orders" +msgstr "" + From 5d8885bf4636d9434e63ae6021839972fda9d7b4 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 22 Jul 2019 10:18:07 +0200 Subject: [PATCH 3/6] [MIG] pos_stock_picking_invoice_link: Migration to 11.0 --- oca_dependencies.txt | 3 +- pos_stock_picking_invoice_link/README.rst | 71 ++- pos_stock_picking_invoice_link/__init__.py | 2 - .../__manifest__.py | 6 +- .../models/__init__.py | 3 +- .../models/pos_order.py | 28 +- .../models/stock_move.py | 30 ++ .../readme/CONTRIBUTORS.rst | 4 + .../readme/DESCRIPTION.rst | 2 + .../readme/USAGE.rst | 3 + .../static/description/index.html | 432 ++++++++++++++++++ .../tests/__init__.py | 2 - .../test_point_of_sale_stock_invoice_link.py | 1 - 13 files changed, 541 insertions(+), 46 deletions(-) create mode 100644 pos_stock_picking_invoice_link/models/stock_move.py create mode 100644 pos_stock_picking_invoice_link/readme/CONTRIBUTORS.rst create mode 100644 pos_stock_picking_invoice_link/readme/DESCRIPTION.rst create mode 100644 pos_stock_picking_invoice_link/readme/USAGE.rst create mode 100644 pos_stock_picking_invoice_link/static/description/index.html diff --git a/oca_dependencies.txt b/oca_dependencies.txt index 9dcd24b5..c901b0bd 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1,3 +1,4 @@ # list the OCA project dependencies, one per line # add a github url if you need a forked version -account-payment https://github.com/OCA/account-payment +account-payment +stock-logistics-workflow diff --git a/pos_stock_picking_invoice_link/README.rst b/pos_stock_picking_invoice_link/README.rst index 37bc18b2..f662f1e8 100644 --- a/pos_stock_picking_invoice_link/README.rst +++ b/pos_stock_picking_invoice_link/README.rst @@ -1,14 +1,38 @@ -.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png - :target: https://www.gnu.org/licenses/agpl - :alt: License: AGPL-3 - ============================== POS Stock Picking Invoice Link ============================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpos-lightgray.png?logo=github + :target: https://github.com/OCA/pos/tree/11.0/pos_stock_picking_invoice_link + :alt: OCA/pos +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/pos-11-0/pos-11-0-pos_stock_picking_invoice_link + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/184/11.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + Links POS generated stock moves and pickings to its corresponding invoice lines. +**Table of contents** + +.. contents:: + :local: + Usage ===== @@ -16,44 +40,45 @@ Usage * If you open invoice form in the backend, you must see the related picking in the Pickings tab. -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/184/10.0 - Bug Tracker =========== -Bugs are tracked on `GitHub Issues -`_. In case of trouble, please -check there if your issue has already been reported. If you spotted it first, -help us smash it by providing detailed and welcomed feedback. +Bugs are tracked on `GitHub Issues `_. +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 +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* Tecnativa Contributors ------------- +~~~~~~~~~~~~ -* David (https://www.tecnativa.com) -Do not contact contributors directly about support or help with technical issues. +* `Tecnativa `_ + + * David Vidal -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - 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. -To contribute to this module, please visit https://odoo-community.org. +This module is part of the `OCA/pos `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/pos_stock_picking_invoice_link/__init__.py b/pos_stock_picking_invoice_link/__init__.py index cde864ba..0650744f 100644 --- a/pos_stock_picking_invoice_link/__init__.py +++ b/pos_stock_picking_invoice_link/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import models diff --git a/pos_stock_picking_invoice_link/__manifest__.py b/pos_stock_picking_invoice_link/__manifest__.py index b9174456..1599a75d 100644 --- a/pos_stock_picking_invoice_link/__manifest__.py +++ b/pos_stock_picking_invoice_link/__manifest__.py @@ -1,10 +1,8 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Tecnativa S.L. - David Vidal +# Copyright 2018-19 Tecnativa S.L. - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - { 'name': 'POS Stock Picking Invoice Link', - 'version': '10.0.1.0.0', + 'version': '11.0.1.0.0', 'category': 'Point of Sale', 'author': 'Tecnativa,' 'Odoo Community Association (OCA)', diff --git a/pos_stock_picking_invoice_link/models/__init__.py b/pos_stock_picking_invoice_link/models/__init__.py index 39beeb1f..f4508d7d 100644 --- a/pos_stock_picking_invoice_link/models/__init__.py +++ b/pos_stock_picking_invoice_link/models/__init__.py @@ -1,3 +1,2 @@ -# -*- coding: utf-8 -*- - from . import pos_order +from . import stock_move diff --git a/pos_stock_picking_invoice_link/models/pos_order.py b/pos_stock_picking_invoice_link/models/pos_order.py index 16418e9a..fddffc84 100644 --- a/pos_stock_picking_invoice_link/models/pos_order.py +++ b/pos_stock_picking_invoice_link/models/pos_order.py @@ -1,13 +1,15 @@ -# -*- coding: utf-8 -*- -# Copyright 2018 Tecnativa - David Vidal +# Copyright 2018-19 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - -from odoo import models +from odoo import fields, models class PosOrder(models.Model): _inherit = 'pos.order' + def create_picking(self): + self_ctx = self.with_context(merge_pos_order_line=True) + return super(PosOrder, self_ctx).create_picking() + def _prepare_invoice(self): res = super(PosOrder, self)._prepare_invoice() res.update({ @@ -20,11 +22,15 @@ class PosOrder(models.Model): PosOrder, self)._action_create_invoice_line(line, invoice_id) if not line: return invoice_line - move = self.env['stock.move'].search([ - ('picking_id', '=', self.picking_id.id), - ('name', '=', line.name)]) - if move: - invoice_line.write({ - 'move_line_ids': [(6, 0, move.ids)], - }) + invoice_line.move_line_ids |= line.stock_move_ids return invoice_line + + +class PosOrderLine(models.Model): + _inherit = 'pos.order.line' + + stock_move_ids = fields.One2many( + comodel_name='stock.move', + inverse_name='pos_order_line_id', + string='Related Stock Moves', + ) diff --git a/pos_stock_picking_invoice_link/models/stock_move.py b/pos_stock_picking_invoice_link/models/stock_move.py new file mode 100644 index 00000000..c60a554d --- /dev/null +++ b/pos_stock_picking_invoice_link/models/stock_move.py @@ -0,0 +1,30 @@ +# Copyright 2019 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo import api, fields, models + + +class StockMove(models.Model): + _inherit = 'stock.move' + + pos_order_line_id = fields.Many2one( + comodel_name='pos.order.line', + string='Related POS Order Line', + ) + + @api.model + def create(self, vals): + """We're creating the move in pos.order context + so we search the line uid""" + if self.env.context.get('merge_pos_order_line'): + line = self.env['pos.order.line'].search([ + ('name', '=', vals.get('name')), + ]) + if line: + vals['pos_order_line_id'] = line.id + return super().create(vals) + + @api.model + def _prepare_merge_moves_distinct_fields(self): + distinct_fields = super()._prepare_merge_moves_distinct_fields() + distinct_fields.append('pos_order_line_id') + return distinct_fields diff --git a/pos_stock_picking_invoice_link/readme/CONTRIBUTORS.rst b/pos_stock_picking_invoice_link/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..c5e0cb7a --- /dev/null +++ b/pos_stock_picking_invoice_link/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ + +* `Tecnativa `_ + + * David Vidal diff --git a/pos_stock_picking_invoice_link/readme/DESCRIPTION.rst b/pos_stock_picking_invoice_link/readme/DESCRIPTION.rst new file mode 100644 index 00000000..feac095e --- /dev/null +++ b/pos_stock_picking_invoice_link/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +Links POS generated stock moves and pickings to its corresponding invoice +lines. diff --git a/pos_stock_picking_invoice_link/readme/USAGE.rst b/pos_stock_picking_invoice_link/readme/USAGE.rst new file mode 100644 index 00000000..ecd01ff9 --- /dev/null +++ b/pos_stock_picking_invoice_link/readme/USAGE.rst @@ -0,0 +1,3 @@ +* Create a POS order with stockable products and invoice option checked. +* If you open invoice form in the backend, you must see the related picking in + the Pickings tab. diff --git a/pos_stock_picking_invoice_link/static/description/index.html b/pos_stock_picking_invoice_link/static/description/index.html new file mode 100644 index 00000000..c3d66b8d --- /dev/null +++ b/pos_stock_picking_invoice_link/static/description/index.html @@ -0,0 +1,432 @@ + + + + + + +POS Stock Picking Invoice Link + + + + + + diff --git a/pos_stock_picking_invoice_link/tests/__init__.py b/pos_stock_picking_invoice_link/tests/__init__.py index 04b79b41..45112269 100644 --- a/pos_stock_picking_invoice_link/tests/__init__.py +++ b/pos_stock_picking_invoice_link/tests/__init__.py @@ -1,3 +1 @@ -# -*- coding: utf-8 -*- - from . import test_point_of_sale_stock_invoice_link diff --git a/pos_stock_picking_invoice_link/tests/test_point_of_sale_stock_invoice_link.py b/pos_stock_picking_invoice_link/tests/test_point_of_sale_stock_invoice_link.py index b67c14cc..0c42ac41 100644 --- a/pos_stock_picking_invoice_link/tests/test_point_of_sale_stock_invoice_link.py +++ b/pos_stock_picking_invoice_link/tests/test_point_of_sale_stock_invoice_link.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2018 Tecnativa - David Vidal # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). From 47ca4bd1bc323ff96e517f1371d754691b5a0991 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Tue, 20 Aug 2019 07:24:23 +0000 Subject: [PATCH 4/6] [UPD] Update pos_stock_picking_invoice_link.pot --- .../i18n/pos_stock_picking_invoice_link.pot | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/pos_stock_picking_invoice_link/i18n/pos_stock_picking_invoice_link.pot b/pos_stock_picking_invoice_link/i18n/pos_stock_picking_invoice_link.pot index 03d8dee5..c09a6e14 100644 --- a/pos_stock_picking_invoice_link/i18n/pos_stock_picking_invoice_link.pot +++ b/pos_stock_picking_invoice_link/i18n/pos_stock_picking_invoice_link.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 11.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" @@ -13,8 +13,28 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: pos_stock_picking_invoice_link +#: model:ir.model,name:pos_stock_picking_invoice_link.model_pos_order_line +msgid "Lines of Point of Sale Orders" +msgstr "" + #. module: pos_stock_picking_invoice_link #: model:ir.model,name:pos_stock_picking_invoice_link.model_pos_order msgid "Point of Sale Orders" msgstr "" +#. module: pos_stock_picking_invoice_link +#: model:ir.model.fields,field_description:pos_stock_picking_invoice_link.field_stock_move_pos_order_line_id +msgid "Related POS Order Line" +msgstr "" + +#. module: pos_stock_picking_invoice_link +#: model:ir.model.fields,field_description:pos_stock_picking_invoice_link.field_pos_order_line_stock_move_ids +msgid "Related Stock Moves" +msgstr "" + +#. module: pos_stock_picking_invoice_link +#: model:ir.model,name:pos_stock_picking_invoice_link.model_stock_move +msgid "Stock Move" +msgstr "" + From ddc111ae8f8bff019268209684b7f324aa080f77 Mon Sep 17 00:00:00 2001 From: OCA-git-bot Date: Tue, 20 Aug 2019 07:31:57 +0000 Subject: [PATCH 5/6] [UPD] README.rst --- pos_stock_picking_invoice_link/static/description/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pos_stock_picking_invoice_link/static/description/index.html b/pos_stock_picking_invoice_link/static/description/index.html index c3d66b8d..3d9de42e 100644 --- a/pos_stock_picking_invoice_link/static/description/index.html +++ b/pos_stock_picking_invoice_link/static/description/index.html @@ -3,7 +3,7 @@ - + POS Stock Picking Invoice Link