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 new file mode 100644 index 00000000..f662f1e8 --- /dev/null +++ b/pos_stock_picking_invoice_link/README.rst @@ -0,0 +1,84 @@ +============================== +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 +===== + +* 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. + +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 smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Tecnativa + +Contributors +~~~~~~~~~~~~ + + +* `Tecnativa `_ + + * David Vidal + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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. + +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 new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/pos_stock_picking_invoice_link/__init__.py @@ -0,0 +1 @@ +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..1599a75d --- /dev/null +++ b/pos_stock_picking_invoice_link/__manifest__.py @@ -0,0 +1,17 @@ +# 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': '11.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/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..c09a6e14 --- /dev/null +++ b/pos_stock_picking_invoice_link/i18n/pos_stock_picking_invoice_link.pot @@ -0,0 +1,40 @@ +# 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 11.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_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 "" + 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..f4508d7d --- /dev/null +++ b/pos_stock_picking_invoice_link/models/__init__.py @@ -0,0 +1,2 @@ +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 new file mode 100644 index 00000000..fddffc84 --- /dev/null +++ b/pos_stock_picking_invoice_link/models/pos_order.py @@ -0,0 +1,36 @@ +# Copyright 2018-19 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +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({ + '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 + 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/icon.png b/pos_stock_picking_invoice_link/static/description/icon.png new file mode 100644 index 00000000..f5deaa3f Binary files /dev/null and b/pos_stock_picking_invoice_link/static/description/icon.png differ 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..3d9de42e --- /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 new file mode 100644 index 00000000..45112269 --- /dev/null +++ b/pos_stock_picking_invoice_link/tests/__init__.py @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..0c42ac41 --- /dev/null +++ b/pos_stock_picking_invoice_link/tests/test_point_of_sale_stock_invoice_link.py @@ -0,0 +1,69 @@ +# Copyright 2018 Tecnativa - David Vidal +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests import common + + +@common.at_install(False) +@common.post_install(True) +class TestPointOfSaleStockPickingInvoiceLink(common.HttpCase): + def setUp(self): + super(TestPointOfSaleStockPickingInvoiceLink, self).setUp() + self.partner = self.env['res.partner'].create({ + 'name': 'Mr. Odoo', + }) + self.product_1 = self.env['product.product'].create({ + 'name': 'Test variant 1', + 'standard_price': 1.0, + 'type': 'product', + }) + self.product_2 = self.env['product.product'].create({ + 'name': 'Test variant 1', + 'standard_price': 1.0, + 'type': 'product', + }) + self.PosOrder = self.env['pos.order'] + self.pos_config = self.env.ref('point_of_sale.pos_config_main') + + def test_stock_picking_invoice_link(self): + """The picking is created and the lines are related to their moves""" + self.pos_config.open_session_cb() + pos_order = self.PosOrder.create({ + 'session_id': self.pos_config.current_session_id.id, + 'partner_id': self.partner.id, + 'pricelist_id': self.partner.property_product_pricelist.id, + 'lines': [ + (0, 0, { + 'name': "POSLINE/0001", + 'product_id': self.product_1.id, + 'price_unit': 450, + 'qty': 2.0, + }), + (0, 0, { + 'name': "POSLINE/0002", + 'product_id': self.product_2.id, + 'price_unit': 450, + 'qty': 2.0, + }), + (0, 0, { + 'name': "POSLINE/0003", + 'product_id': self.product_1.id, + 'price_unit': 450, + 'qty': 2.0, + }), + ], + }) + context_make_payment = { + "active_ids": [pos_order.id], + "active_id": pos_order.id, + } + pos_make_payment = self.env['pos.make.payment'].with_context( + context_make_payment).create({'amount': 950}) + context_payment = {'active_id': pos_order.id} + pos_make_payment.with_context(context_payment).check() + pos_order.create_picking() + res = pos_order.action_pos_order_invoice() + invoice = self.env['account.invoice'].browse(res['res_id']) + self.assertTrue(invoice.picking_ids) + for line in invoice.invoice_line_ids: + self.assertEqual(len(line.move_line_ids), 1) diff --git a/setup/_metapackage/VERSION.txt b/setup/_metapackage/VERSION.txt index 6389f6a8..bbacb442 100644 --- a/setup/_metapackage/VERSION.txt +++ b/setup/_metapackage/VERSION.txt @@ -1 +1 @@ -11.0.20190816.0 \ No newline at end of file +11.0.20190820.0 \ No newline at end of file diff --git a/setup/_metapackage/setup.py b/setup/_metapackage/setup.py index 5455cedd..0532c385 100644 --- a/setup/_metapackage/setup.py +++ b/setup/_metapackage/setup.py @@ -17,6 +17,7 @@ setuptools.setup( 'odoo11-addon-pos_order_return', 'odoo11-addon-pos_payment_entries_globalization', 'odoo11-addon-pos_session_pay_invoice', + 'odoo11-addon-pos_stock_picking_invoice_link', 'odoo11-addon-pos_ticket_logo', ], classifiers=[ diff --git a/setup/pos_stock_picking_invoice_link/odoo/addons/pos_stock_picking_invoice_link b/setup/pos_stock_picking_invoice_link/odoo/addons/pos_stock_picking_invoice_link new file mode 120000 index 00000000..0dd23227 --- /dev/null +++ b/setup/pos_stock_picking_invoice_link/odoo/addons/pos_stock_picking_invoice_link @@ -0,0 +1 @@ +../../../../pos_stock_picking_invoice_link \ No newline at end of file diff --git a/setup/pos_stock_picking_invoice_link/setup.cfg b/setup/pos_stock_picking_invoice_link/setup.cfg new file mode 100644 index 00000000..3c6e79cf --- /dev/null +++ b/setup/pos_stock_picking_invoice_link/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/setup/pos_stock_picking_invoice_link/setup.py b/setup/pos_stock_picking_invoice_link/setup.py new file mode 100644 index 00000000..28c57bb6 --- /dev/null +++ b/setup/pos_stock_picking_invoice_link/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)