-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD]sale_order_type_invoice_policy_invoice_link:new module
X-original-commit: fb4e43a
- Loading branch information
Showing
5 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
41
sale_order_type_invoice_policy_invoice_link/__manifest__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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': True, | ||
'auto_install': True, | ||
'application': False, | ||
} |
5 changes: 5 additions & 0 deletions
5
sale_order_type_invoice_policy_invoice_link/models/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
23
sale_order_type_invoice_policy_invoice_link/models/stock_move.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |