mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] packaging_uom, purchase_packaging, sale_packaging: Migrated to 10.0
This commit is contained in:
committed by
Thomas Binsfeld
parent
7a368c40d3
commit
4e2dcba532
@@ -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
|
||||
=============
|
||||
@@ -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
|
||||
------------
|
||||
|
||||
|
||||
@@ -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
packaging_uom/__manifest__.py
Executable file
18
packaging_uom/__manifest__.py
Executable file
@@ -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,
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
# -*- 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 UOM",
|
||||
"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,
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
@@ -34,13 +15,22 @@ class ProductPackaging(models.Model):
|
||||
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')
|
||||
@@ -49,7 +39,7 @@ class ProductPackaging(models.Model):
|
||||
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
|
||||
|
||||
BIN
packaging_uom/static/description/icon.png
Normal file
BIN
packaging_uom/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -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
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
# -*- 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)
|
||||
71
packaging_uom/tests/test_product_packaging.py
Normal file
71
packaging_uom/tests/test_product_packaging.py
Normal file
@@ -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)
|
||||
@@ -1,45 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- Copyright 2015-2017 ACSONE SA/NV (<http://acsone.eu>)
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||
<odoo>
|
||||
<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">
|
||||
<page name="general_information" position="after">
|
||||
<page name="packaging" string="Packaging" attrs="{'invisible':[('type','=','service')]}" groups="product.group_stock_packaging" >
|
||||
<group name="packaging" string="Packaging">
|
||||
<field name="packaging_ids" string="Configurations"
|
||||
context="{'get_uom_categ_from_uom': uom_id, 'tree_view_ref':'product.product_packaging_tree_view_product', 'form_view_ref': 'product.product_packaging_form_view_without_product'}"/>
|
||||
</group>
|
||||
</page>
|
||||
</page>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<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">
|
||||
{'get_uom_categ_from_uom': uom_id,
|
||||
'tree_view_ref':'product.product_packaging_tree_view_product',
|
||||
'form_view_ref': 'product.product_packaging_form_view_without_product'}</attribute>
|
||||
</field>
|
||||
<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>
|
||||
</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" required="False"/>
|
||||
<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>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user