Skip to content

Commit

Permalink
[MIG] stock_quant_merge to v10
Browse files Browse the repository at this point in the history
  • Loading branch information
LoisRForgeFlow committed Mar 16, 2017
1 parent 90d6d05 commit 00a2082
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
1 change: 1 addition & 0 deletions stock_quant_merge/README.rst
Expand Up @@ -40,6 +40,7 @@ Contributors
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Ana Juaristi <ajuaristio@gmail.com>
* Lionel Sausin <ls@numerigraphe.com>
* Lois Rilo <lois.rilo@eficent.com>

Maintainer
----------
Expand Down
2 changes: 2 additions & 0 deletions stock_quant_merge/__init__.py
Expand Up @@ -2,5 +2,7 @@
# © 2015 OdooMRP team
# © 2015 AvanzOSC
# © 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
# © 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
5 changes: 3 additions & 2 deletions stock_quant_merge/__manifest__.py
Expand Up @@ -2,10 +2,11 @@
# © 2015 OdooMRP team
# © 2015 AvanzOSC
# © 2015 Pedro M. Baeza <pedro.baeza@tecnativa.com>
# © 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Stock - Quant merge",
"version": "9.0.1.0.0",
"version": "10.0.1.0.0",
"depends": [
"stock",
],
Expand All @@ -15,6 +16,6 @@
"Odoo Community Association (OCA)",
"website": "http://www.odoomrp.com",
"category": "Warehouse Management",
'installable': False,
'installable': True,
"license": "AGPL-3",
}
4 changes: 3 additions & 1 deletion stock_quant_merge/models/__init__.py
Expand Up @@ -2,6 +2,8 @@
# © 2015 OdooMRP team
# © 2015 AvanzOSC
# © 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
# © 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import stock
from . import stock_quant
from . import stock_move
15 changes: 15 additions & 0 deletions stock_quant_merge/models/stock_move.py
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# © 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class StockMove(models.Model):
_inherit = 'stock.move'

@api.model
def quants_unreserve(self):
quants = self.reserved_quant_ids
super(StockMove, self).quants_unreserve()
quants.merge_stock_quants()
Expand Up @@ -2,9 +2,10 @@
# © 2015 OdooMRP team
# © 2015 AvanzOSC
# © 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
# © 2017 Eficent Business and IT Consulting Services S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, api
from odoo import api, models


class StockQuant(models.Model):
Expand Down Expand Up @@ -32,17 +33,11 @@ def merge_stock_quants(self):
cont = 1
cost = quant2merge.cost
for quant in quants:
if (self._get_latest_move(quant2merge) ==
self._get_latest_move(quant)):
if (quant2merge._get_latest_move() ==
quant._get_latest_move()):
quant2merge.sudo().qty += quant.qty
cost += quant.cost
cont += 1
pending_quants -= quant
quant.with_context(force_unlink=True).sudo().unlink()
quant2merge.sudo().cost = cost / cont

@api.model
def quants_unreserve(self, move):
quants = move.reserved_quant_ids
super(StockQuant, self).quants_unreserve(move)
quants.merge_stock_quants()
2 changes: 1 addition & 1 deletion stock_quant_merge/tests/test_merge.py
Expand Up @@ -2,7 +2,7 @@
# © 2015 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp.tests.common import TransactionCase
from odoo.tests.common import TransactionCase


class TestMerge(TransactionCase):
Expand Down

0 comments on commit 00a2082

Please sign in to comment.