Skip to content

Commit

Permalink
[MIG] packaging_uom, purchase_packaging, sale_packaging: Migrated to …
Browse files Browse the repository at this point in the history
…10.0
  • Loading branch information
lmignon committed Mar 15, 2017
1 parent b167451 commit e49dca1
Show file tree
Hide file tree
Showing 55 changed files with 1,055 additions and 1,201 deletions.
23 changes: 14 additions & 9 deletions packaging_uom/README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

Packaging UOM
=============
Expand All @@ -25,22 +26,26 @@ To configure this module, you need to:
Usage
=====

For further information, please visit:

* https://www.odoo.com/forum/help-1
.. 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/10.0

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/stock-logistics-warehouse/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
`here <https://github.com/OCA/stock-logistics-warehouse/issues/new?body=module:%20packaging_extended%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/stock-logistics-warehouse/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
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

Expand Down
3 changes: 2 additions & 1 deletion packaging_uom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models
18 changes: 18 additions & 0 deletions packaging_uom/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
"name": "Packaging UOM",
"version": "10.0.1.0.0",
"author": 'ACSONE SA/NV, '
'Odoo Community Association (OCA)',
"category": "Warehouse",
"website": "http://www.acsone.eu",
'summary': "Use uom in package",
"depends": ["product",
],
"data": ["views/product_packaging_views.xml",
],
"license": "AGPL-3",
"installable": True,
}
36 changes: 0 additions & 36 deletions packaging_uom/__openerp__.py

This file was deleted.

2 changes: 2 additions & 0 deletions packaging_uom/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import product_packaging
48 changes: 19 additions & 29 deletions packaging_uom/models/product_packaging.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Authors: Laetitia Gangloff
# Copyright (c) 2015 Acsone SA/NV (http://www.acsone.eu)
#
# 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/>.
#
##############################################################################


from openerp import api, fields, models
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import api, fields, models


class ProductPackaging(models.Model):
Expand All @@ -34,13 +15,22 @@ def _default_uom_categ_domain_id(self):
uom = self.env['product.uom'].browse(uom_id)
return uom.category_id.id

uom_id = fields.Many2one('product.uom', 'Unit of Measure', required=True,
help="It must be in the same category than "
"the default unit of measure.")
uom_id = fields.Many2one(
'product.uom',
'Unit of Measure',
required=True,
help="It must be in the same category than "
"the default unit of measure."
)
uom_categ_domain_id = fields.Many2one(
default=_default_uom_categ_domain_id,
comodel_name='product.uom.categ')
qty = fields.Float(compute="_compute_qty", store=True, readonly=True)
comodel_name='product.uom.categ'
)
qty = fields.Float(
compute="_compute_qty",
store=True,
readonly=True
)

@api.one
@api.depends('uom_id', 'product_tmpl_id.uom_id')
Expand All @@ -49,7 +39,7 @@ def _compute_qty(self):
Compute the quantity by package based on uom
"""
if self.uom_id and self.product_tmpl_id:
self.qty = self.env['product.uom']._compute_qty_obj(
self.uom_id, 1, self.product_tmpl_id.uom_id)
self.qty = self.uom_id._compute_quantity(
1, to_unit=self.product_tmpl_id.uom_id)
else:
self.qty = 0
Binary file added packaging_uom/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion packaging_uom/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import test_packaging
from . import test_product_packaging
82 changes: 0 additions & 82 deletions packaging_uom/tests/test_packaging.py

This file was deleted.

71 changes: 71 additions & 0 deletions packaging_uom/tests/test_product_packaging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*-
# Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import odoo.tests.common as common


class TestProductPackaging(common.TransactionCase):

def setUp(self):
super(TestProductPackaging, self).setUp()
self.uom_unit = self.env.ref('product.product_uom_unit')
self.uom_dozen = self.env.ref('product.product_uom_dozen')
self.product_tmpl_dozen = self.env[
'product.template'].new(
{'uom_id': self.uom_dozen})
self.product_tmpl_unit = self.env[
'product.template'].new(
{'uom_id': self.uom_unit})

def test_compute_quantity_by_package(self):
""" Create a packagings with uom product_uom_dozen on
* product_tmpl_dozen (uom is product_uom_dozen)
* product_tmpl_unit (uom is product_uom_unit)
Result should be :
* product_tmpl_dozen -> qty by package : 1
* product_tmpl_unit -> qty by package : 12
Create product_uom_24
Update product_tmpl_dozen to set this new uom
Result should be :
* product_tmpl_dozen -> qty by package : 0.5
Update product_package_unit to set this new uom
Result should be :
* product_packaging_unit -> qty by package : 24
Create product_uom 6
Update product_tmpl_dozen to set this new uom
Result should be :
* product_packaging_dozen -> qty by package : 2
Update product_packaging_unit to set this new uom
Result should be :
* product_packaging_unit -> qty by package : 6
"""

packaging_obj = self.env['product.packaging']
product_packaging_dozen = packaging_obj.new(
{'product_tmpl_id': self.product_tmpl_dozen,
'uom_id': self.uom_dozen})
self.assertAlmostEqual(product_packaging_dozen.qty, 1)
product_packaging_unit = packaging_obj.new(
{'product_tmpl_id': self.product_tmpl_unit,
'uom_id': self.uom_dozen})
self.assertAlmostEqual(product_packaging_unit.qty, 12)
product_uom_24 = self.env['product.uom'].create(
{'category_id': self.env.ref('product.product_uom_categ_unit').id,
'name': 'Double Dozens',
'factor_inv': 24,
'uom_type': 'bigger'
})
self.product_tmpl_dozen.uom_id = product_uom_24
self.assertAlmostEqual(product_packaging_dozen.qty, 0.5)
product_packaging_unit.uom_id = product_uom_24
self.assertAlmostEqual(product_packaging_unit.qty, 24)
product_uom_6 = self.env['product.uom'].create(
{'category_id': self.env.ref('product.product_uom_categ_unit').id,
'name': 'Demi Dozens',
'factor_inv': 6,
'uom_type': 'bigger'
})
self.product_tmpl_dozen.uom_id = product_uom_6
self.assertAlmostEqual(product_packaging_dozen.qty, 2)
product_packaging_unit.uom_id = product_uom_6
self.assertAlmostEqual(product_packaging_unit.qty, 6)
Loading

0 comments on commit e49dca1

Please sign in to comment.