Skip to content

Commit

Permalink
Merge pull request #81 from numerigraphe/8.0-stock-available-sale
Browse files Browse the repository at this point in the history
Migrate stock_available_sale to v8
  • Loading branch information
moylop260 committed Nov 20, 2015
2 parents 99ea7ad + 449071b commit bcf19ba
Show file tree
Hide file tree
Showing 25 changed files with 481 additions and 568 deletions.
20 changes: 2 additions & 18 deletions stock_available/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module is copyright (C) 2014 Numérigraphe SARL. 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/>.
#
##############################################################################
# © 2014 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
23 changes: 3 additions & 20 deletions stock_available/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module is copyright (C) 2014 Numérigraphe SARL. 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/>.
#
##############################################################################

# © 2014 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': 'Stock available to promise',
'version': '8.0.2.0.0',
'version': '8.0.3.0.0',
"author": u"Numérigraphe,Odoo Community Association (OCA)",
'category': 'Warehouse',
'depends': ['stock'],
Expand Down
20 changes: 2 additions & 18 deletions stock_available/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module is copyright (C) 2014 Numérigraphe SARL. 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/>.
#
##############################################################################
# © 2014 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import product_template
from . import product_product
Expand Down
27 changes: 7 additions & 20 deletions stock_available/models/product_product.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module is copyright (C) 2014 Numérigraphe SARL. 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/>.
#
##############################################################################
# © 2014 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields, api
from openerp.addons import decimal_precision as dp
Expand All @@ -36,8 +20,11 @@ def _immediately_usable_qty(self):
By default, available to promise = forecasted quantity.
Must be overridden by another module that actually implement
computations."""
**Each** sub-module **must** override this method in **both**
`product.product` **and** `product.template`, because we can't
decide in advance how to compute the template's quantity from the
variants.
"""
for prod in self:
prod.immediately_usable_qty = prod.virtual_available

Expand Down
35 changes: 12 additions & 23 deletions stock_available/models/product_template.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module is copyright (C) 2014 Numérigraphe SARL. 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/>.
#
##############################################################################
# © 2014 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields, api
from openerp.addons import decimal_precision as dp
Expand All @@ -28,12 +12,17 @@ class ProductTemplate(models.Model):
@api.multi
@api.depends('product_variant_ids.immediately_usable_qty')
def _immediately_usable_qty(self):
"""Compute the quantity using all the variants"""
"""No-op implementation of the stock available to promise.
By default, available to promise = forecasted quantity.
**Each** sub-module **must** override this method in **both**
`product.product` **and** `product.template`, because we can't
decide in advance how to compute the template's quantity from the
variants.
"""
for tmpl in self:
tmpl.immediately_usable_qty = sum(
v.immediately_usable_qty
for v in tmpl.product_variant_ids
)
tmpl.immediately_usable_qty = tmpl.virtual_available

immediately_usable_qty = fields.Float(
digits=dp.get_precision('Product Unit of Measure'),
Expand Down
34 changes: 9 additions & 25 deletions stock_available/models/res_config.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# This module is copyright (C) 2014 Numérigraphe SARL. All Rights Reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2014 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, fields

Expand All @@ -31,13 +15,13 @@ class StockConfig(models.TransientModel):
"available to promise.\n"
"This installs the module stock_available_immediately.")

# module_stock_available_sale = fields.Boolean(
# string='Exclude goods already in sale quotations',
# help="This will subtract quantities from the sale quotations from "
# "the quantities available to promise.\n"
# "This installs the modules stock_available_sale.\n"
# "If the modules sale and sale_delivery_date are not "
# "installed, this will install them too")
module_stock_available_sale = fields.Boolean(
string='Exclude goods already in sale quotations',
help="This will subtract quantities from the sale quotations from "
"the quantities available to promise.\n"
"This installs the modules stock_available_sale.\n"
"If the modules sale and sale_delivery_date are not "
"installed, this will install them too")

# module_stock_available_mrp = fields.Boolean(
# string='Include the production potential',
Expand Down
4 changes: 2 additions & 2 deletions stock_available/views/res_config_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
<field name="module_stock_available_immediately" class="oe_inline" />
<label for="module_stock_available_immediately" />
</div>
<!-- <div>
<div>
<field name="module_stock_available_sale" class="oe_inline" />
<label for="module_stock_available_sale" />
</div> -->
</div>
<!-- <div>
<field name="module_stock_available_mrp" class="oe_inline" />
<label for="module_stock_available_mrp" />
Expand Down
20 changes: 2 additions & 18 deletions stock_available_immediately/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author Guewen Baconnier. Copyright Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import models
25 changes: 4 additions & 21 deletions stock_available_immediately/__openerp__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
# -*- coding: utf-8 -*-
#
#
# Author: Guewen Baconnier
# Copyright 2010-2012 Camptocamp SA
# Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
#
# 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/>.
#
#
# © 2010-2012 Camptocamp SA
# © 2011 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
"name": "Ignore planned receptions in quantity available to promise",
"version": "8.0.2.0.0",
"version": "8.0.2.0.1",
"depends": ["stock_available"],
"author": "Camptocamp,Odoo Community Association (OCA)",
"license": "AGPL-3",
Expand Down
21 changes: 3 additions & 18 deletions stock_available_immediately/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Author Guewen Baconnier. Copyright Camptocamp SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import product_product
from . import product_template
26 changes: 6 additions & 20 deletions stock_available_immediately/models/product_product.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright 2010-2012 Camptocamp SA
# Copyright (C) 2011 Akretion Sébastien BEAU <sebastien.beau@akretion.com>
#
# 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/>.
#
##############################################################################
# © 2010-2012 Camptocamp SA
# © 2011 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, api

Expand All @@ -28,7 +12,9 @@ class ProductProduct(models.Model):
@api.multi
@api.depends('virtual_available', 'incoming_qty')
def _immediately_usable_qty(self):
"""Ignore the incoming goods in the quantity available to promise"""
"""Ignore the incoming goods in the quantity available to promise
This is the same implementation as for templates."""
super(ProductProduct, self)._immediately_usable_qty()
for prod in self:
prod.immediately_usable_qty -= prod.incoming_qty
19 changes: 19 additions & 0 deletions stock_available_immediately/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
# © 2015 Numérigraphe SARL
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, api


class ProductTemplate(models.Model):
_inherit = 'product.template'

@api.multi
@api.depends('virtual_available', 'incoming_qty')
def _immediately_usable_qty(self):
"""Ignore the incoming goods in the quantity available to promise
This is the same implementation as for variants."""
super(ProductTemplate, self)._immediately_usable_qty()
for tmpl in self:
tmpl.immediately_usable_qty -= tmpl.incoming_qty
2 changes: 2 additions & 0 deletions stock_available_immediately/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import test_stock_available_immediately
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2015 Therp BV <http://therp.nl>
#
# 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/>.
#
##############################################################################
# © 2015 Therp BV <http://therp.nl>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp.tests.common import TransactionCase


Expand Down

0 comments on commit bcf19ba

Please sign in to comment.