From a61b82aac5cb9f0d70d0782bb03d11e82bd23349 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 12 Mar 2018 19:04:33 +0100 Subject: [PATCH] [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&l2R>3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