Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][ADD]sale_order_type_invoice_policy_invoice_link:new module #591

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions sale_order_type_invoice_policy_invoice_link/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.. |company| replace:: ADHOC SA

.. |company_logo| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-logo.png
:alt: ADHOC SA
:target: https://www.adhoc.com.ar

.. |icon| image:: https://raw.githubusercontent.com/ingadhoc/maintainer-tools/master/resources/adhoc-icon.png

.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

===========================================
sale order type invoice policy invoice link
===========================================

Bridge module between sale_order_type_invoice_policy and stock_picking_invoice_link.

Installation
============

To install this module, you need to:

#. Only need to install the module

Configuration
=============

To configure this module, you need to:

#. Only need to install the module

Usage
=====

To use this module, you need to:

#. Go to ...

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: http://runbot.adhoc.com.ar/

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

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

* |company| |icon|

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

Maintainer
----------

|company_logo|

This module is maintained by the |company|.

To contribute to this module, please visit https://www.adhoc.com.ar.
5 changes: 5 additions & 0 deletions sale_order_type_invoice_policy_invoice_link/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import models
41 changes: 41 additions & 0 deletions sale_order_type_invoice_policy_invoice_link/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
##############################################################################
#
# Copyright (C) 2015 ADHOC SA (http://www.adhoc.com.ar)
# All Rights Reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'sale order type invoice policy invoice link',
'version': "16.0.1.0.0",
'category': 'Warehouse Management',
'sequence': 14,
'summary': '',
'author': 'ADHOC SA',
'website': 'www.adhoc.com.ar',
'license': 'AGPL-3',
'images': [
],
'depends': [
'sale_order_type_invoice_policy','stock_picking_invoice_link'
],
'data': [
],
'demo': [
],
'installable': False,
'auto_install': True,
'application': False,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##############################################################################
# For copyright and license notices, see __manifest__.py file in module root
# directory
##############################################################################
from . import stock_move
23 changes: 23 additions & 0 deletions sale_order_type_invoice_policy_invoice_link/models/stock_move.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

from odoo.addons.stock_picking_invoice_link.models.stock_move import StockMove


def new_write(self, vals):
# monkey patch to take in consideration both module stock_picking_invoice_link and sale_order_type_invoice_policy
if "product_uom_qty" in vals and not self.env.context.get(
"bypass_stock_move_update_restriction"
):
for move in self:
if move.state == "done" and move.invoice_line_ids:
raise UserError(_("You can not modify an invoiced stock move"))
res = super(StockMove, self).write(vals)
if vals.get("state", "") == 'done':
stock_moves = self.get_moves_delivery_link_invoice()
for stock_move in stock_moves.filtered(lambda sm: sm.sale_line_id and (sm.sale_line_id.order_id.type_id.invoice_policy == "order" or sm.sale_line_id.order_id.type_id.invoice_policy == "by_product" and sm.product_id.invoice_policy == "order")):
inv_type = stock_move.to_refund and "out_refund" or "out_invoice"
inv_line = (self.env["account.move.line"].sudo().search([('sale_line_ids','=',stock_move.sale_line_id.id),('move_id.move_type','=',inv_type)]))
if inv_line:
stock_move.invoice_line_ids = [(4, m.id) for m in inv_line]
return res

StockMove.write = new_write