Browse Source

[ADD] pos_stock_picking_invoice_link: New Module

pull/393/head
David 7 years ago
committed by OCA-git-bot
parent
commit
a61b82aac5
  1. 59
      pos_stock_picking_invoice_link/README.rst
  2. 3
      pos_stock_picking_invoice_link/__init__.py
  3. 19
      pos_stock_picking_invoice_link/__manifest__.py
  4. 3
      pos_stock_picking_invoice_link/models/__init__.py
  5. 30
      pos_stock_picking_invoice_link/models/pos_order.py
  6. BIN
      pos_stock_picking_invoice_link/static/description/icon.png
  7. 3
      pos_stock_picking_invoice_link/tests/__init__.py
  8. 70
      pos_stock_picking_invoice_link/tests/test_point_of_sale_stock_invoice_link.py

59
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
<https://github.com/OCA/pos/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 <https://odoo-community.org/logo.png>`_.
Contributors
------------
* David <david.vidal@tecnativa.com> (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.

3
pos_stock_picking_invoice_link/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models

19
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,
}

3
pos_stock_picking_invoice_link/models/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import pos_order

30
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

BIN
pos_stock_picking_invoice_link/static/description/icon.png

After

Width: 373  |  Height: 374  |  Size: 4.7 KiB

3
pos_stock_picking_invoice_link/tests/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import test_point_of_sale_stock_invoice_link

70
pos_stock_picking_invoice_link/tests/test_point_of_sale_stock_invoice_link.py

@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
# 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)
Loading…
Cancel
Save