mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
rename packaging_extended to packaging_uom
This commit is contained in:
committed by
Thomas Binsfeld
parent
5a4bec20d8
commit
d149b4d4f6
63
packaging_uom/README.rst
Normal file
63
packaging_uom/README.rst
Normal file
@@ -0,0 +1,63 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:alt: License: AGPL-3
|
||||
|
||||
Packaging Extended
|
||||
===========
|
||||
|
||||
This module was written to use unit of measure instead of quantity by package
|
||||
in the definition of packaging.
|
||||
The goal is to ease the use of packaging in sale and purchase.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
To install this module, you need to:
|
||||
|
||||
* Click on install button
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
To configure this module, you need to:
|
||||
|
||||
* on product packaging define the unit of measure to use.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
For further information, please visit:
|
||||
|
||||
* https://www.odoo.com/forum/help-1
|
||||
|
||||
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**>`_.
|
||||
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Laetitia Gangloff <laetitia.gangloff@acsone.eu>
|
||||
* Laurent Mignon <laurent.mignon@acsone.eu>
|
||||
|
||||
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 http://odoo-community.org.
|
||||
3
packaging_uom/__init__.py
Executable file
3
packaging_uom/__init__.py
Executable file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import models
|
||||
36
packaging_uom/__openerp__.py
Executable file
36
packaging_uom/__openerp__.py
Executable file
@@ -0,0 +1,36 @@
|
||||
# -*- 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
"name": "Packaging Extended",
|
||||
"version": "0.1",
|
||||
'author': "Acsone, Odoo Community Association (OCA)",
|
||||
"category": "Other",
|
||||
"website": "http://www.acsone.eu",
|
||||
'summary': "Use uom in package",
|
||||
"depends": ["product",
|
||||
],
|
||||
"data": ["views/product_packaging_views.xml",
|
||||
],
|
||||
"license": "AGPL-3",
|
||||
"installable": True,
|
||||
"application": False,
|
||||
}
|
||||
3
packaging_uom/models/__init__.py
Executable file
3
packaging_uom/models/__init__.py
Executable file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import product_packaging
|
||||
47
packaging_uom/models/product_packaging.py
Normal file
47
packaging_uom/models/product_packaging.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# -*- 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
|
||||
|
||||
|
||||
class ProductPackaging(models.Model):
|
||||
_inherit = 'product.packaging'
|
||||
|
||||
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(
|
||||
related='product_tmpl_id.uom_id.category_id',
|
||||
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')
|
||||
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)
|
||||
else:
|
||||
self.qty = 0
|
||||
3
packaging_uom/tests/__init__.py
Normal file
3
packaging_uom/tests/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_packaging
|
||||
82
packaging_uom/tests/test_packaging.py
Normal file
82
packaging_uom/tests/test_packaging.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# -*- 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/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import openerp.tests.common as common
|
||||
|
||||
|
||||
class TestPackaging(common.TransactionCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPackaging, self).setUp()
|
||||
|
||||
def test_compute_quantity_by_package(self):
|
||||
""" Create a packagings with uom product_uom_dozen on
|
||||
* product_product_35 (uom is product_uom_dozen)
|
||||
* product_product_34 (uom is product_uom_unit)
|
||||
Result should be :
|
||||
* product_product_35 -> qty by package : 1
|
||||
* product_product_34 -> qty by package : 12
|
||||
Create product_uom_24
|
||||
Update product_product_35 to set this new uom
|
||||
Result should be :
|
||||
* product_product_35 -> qty by package : 0.5
|
||||
Update product_package_34 to set this new uom
|
||||
Result should be :
|
||||
* product_product_34 -> qty by package : 24
|
||||
Create product_uom 6
|
||||
Update product_product_35 to set this new uom
|
||||
Result should be :
|
||||
* product_product_35 -> qty by package : 2
|
||||
Update product_package_34 to set this new uom
|
||||
Result should be :
|
||||
* product_product_34 -> qty by package : 6
|
||||
"""
|
||||
packaging_obj = self.env['product.packaging']
|
||||
product_packaging_35 = packaging_obj.create(
|
||||
{'product_tmpl_id': self.env.ref('product.product_product_35'
|
||||
).product_tmpl_id.id,
|
||||
'uom_id': self.env.ref('product.product_uom_dozen').id})
|
||||
self.assertAlmostEqual(product_packaging_35.qty, 1)
|
||||
product_packaging_34 = packaging_obj.create(
|
||||
{'product_tmpl_id': self.env.ref('product.product_product_34'
|
||||
).product_tmpl_id.id,
|
||||
'uom_id': self.env.ref('product.product_uom_dozen').id})
|
||||
self.assertAlmostEqual(product_packaging_34.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.env.ref('product.product_product_35').uom_id = product_uom_24
|
||||
self.assertAlmostEqual(product_packaging_35.qty, 0.5)
|
||||
product_packaging_34.uom_id = product_uom_24
|
||||
self.assertAlmostEqual(product_packaging_34.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.env.ref('product.product_product_35').uom_id = product_uom_6
|
||||
self.assertAlmostEqual(product_packaging_35.qty, 2)
|
||||
product_packaging_34.uom_id = product_uom_6
|
||||
self.assertAlmostEqual(product_packaging_34.qty, 6)
|
||||
45
packaging_uom/views/product_packaging_views.xml
Normal file
45
packaging_uom/views/product_packaging_views.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="product_template_view_form_inherit_packaging_uom" model="ir.ui.view">
|
||||
<field name="name">product.template.common.form (packaging_uom)</field>
|
||||
<field name="model">product.template</field>
|
||||
<field name="inherit_id" ref="product.product_template_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="packaging_ids" position="attributes">
|
||||
<attribute name="context">
|
||||
{'default_product_tmpl_id': id,
|
||||
'tree_view_ref':'product.product_packaging_tree_view_product',
|
||||
'form_view_ref': 'product.product_packaging_form_view_without_product'}</attribute>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="product_packaging_2_view_form_inherit_packaging_uom" model="ir.ui.view">
|
||||
<field name="name">product.packaging.form.view.without.product (packaging_uom)</field>
|
||||
<field name="model">product.packaging</field>
|
||||
<field name="inherit_id" ref="product.product_packaging_form_view_without_product"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="qty" position="before">
|
||||
<field name="product_tmpl_id" invisible="1"/>
|
||||
<field name="uom_categ_domain_id" invisible="1"/>
|
||||
<field name="uom_id" domain="[('category_id', '=', uom_categ_domain_id)]"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="product_packaging_view_form_inherit_packaging_uom" model="ir.ui.view">
|
||||
<field name="name">product.packaging.form.view (packaging_uom)</field>
|
||||
<field name="model">product.packaging</field>
|
||||
<field name="inherit_id" ref="product.product_packaging_form_view"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="qty" position="before">
|
||||
<field name="uom_categ_domain_id" invisible="1"/>
|
||||
<field name="uom_id" domain="[('category_id', '=', uom_categ_domain_id)]"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user