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).