From 2c0d25c7c2d52095650e6ba247450f2dfa8806d4 Mon Sep 17 00:00:00 2001 From: Daniel-CA Date: Thu, 19 Nov 2015 16:20:22 +0100 Subject: [PATCH] [ADD] pos_invoicing_from_picking --- pos_invoicing_from_picking/README.rst | 50 +++++++++++++++++++ pos_invoicing_from_picking/__init__.py | 6 +++ pos_invoicing_from_picking/__openerp__.py | 20 ++++++++ pos_invoicing_from_picking/models/__init__.py | 6 +++ .../models/point_of_sale.py | 21 ++++++++ pos_invoicing_from_picking/models/stock.py | 25 ++++++++++ .../oca_dependencies.txt | 3 ++ .../views/point_of_sale_view.xml | 14 ++++++ 8 files changed, 145 insertions(+) create mode 100644 pos_invoicing_from_picking/README.rst create mode 100644 pos_invoicing_from_picking/__init__.py create mode 100644 pos_invoicing_from_picking/__openerp__.py create mode 100644 pos_invoicing_from_picking/models/__init__.py create mode 100644 pos_invoicing_from_picking/models/point_of_sale.py create mode 100644 pos_invoicing_from_picking/models/stock.py create mode 100644 pos_invoicing_from_picking/oca_dependencies.txt create mode 100644 pos_invoicing_from_picking/views/point_of_sale_view.xml diff --git a/pos_invoicing_from_picking/README.rst b/pos_invoicing_from_picking/README.rst new file mode 100644 index 00000000..1c887f98 --- /dev/null +++ b/pos_invoicing_from_picking/README.rst @@ -0,0 +1,50 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :alt: License +========================== +PoS invoicing from picking +========================== + +This module allows to invoice from stock picking PoS sale orders. + +Usage +===== + +To use this module, you need to go to PoS backend sale orders and use the +picking button to create a picking to be invoiced. + +.. 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/8.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 smashing it by providing a detailed and welcomed feedback +`here `_. + +Credits +======= + +Contributors +------------ +* Daniel Campos +* Pedro M. Baeza +* Ana Juaristi + + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://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 http://odoo-community.org. \ No newline at end of file diff --git a/pos_invoicing_from_picking/__init__.py b/pos_invoicing_from_picking/__init__.py new file mode 100644 index 00000000..f95f1fe5 --- /dev/null +++ b/pos_invoicing_from_picking/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Daniel Campos - Avanzosc S.L. +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import models + diff --git a/pos_invoicing_from_picking/__openerp__.py b/pos_invoicing_from_picking/__openerp__.py new file mode 100644 index 00000000..bc95b4c1 --- /dev/null +++ b/pos_invoicing_from_picking/__openerp__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Daniel Campos - Avanzosc S.L. +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + "name": "POS invoicing from picking", + "version": "8.0.1.0.0", + 'author': 'OdooMRP team', + 'website': "http://www.odoomrp.com", + 'license': 'AGPL-3', + 'contributors': ["Daniel Campos ", + "Pedro M. Baeza ", + "Ana Juaristi "], + "depends": ['point_of_sale', 'stock_account', + 'stock_picking_invoice_link'], + "category": "POS", + "data": ['views/point_of_sale_view.xml' + ], + "installable": True +} diff --git a/pos_invoicing_from_picking/models/__init__.py b/pos_invoicing_from_picking/models/__init__.py new file mode 100644 index 00000000..d75a8256 --- /dev/null +++ b/pos_invoicing_from_picking/models/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Daniel Campos - Avanzosc S.L. +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import point_of_sale +from . import stock diff --git a/pos_invoicing_from_picking/models/point_of_sale.py b/pos_invoicing_from_picking/models/point_of_sale.py new file mode 100644 index 00000000..2deb5b2c --- /dev/null +++ b/pos_invoicing_from_picking/models/point_of_sale.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Daniel Campos - Avanzosc S.L. +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import models, api, exceptions, _ + + +class PosOrder(models.Model): + _inherit = 'pos.order' + + @api.multi + def action_confirm_picking(self): + for order in self: + if not order.partner_id: + raise exceptions.Warning( + _('Customer must be selected to invoice from picking')) + if not self.picking_id: + order.create_picking() + pick = order.picking_id + pick.invoice_state = '2binvoiced' + order.state = 'invoiced' diff --git a/pos_invoicing_from_picking/models/stock.py b/pos_invoicing_from_picking/models/stock.py new file mode 100644 index 00000000..3f8f5c70 --- /dev/null +++ b/pos_invoicing_from_picking/models/stock.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# (c) 2015 Daniel Campos - Avanzosc S.L. +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import models, api + + +class StockPicking(models.Model): + _inherit = 'stock.picking' + + @api.multi + def action_invoice_create(self, journal_id, group=False, + type='out_invoice'): + res = super(StockPicking, self).action_invoice_create( + journal_id, group=group, type=type) + for picking in self: + pos_order_obj = self.env['pos.order'] + picking_type_id = self.env.ref('point_of_sale.picking_type_posout') + if picking_type_id.id == picking.picking_type_id.id: + pos_order = pos_order_obj.search( + [('picking_id', '=', picking.id)], limit=1) + if pos_order: + pos_order.invoice_id = picking.invoice_id + pos_order.invoice_id.origin += ' / ' + pos_order.name + return res diff --git a/pos_invoicing_from_picking/oca_dependencies.txt b/pos_invoicing_from_picking/oca_dependencies.txt new file mode 100644 index 00000000..841f967b --- /dev/null +++ b/pos_invoicing_from_picking/oca_dependencies.txt @@ -0,0 +1,3 @@ +# list the OCA project dependencies, one per line +# add a github url if you need a forked version +stock-logistics-workflow https://github.com/OCA/stock-logistics-workflow.git diff --git a/pos_invoicing_from_picking/views/point_of_sale_view.xml b/pos_invoicing_from_picking/views/point_of_sale_view.xml new file mode 100644 index 00000000..9b3cdea8 --- /dev/null +++ b/pos_invoicing_from_picking/views/point_of_sale_view.xml @@ -0,0 +1,14 @@ + + + + pos.order.ext.form + pos.order + + + + + + +