From 949d579ea411d607db5bf460b0d6c99616dd1b75 Mon Sep 17 00:00:00 2001 From: Jordi Ballester Alomar Date: Fri, 3 Mar 2017 12:07:48 +0100 Subject: [PATCH] [9.0][mig][stock_account_quant_merge] (#256) * stock_account_quant_merge (#199) [ADD] stock_account_quant_merge * OCA Transbot updated translations from Transifex * [9.0][stock_account_quant_merge] Migration to 9.0 --- stock_account_quant_merge/README.rst | 65 ++++++++++ stock_account_quant_merge/__init__.py | 5 + stock_account_quant_merge/__openerp__.py | 18 +++ stock_account_quant_merge/i18n/de.po | 24 ++++ stock_account_quant_merge/i18n/es.po | 24 ++++ stock_account_quant_merge/i18n/fi.po | 24 ++++ stock_account_quant_merge/i18n/fr.po | 24 ++++ stock_account_quant_merge/i18n/it.po | 24 ++++ stock_account_quant_merge/i18n/pt_BR.po | 24 ++++ stock_account_quant_merge/i18n/ro.po | 24 ++++ stock_account_quant_merge/i18n/sl.po | 24 ++++ stock_account_quant_merge/models/__init__.py | 5 + stock_account_quant_merge/models/stock.py | 19 +++ stock_account_quant_merge/tests/__init__.py | 5 + stock_account_quant_merge/tests/test_merge.py | 113 ++++++++++++++++++ 15 files changed, 422 insertions(+) create mode 100644 stock_account_quant_merge/README.rst create mode 100644 stock_account_quant_merge/__init__.py create mode 100644 stock_account_quant_merge/__openerp__.py create mode 100644 stock_account_quant_merge/i18n/de.po create mode 100644 stock_account_quant_merge/i18n/es.po create mode 100644 stock_account_quant_merge/i18n/fi.po create mode 100644 stock_account_quant_merge/i18n/fr.po create mode 100644 stock_account_quant_merge/i18n/it.po create mode 100644 stock_account_quant_merge/i18n/pt_BR.po create mode 100644 stock_account_quant_merge/i18n/ro.po create mode 100644 stock_account_quant_merge/i18n/sl.po create mode 100644 stock_account_quant_merge/models/__init__.py create mode 100644 stock_account_quant_merge/models/stock.py create mode 100644 stock_account_quant_merge/tests/__init__.py create mode 100644 stock_account_quant_merge/tests/test_merge.py diff --git a/stock_account_quant_merge/README.rst b/stock_account_quant_merge/README.rst new file mode 100644 index 000000000..0905dfeb1 --- /dev/null +++ b/stock_account_quant_merge/README.rst @@ -0,0 +1,65 @@ +.. 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 + +========================= +Stock Account Quant merge +========================= + +This module is an extension of "stock_quant_merge", and adds the cost as a +criteria to merge quants. + +Odoo splits quants each time a reservation is done: this module makes Odoo +merge them back if they still meet the following requirements: + +* same product +* same serial number/lot +* same location +* same package +* same unit cost +* same incoming date + +The restriction to only merge quants that have been received in the same +date, with the the same cost is very important when the product is defined +with the real costing method. + +Usage +===== + +The merge is done automatically when a reservation is undone. No user intervention is needed. + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/153/9.0 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 +======= + +Contributors +------------ +* Jordi Ballester Alomar + +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. diff --git a/stock_account_quant_merge/__init__.py b/stock_account_quant_merge/__init__.py new file mode 100644 index 000000000..ea72e9e60 --- /dev/null +++ b/stock_account_quant_merge/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016-17 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import models diff --git a/stock_account_quant_merge/__openerp__.py b/stock_account_quant_merge/__openerp__.py new file mode 100644 index 000000000..9760c9870 --- /dev/null +++ b/stock_account_quant_merge/__openerp__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +# © 2016-17 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Stock Account - Quant merge", + "version": "9.0.1.0.0", + "depends": [ + "stock_account", + "stock_quant_merge" + ], + "author": "Eficent," + "Odoo Community Association (OCA)", + "website": "http://www.eficent.com", + "category": "Warehouse Management", + "installable": True, + "license": "AGPL-3", + "images": [], +} diff --git a/stock_account_quant_merge/i18n/de.po b/stock_account_quant_merge/i18n/de.po new file mode 100644 index 000000000..dbd18c7a0 --- /dev/null +++ b/stock_account_quant_merge/i18n/de.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_account_quant_merge +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-18 03:43+0000\n" +"PO-Revision-Date: 2016-11-18 03:43+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_account_quant_merge +#: model:ir.model,name:stock_account_quant_merge.model_stock_quant +msgid "Quants" +msgstr "Quants" diff --git a/stock_account_quant_merge/i18n/es.po b/stock_account_quant_merge/i18n/es.po new file mode 100644 index 000000000..4766180ef --- /dev/null +++ b/stock_account_quant_merge/i18n/es.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_account_quant_merge +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-18 03:43+0000\n" +"PO-Revision-Date: 2016-11-18 03:43+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: es\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_account_quant_merge +#: model:ir.model,name:stock_account_quant_merge.model_stock_quant +msgid "Quants" +msgstr "Quants" diff --git a/stock_account_quant_merge/i18n/fi.po b/stock_account_quant_merge/i18n/fi.po new file mode 100644 index 000000000..1e6b01df7 --- /dev/null +++ b/stock_account_quant_merge/i18n/fi.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_account_quant_merge +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-18 03:43+0000\n" +"PO-Revision-Date: 2016-11-18 03:43+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Finnish (https://www.transifex.com/oca/teams/23907/fi/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fi\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_account_quant_merge +#: model:ir.model,name:stock_account_quant_merge.model_stock_quant +msgid "Quants" +msgstr "Määrät" diff --git a/stock_account_quant_merge/i18n/fr.po b/stock_account_quant_merge/i18n/fr.po new file mode 100644 index 000000000..8d7746d69 --- /dev/null +++ b/stock_account_quant_merge/i18n/fr.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_account_quant_merge +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-18 03:43+0000\n" +"PO-Revision-Date: 2016-11-18 03:43+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: fr\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: stock_account_quant_merge +#: model:ir.model,name:stock_account_quant_merge.model_stock_quant +msgid "Quants" +msgstr "Quants" diff --git a/stock_account_quant_merge/i18n/it.po b/stock_account_quant_merge/i18n/it.po new file mode 100644 index 000000000..d7ae52b1d --- /dev/null +++ b/stock_account_quant_merge/i18n/it.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_account_quant_merge +# +# Translators: +# Paolo Valier , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-18 03:43+0000\n" +"PO-Revision-Date: 2016-11-18 03:43+0000\n" +"Last-Translator: Paolo Valier , 2016\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" +"Content-Transfer-Encoding: \n" +"Language: it\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: stock_account_quant_merge +#: model:ir.model,name:stock_account_quant_merge.model_stock_quant +msgid "Quants" +msgstr "Quantità" diff --git a/stock_account_quant_merge/i18n/pt_BR.po b/stock_account_quant_merge/i18n/pt_BR.po new file mode 100644 index 000000000..cc27cbc1a --- /dev/null +++ b/stock_account_quant_merge/i18n/pt_BR.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_account_quant_merge +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-18 03:43+0000\n" +"PO-Revision-Date: 2016-11-18 03:43+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/23907/pt_BR/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: pt_BR\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: stock_account_quant_merge +#: model:ir.model,name:stock_account_quant_merge.model_stock_quant +msgid "Quants" +msgstr "Quants" diff --git a/stock_account_quant_merge/i18n/ro.po b/stock_account_quant_merge/i18n/ro.po new file mode 100644 index 000000000..2ecac4e8a --- /dev/null +++ b/stock_account_quant_merge/i18n/ro.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_account_quant_merge +# +# Translators: +# Dorin Hongu , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-18 03:43+0000\n" +"PO-Revision-Date: 2016-11-18 03:43+0000\n" +"Last-Translator: Dorin Hongu , 2016\n" +"Language-Team: Romanian (https://www.transifex.com/oca/teams/23907/ro/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: ro\n" +"Plural-Forms: nplurals=3; plural=(n==1?0:(((n%100>19)||((n%100==0)&&(n!=0)))?2:1));\n" + +#. module: stock_account_quant_merge +#: model:ir.model,name:stock_account_quant_merge.model_stock_quant +msgid "Quants" +msgstr "Poziții de stoc" diff --git a/stock_account_quant_merge/i18n/sl.po b/stock_account_quant_merge/i18n/sl.po new file mode 100644 index 000000000..58204895e --- /dev/null +++ b/stock_account_quant_merge/i18n/sl.po @@ -0,0 +1,24 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * stock_account_quant_merge +# +# Translators: +# OCA Transbot , 2016 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 8.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2016-11-18 03:43+0000\n" +"PO-Revision-Date: 2016-11-18 03:43+0000\n" +"Last-Translator: OCA Transbot , 2016\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Language: sl\n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n" + +#. module: stock_account_quant_merge +#: model:ir.model,name:stock_account_quant_merge.model_stock_quant +msgid "Quants" +msgstr "Kvant" diff --git a/stock_account_quant_merge/models/__init__.py b/stock_account_quant_merge/models/__init__.py new file mode 100644 index 000000000..2701b5567 --- /dev/null +++ b/stock_account_quant_merge/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016-17 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import stock diff --git a/stock_account_quant_merge/models/stock.py b/stock_account_quant_merge/models/stock.py new file mode 100644 index 000000000..023cd286a --- /dev/null +++ b/stock_account_quant_merge/models/stock.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# © 2016-17 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp import api, models + + +class StockQuant(models.Model): + _inherit = 'stock.quant' + + @api.multi + def _mergeable_domain(self): + domain = super(StockQuant, self)._mergeable_domain() + + if self.product_id.cost_method == 'real': + domain += [('cost', '=', self.cost), + ('in_date', '=', self.in_date)] + + return domain diff --git a/stock_account_quant_merge/tests/__init__.py b/stock_account_quant_merge/tests/__init__.py new file mode 100644 index 000000000..4abb5e717 --- /dev/null +++ b/stock_account_quant_merge/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016-17 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from . import test_merge diff --git a/stock_account_quant_merge/tests/test_merge.py b/stock_account_quant_merge/tests/test_merge.py new file mode 100644 index 000000000..1eccde9eb --- /dev/null +++ b/stock_account_quant_merge/tests/test_merge.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +# © 2016-17 Eficent Business and IT Consulting Services S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openerp.addons.stock.tests.common import TestStockCommon + + +class TestMerge(TestStockCommon): + """Test the potential quantity on a product with a multi-line BoM""" + + def setUp(self): + super(TestMerge, self).setUp() + loc_supplier_id = self.env.ref('stock.stock_location_suppliers') + self.loc_stock = self.env.ref('stock.stock_location_stock') + self.loc_scrap = self.env.ref('stock.stock_location_scrapped') + self.product = self.env.ref('product.product_product_36') + + # Zero out the inventory of the product + inventory = self.env['stock.inventory'].create( + {'name': 'Remove product for test', + 'location_id': self.loc_stock.id, + 'filter': 'product', + 'product_id': self.product.id}) + inventory.prepare_inventory() + inventory.reset_real_qty() + inventory.action_done() + + self.picking_obj = self.env['stock.picking'] + move_obj = self.env['stock.move'] + + self.picking_type = self.env.ref('stock.picking_type_in') + + # Change the cost method to 'Real Price' + self.product.cost_method = 'real' + + self.picking_1 = self.picking_obj.create( + {'picking_type_id': self.picking_type.id, + 'location_id': loc_supplier_id.id, + 'location_dest_id': self.loc_stock.id + }) + move_obj.create({'name': '/', + 'picking_id': self.picking_1.id, + 'product_uom': self.product.uom_id.id, + 'location_id': loc_supplier_id.id, + 'location_dest_id': self.loc_stock.id, + 'product_id': self.product.id, + 'price_unit': 10, + 'product_uom_qty': 10}) + self.picking_1.action_confirm() + self.picking_1.action_assign() + self.picking_1.action_done() + + self.picking_2 = self.picking_obj.create( + {'picking_type_id': self.picking_type.id, + 'location_id': loc_supplier_id.id, + 'location_dest_id': self.loc_stock.id + }) + move_obj.create({'name': '/', + 'picking_id': self.picking_2.id, + 'product_uom': self.product.uom_id.id, + 'location_id': loc_supplier_id.id, + 'location_dest_id': self.loc_stock.id, + 'product_id': self.product.id, + 'price_unit': 20, + 'product_uom_qty': 10}) + self.picking_2.action_confirm() + self.picking_2.action_assign() + self.picking_2.action_done() + + def test_merge(self): + quant_obj = self.env['stock.quant'] + domain = [('location_id', '=', self.loc_stock.id), + ('product_id', '=', self.product.id)] + + quants = quant_obj.search(domain) + self.assertEqual(len(quants), 2, "There should be 2 quants") + + # Make a reservation to split the quants + move_1 = self.env['stock.move'].create( + {'name': 'Test move', + 'product_id': self.product.id, + 'location_id': self.loc_stock.id, + 'location_dest_id': self.loc_scrap.id, + 'product_uom_qty': 15.0, + 'product_uom': self.product.uom_id.id}) + move_1.action_confirm() + move_1.action_assign() + + # Make a reservation to split the quants + move_2 = self.env['stock.move'].create( + {'name': 'Test move', + 'product_id': self.product.id, + 'location_id': self.loc_stock.id, + 'location_dest_id': self.loc_scrap.id, + 'product_uom_qty': 3.0, + 'product_uom': self.product.uom_id.id}) + move_2.action_confirm() + move_2.action_assign() + + quants = quant_obj.search(domain) + self.assertEqual(len(quants), 4, "There should be 4 quants") + + # Cancel the second move : the quants with unit cost 20 should be + # merged back together + move_2.action_cancel() + quants = quant_obj.search(domain) + self.assertEqual(len(quants), 3, "There should be 3 quants") + + # Cancel the first move : the quants with unit cost 20 should be + # merged back together + move_1.action_cancel() + quants = quant_obj.search(domain) + self.assertEqual(len(quants), 2, "There should be 2 quants")