forked from OCA/stock-logistics-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[9.0] stock_picking_invoice_link: redo migration from 8.0 to 9.0 (OCA…
…#296) Previous migration did not keep the business functionality of the previous module. Link from invoice to picking must link only related delivery and not all deliveries in case of partial delivery
- Loading branch information
Showing
11 changed files
with
232 additions
and
73 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 |
---|---|---|
|
@@ -2,17 +2,23 @@ | |
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
================================== | ||
Link between invoices and pickings | ||
================================== | ||
======================================== | ||
Link between invoices and their pickings | ||
======================================== | ||
|
||
This module adds a link between pickings and invoices. | ||
So that user can easily reach the invoices related to the picking | ||
and see the pickings related to the invoice. | ||
This module adds a link between pickings and invoices as well as on the lines. | ||
Invoices are generated from sales orders. With this module, you can find back | ||
which deliveries an invoice relates to. | ||
|
||
As the invoincing flow has changed in odoo version 9, | ||
invoices linked to pickings (and vice versa), are shown independently from | ||
the invoicing method | ||
In standard, if you make a partial delivery and invoice it, then make remaining | ||
delivery and invoice it, it is impossible to known to what delivery the | ||
invoices relate to. You only have the quantity. | ||
|
||
This module is also useful if you want to present data on the invoice report | ||
grouped by deliveries. | ||
|
||
Note that the links are only for products with an invoicing policy set on | ||
delivery. | ||
|
||
Usage | ||
===== | ||
|
@@ -32,6 +38,11 @@ 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 | ||
------------ | ||
|
||
|
@@ -44,18 +55,19 @@ Contributors | |
* Unai Alkorta | ||
* Iñaki Zabala | ||
* Oihane Crucelaegui <[email protected]> | ||
* Jacques-Etienne Baudoux <[email protected]> | ||
|
||
Maintainer | ||
---------- | ||
|
||
.. image:: http://odoo-community.org/logo.png | ||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: http://odoo-community.org | ||
: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 http://odoo-community.org. | ||
To contribute to this module, please visit https://odoo-community.org. |
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 |
---|---|---|
|
@@ -2,15 +2,17 @@ | |
# © 2013-15 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# © 2016 AvanzOSC (<http://www.avanzosc.es>) | ||
# © 2016 Pedro M. Baeza <[email protected]> | ||
# © 2017 Jacques-Etienne Baudoux <[email protected]> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
{ | ||
'name': 'Stock Picking Invoice Link', | ||
'version': '9.0.1.1.0', | ||
'version': '9.0.2.0.0', | ||
'category': 'Warehouse Management', | ||
'summary': 'Adds link between pickings and invoices', | ||
'author': 'Agile Business Group, ' | ||
'Tecnativa, ' | ||
'BCIM sprl, ' | ||
'Odoo Community Association (OCA)', | ||
'website': 'http://www.agilebg.com', | ||
'license': 'AGPL-3', | ||
|
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 |
---|---|---|
|
@@ -4,14 +4,13 @@ | |
# | ||
# Translators: | ||
# OCA Transbot <[email protected]>, 2017 | ||
# Paolo Valier <[email protected]>, 2017 | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 9.0c\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2017-01-23 11:56+0000\n" | ||
"PO-Revision-Date: 2017-01-23 11:56+0000\n" | ||
"Last-Translator: Paolo Valier <[email protected]>, 2017\n" | ||
"POT-Creation-Date: 2017-06-15 11:08+0000\n" | ||
"PO-Revision-Date: 2017-06-15 11:08+0000\n" | ||
"Last-Translator: OCA Transbot <[email protected]>, 2017\n" | ||
"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
|
@@ -21,23 +20,24 @@ msgstr "" | |
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model,name:stock_picking_invoice_link.model_account_invoice | ||
#: model:ir.model.fields,field_description:stock_picking_invoice_link.field_stock_picking_invoice_id | ||
#: model:ir.ui.view,arch_db:stock_picking_invoice_link.view_picking_form | ||
msgid "Invoice" | ||
msgstr "Fattura" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model,name:stock_picking_invoice_link.model_account_invoice_line | ||
#: model:ir.model.fields,field_description:stock_picking_invoice_link.field_stock_move_invoice_line_id | ||
msgid "Invoice Line" | ||
msgstr "Riga Fattura" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model.fields,field_description:stock_picking_invoice_link.field_stock_move_invoice_line_ids | ||
#: model:ir.ui.view,arch_db:stock_picking_invoice_link.view_move_form | ||
msgid "Invoice Lines" | ||
msgstr "Righe Fattura" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model.fields,field_description:stock_picking_invoice_link.field_stock_picking_invoice_ids | ||
#: model:ir.ui.view,arch_db:stock_picking_invoice_link.view_picking_form | ||
msgid "Invoices" | ||
msgstr "Fatture" | ||
|
||
|
@@ -56,6 +56,25 @@ msgstr "Picking Correlati" | |
msgid "Related Stock Moves" | ||
msgstr "Movimenti di Magazzino Correlati" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model.fields,help:stock_picking_invoice_link.field_account_invoice_picking_ids | ||
msgid "" | ||
"Related pickings (only when the invoice has been generated from a sale " | ||
"order)." | ||
msgstr "" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model.fields,help:stock_picking_invoice_link.field_account_invoice_line_move_line_ids | ||
msgid "" | ||
"Related stock moves (only when the invoice has been generated from a sale " | ||
"order)." | ||
msgstr "" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model,name:stock_picking_invoice_link.model_sale_order_line | ||
msgid "Sales Order Line" | ||
msgstr "" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model,name:stock_picking_invoice_link.model_stock_move | ||
msgid "Stock Move" | ||
|
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 |
---|---|---|
|
@@ -8,8 +8,8 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: Odoo Server 9.0c\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2017-01-23 11:56+0000\n" | ||
"PO-Revision-Date: 2017-01-23 11:56+0000\n" | ||
"POT-Creation-Date: 2017-06-15 11:08+0000\n" | ||
"PO-Revision-Date: 2017-06-15 11:08+0000\n" | ||
"Last-Translator: OCA Transbot <[email protected]>, 2017\n" | ||
"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" | ||
"MIME-Version: 1.0\n" | ||
|
@@ -20,23 +20,24 @@ msgstr "" | |
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model,name:stock_picking_invoice_link.model_account_invoice | ||
#: model:ir.model.fields,field_description:stock_picking_invoice_link.field_stock_picking_invoice_id | ||
#: model:ir.ui.view,arch_db:stock_picking_invoice_link.view_picking_form | ||
msgid "Invoice" | ||
msgstr "Fatura" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model,name:stock_picking_invoice_link.model_account_invoice_line | ||
#: model:ir.model.fields,field_description:stock_picking_invoice_link.field_stock_move_invoice_line_id | ||
msgid "Invoice Line" | ||
msgstr "Linha da Fatura" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model.fields,field_description:stock_picking_invoice_link.field_stock_move_invoice_line_ids | ||
#: model:ir.ui.view,arch_db:stock_picking_invoice_link.view_move_form | ||
msgid "Invoice Lines" | ||
msgstr "Linhas da Fatura" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model.fields,field_description:stock_picking_invoice_link.field_stock_picking_invoice_ids | ||
#: model:ir.ui.view,arch_db:stock_picking_invoice_link.view_picking_form | ||
msgid "Invoices" | ||
msgstr "Faturas" | ||
|
||
|
@@ -55,6 +56,25 @@ msgstr "Separações Relacionadas" | |
msgid "Related Stock Moves" | ||
msgstr "Movimentações de Estoque Relacionadas" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model.fields,help:stock_picking_invoice_link.field_account_invoice_picking_ids | ||
msgid "" | ||
"Related pickings (only when the invoice has been generated from a sale " | ||
"order)." | ||
msgstr "" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model.fields,help:stock_picking_invoice_link.field_account_invoice_line_move_line_ids | ||
msgid "" | ||
"Related stock moves (only when the invoice has been generated from a sale " | ||
"order)." | ||
msgstr "" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model,name:stock_picking_invoice_link.model_sale_order_line | ||
msgid "Sales Order Line" | ||
msgstr "" | ||
|
||
#. module: stock_picking_invoice_link | ||
#: model:ir.model,name:stock_picking_invoice_link.model_stock_move | ||
msgid "Stock Move" | ||
|
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
from . import account_invoice | ||
from . import stock_move | ||
from . import stock_picking | ||
from . import sale_order |
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 |
---|---|---|
|
@@ -2,37 +2,29 @@ | |
# © 2013-15 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# © 2015-2016 AvanzOSC | ||
# © 2016 Pedro M. Baeza <[email protected]> | ||
# © 2017 Jacques-Etienne Baudoux <[email protected]> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from openerp import api, fields, models | ||
from openerp import fields, models | ||
|
||
|
||
class AccountInvoice(models.Model): | ||
_inherit = "account.invoice" | ||
|
||
picking_ids = fields.Many2many( | ||
comodel_name='stock.picking', string='Related Pickings', | ||
compute="_compute_picking_ids") | ||
|
||
@api.multi | ||
def _compute_picking_ids(self): | ||
for invoice in self: | ||
invoice.picking_ids = self.env['stock.picking'] | ||
for line in invoice.invoice_line_ids: | ||
invoice.picking_ids |= line.move_line_ids.mapped('picking_id') | ||
comodel_name='stock.picking', string='Related Pickings', readonly=True, | ||
copy=False, | ||
help="Related pickings " | ||
"(only when the invoice has been generated from a sale order).") | ||
|
||
|
||
class AccountInvoiceLine(models.Model): | ||
_inherit = "account.invoice.line" | ||
|
||
move_line_ids = fields.Many2many( | ||
comodel_name='stock.move', string='Related Stock Moves', | ||
compute="_compute_move_line_ids") | ||
|
||
@api.multi | ||
def _compute_move_line_ids(self): | ||
for line in self: | ||
line.move_line_ids = self.env['stock.move'] | ||
for sale_line in line.sale_line_ids: | ||
for proc in sale_line.procurement_ids: | ||
line.move_line_ids |= proc.move_ids | ||
move_line_ids = fields.One2many( | ||
'stock.move', 'invoice_line_id', | ||
string='Related Stock Moves', | ||
readonly=True, | ||
copy=False, | ||
help="Related stock moves " | ||
"(only when the invoice has been generated from a sale order).") |
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,34 @@ | ||
# -*- coding: utf-8 -*- | ||
# © 2013-15 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# © 2017 Jacques-Etienne Baudoux <[email protected]> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from openerp import api, models | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
_inherit = "sale.order.line" | ||
|
||
@api.multi | ||
def invoice_line_create(self, invoice_id, qty): | ||
self.mapped('procurement_ids') \ | ||
.mapped('move_ids') \ | ||
.filtered( | ||
lambda x: x.state == 'done' and | ||
not x.invoice_line_id and | ||
not x.location_dest_id.scrap_location and | ||
x.location_dest_id.usage == 'customer') \ | ||
.mapped('picking_id') \ | ||
.write({'invoice_ids': [(4, invoice_id)]}) | ||
return super(SaleOrderLine, self).invoice_line_create(invoice_id, qty) | ||
|
||
@api.multi | ||
def _prepare_invoice_line(self, qty): | ||
vals = super(SaleOrderLine, self)._prepare_invoice_line(qty) | ||
move_ids = self.mapped('procurement_ids').mapped('move_ids').filtered( | ||
lambda x: x.state == 'done' and | ||
not x.invoice_line_id and | ||
not x.location_dest_id.scrap_location and | ||
x.location_dest_id.usage == 'customer').ids | ||
vals['move_line_ids'] = [(6, 0, move_ids)] | ||
return vals |
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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# © 2013-15 Agile Business Group sagl (<http://www.agilebg.com>) | ||
# © 2015-2016 AvanzOSC | ||
# © 2016 Pedro M. Baeza <[email protected]> | ||
# © 2017 Jacques-Etienne Baudoux <[email protected]> | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
|
||
from openerp import api, fields, models | ||
|
@@ -11,13 +12,15 @@ class StockPicking(models.Model): | |
_inherit = "stock.picking" | ||
|
||
invoice_ids = fields.Many2many( | ||
comodel_name='account.invoice', string='Invoices', | ||
compute="_compute_invoice_ids") | ||
comodel_name='account.invoice', copy=False, string='Invoices', | ||
readonly=True) | ||
# Provide this field for backwards compatibility | ||
invoice_id = fields.Many2one( | ||
comodel_name='account.invoice', string='Invoice', | ||
compute="_compute_invoice_id") | ||
|
||
@api.multi | ||
def _compute_invoice_ids(self): | ||
@api.depends('invoice_ids') | ||
def _compute_invoice_id(self): | ||
for picking in self: | ||
invoices = self.env['account.invoice'] | ||
for line in picking.move_lines: | ||
invoices |= line.invoice_line_ids.mapped('invoice_id') | ||
picking.invoice_ids = invoices | ||
picking.invoice_id = picking.invoice_ids[:1] |
Oops, something went wrong.