Skip to content

Commit

Permalink
[9.0][ADD] purchase_stock_picking_return_invoicing_open_qty
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow committed Jul 25, 2017
1 parent f6ea48b commit 3ca3ff2
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 2 deletions.
5 changes: 3 additions & 2 deletions oca_dependencies.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
account-financial-tools
stock-logistics-workflow
product-attribute
bank-payment
purchase-workflow
product-attribute
stock-logistics-workflow
56 changes: 56 additions & 0 deletions purchase_stock_picking_return_invoicing_open_qty/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

================================================
Purchase Stock Picking Return Invoicing Open Qty
================================================

This module extends makes compatible the modules 'Purchase Open Qty' and
'Purchase Stock Picking Return Invoicing'.

Usage
=====

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/95/9.0

Known issues / Roadmap
======================

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/account-invoicing/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.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Miquel Raïch <miquel.raich@eficent.com>

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.
7 changes: 7 additions & 0 deletions purchase_stock_picking_return_invoicing_open_qty/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services
# <contact@eficent.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from . import wizards
20 changes: 20 additions & 0 deletions purchase_stock_picking_return_invoicing_open_qty/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services
# <contact@eficent.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Purchase Stock Picking Return Invoicing Open Qty",
"summary": "This a glue module to combine two modules",
"version": "9.0.1.0.0",
"category": "Purchases",
"website": "https://github.com/OCA/account-invoicing",
"author": "Eficent, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": [
"purchase_stock_picking_return_invoicing",
"purchase_open_qty",
],
"installable": True,
"auto_install": True,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services
# <contact@eficent.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import purchase_order
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Eficent Business and IT Consulting Services
# <contact@eficent.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openerp import api, fields, models
from openerp.tools.float_utils import float_compare


class PurchaseOrderLine(models.Model):
_inherit = "purchase.order.line"

@api.depends('order_id.state', 'qty_received', 'qty_invoiced',
'product_qty', 'move_ids.state',
'invoice_lines.invoice_id.state', 'invoice_lines.quantity')
def _compute_qty_to_invoice(self):
for line in self:
line.qty_to_invoice = line.product_qty - line.qty_invoiced
precision = self.env['decimal.precision'].precision_get(
'Product Unit of Measure')
for line in self:
line.qty_to_invoice = 0.0
line.qty_to_refund = 0.0
if line.order_id.state != 'purchase':
line.invoice_status = 'no'
continue
else:
if line.product_id.purchase_method == 'receive':
qty = (line.qty_received - line.qty_returned) - (
line.qty_invoiced - line.qty_refunded)
if qty >= 0.0:
line.qty_to_invoice = qty
else:
line.qty_to_refund = abs(qty)
else:
line.qty_to_invoice = line.product_qty - line.qty_invoiced
line.qty_to_refund = 0.0

if line.product_id.purchase_method == 'receive' and not \
line.move_ids.filtered(lambda x: x.state == 'done'):
line.invoice_status = 'to invoice'
# We would like to put 'no', but that would break standard
# odoo tests.
continue

if abs(float_compare(line.qty_to_invoice, 0.0,
precision_digits=precision)) == 1:
line.invoice_status = 'to invoice'
elif abs(float_compare(line.qty_to_refund, 0.0,
precision_digits=precision)) == 1:
line.invoice_status = 'to invoice'
elif float_compare(line.qty_to_invoice, 0.0,
precision_digits=precision) == 0 \
and float_compare(line.qty_to_refund, 0.0,
precision_digits=precision) == 0:
line.invoice_status = 'invoiced'
else:
line.invoice_status = 'no'

qty_to_invoice = fields.Float(compute="_compute_qty_to_invoice")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3ca3ff2

Please sign in to comment.