diff --git a/purchase_packaging/README.rst b/purchase_packaging/README.rst index da3ccf2e8..634bc68b7 100644 --- a/purchase_packaging/README.rst +++ b/purchase_packaging/README.rst @@ -1,16 +1,41 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html - :alt: License: AGPL-3 - +================== Purchase Packaging ================== +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github + :target: https://github.com/OCA/server-auth/tree/9.0/purchase_packaging + :alt: OCA/server-auth +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-auth-9-0/server-auth-9-0-purchase_packaging + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/251/9.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + - Use packaging in supplierinfo - Use uom set in the packaging instead of purchase uom for purchase - Add minimum quantity measure unit in supplierinfo - On purchase order line compute the quantity with the quantity and unit of measure +**Table of contents** + +.. contents:: + :local: + Configuration ============= @@ -21,47 +46,43 @@ To configure this module, you need to: to use. * use product packaging in purchase order to use the link unit of measure -Usage -===== - -.. 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 -`_. 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. +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* ACSONE SA/NV Contributors ------------- +~~~~~~~~~~~~ * Laetitia Gangloff * Laurent Mignon -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. 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. +This module is part of the `OCA/server-auth `_ project on GitHub. +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/purchase_packaging/__init__.py b/purchase_packaging/__init__.py index baa5ee9ba..cc6b6354a 100644 --- a/purchase_packaging/__init__.py +++ b/purchase_packaging/__init__.py @@ -1,6 +1,2 @@ -# -*- coding: utf-8 -*- -# Copyright 2015-2017 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from . import models from .hooks import post_init_hook diff --git a/purchase_packaging/__manifest__.py b/purchase_packaging/__openerp__.py similarity index 96% rename from purchase_packaging/__manifest__.py rename to purchase_packaging/__openerp__.py index 5444b02f1..f024c2d3a 100644 --- a/purchase_packaging/__manifest__.py +++ b/purchase_packaging/__openerp__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { "name": "Purchase Packaging", - "version": "10.0.1.0.6", + "version": "9.0.1.0.0", "author": 'ACSONE SA/NV, ' 'Odoo Community Association (OCA)', "category": "Warehouse", diff --git a/purchase_packaging/i18n/purchase_packaging.pot b/purchase_packaging/i18n/purchase_packaging.pot index 0423735bc..035a57b53 100644 --- a/purchase_packaging/i18n/purchase_packaging.pot +++ b/purchase_packaging/i18n/purchase_packaging.pot @@ -4,8 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 10.0\n" +"Project-Id-Version: Odoo Server 9.0c\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-04-18 07:29+0000\n" +"PO-Revision-Date: 2019-04-18 07:29+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" diff --git a/purchase_packaging/models/__init__.py b/purchase_packaging/models/__init__.py index 14144ded2..209938bd2 100644 --- a/purchase_packaging/models/__init__.py +++ b/purchase_packaging/models/__init__.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- -# Copyright 2015-2017 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from . import product_supplier_info from . import purchase_order_line from . import procurement_order diff --git a/purchase_packaging/models/procurement_order.py b/purchase_packaging/models/procurement_order.py index d4e2b14dc..5ac0218f4 100644 --- a/purchase_packaging/models/procurement_order.py +++ b/purchase_packaging/models/procurement_order.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Copyright 2015-2017 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models -from odoo.tools import float_compare +from openerp import api, fields, models +from openerp.tools import float_compare class ProcurementOrder(models.Model): @@ -15,7 +15,8 @@ class ProcurementOrder(models.Model): self.ensure_one() res = super(ProcurementOrder, self)._prepare_purchase_order_line( po, supplier) - seller = self.product_id._select_seller( + seller = self.env['product.product']._select_seller( + self.product_id, partner_id=supplier.name, quantity=res['product_qty'], date=po.date_order and fields.Date.to_string( @@ -26,7 +27,8 @@ class ProcurementOrder(models.Model): new_uom_id = seller.product_uom if new_uom_id.id != res['product_uom']: res['product_uom'] = new_uom_id - qty = self.product_uom._compute_quantity( + qty = self.env['product.uom']._compute_qty_obj( + self.product_uom, self.product_qty, new_uom_id) res['product_qty'] = max(qty, seller.min_qty) return res @@ -36,7 +38,7 @@ class Orderpoint(models.Model): _inherit = 'stock.warehouse.orderpoint' @api.multi - def subtract_procurements_from_orderpoints(self): + def _subtract_procurements_from_orderpoints(self, res): # In this method we need to access the purchase order line quantity # to correctly evaluate the forecast. # Imagine a product with a minimum rule of 4 units and a purchase @@ -49,7 +51,6 @@ class Orderpoint(models.Model): # be increased to 24 units which is wrong. # This override will return 12 and no additionnal procurement will be # created - res = super(Orderpoint, self).subtract_procurements_from_orderpoints() procurements = self.env['procurement.order'].search([ ('orderpoint_id', 'in', self.ids), ('state', 'not in', ['cancel', 'done']), @@ -74,3 +75,12 @@ class Orderpoint(models.Model): precision_rounding=precision) >= 0: res[orderpoint.id] = qty return res + + def subtract_procurements_from_orderpoints(self, cr, uid, orderpoint_ids, + context=None): + res = super(Orderpoint, self).subtract_procurements_from_orderpoints( + cr, uid, orderpoint_ids, context) + orderpoints = self.pool.get(self._name).browse( + cr, uid, orderpoint_ids, context) + res = orderpoints._subtract_procurements_from_orderpoints(res) + return res diff --git a/purchase_packaging/models/product_supplier_info.py b/purchase_packaging/models/product_supplier_info.py index ca214f489..c8aa57ce0 100644 --- a/purchase_packaging/models/product_supplier_info.py +++ b/purchase_packaging/models/product_supplier_info.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2015-2017 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models +from openerp import api, fields, models class ProductSupplierinfo(models.Model): diff --git a/purchase_packaging/models/purchase_order_line.py b/purchase_packaging/models/purchase_order_line.py index ac0457983..909a4f603 100644 --- a/purchase_packaging/models/purchase_order_line.py +++ b/purchase_packaging/models/purchase_order_line.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- # Copyright 2015-2017 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models -import odoo.addons.decimal_precision as dp +from openerp import api, fields, models +import openerp.addons.decimal_precision as dp class PurchaseOrderLine(models.Model): @@ -41,7 +41,8 @@ class PurchaseOrderLine(models.Model): @api.multi def _get_product_seller(self): self.ensure_one() - return self.product_id._select_seller( + return self.env['product.product']._select_seller( + self.product_id, partner_id=self.order_id.partner_id, quantity=self.product_qty, date=self.order_id.date_order and fields.Date.to_string( @@ -65,7 +66,8 @@ class PurchaseOrderLine(models.Model): ('uom_type', '=', 'reference')]) uom_by_category = {to_uom.category_id: to_uom for to_uom in to_uoms} for line in self: - line.product_qty = line.product_purchase_uom_id._compute_quantity( + line.product_qty = uom_obj._compute_qty_obj( + line.product_purchase_uom_id, line.product_purchase_qty, uom_by_category.get(line.product_purchase_uom_id.category_id)) @@ -89,7 +91,8 @@ class PurchaseOrderLine(models.Model): product_purchase_uom = supplier.min_qty_uom_id from_uom = uom_by_category.get( line.product_purchase_uom_id.category_id) - line.product_purchase_qty = from_uom._compute_quantity( + line.product_purchase_qty = uom_obj._compute_qty_obj( + from_uom, line.product_qty, product_purchase_uom) line.product_purchase_uom_id = product_purchase_uom.id @@ -142,7 +145,8 @@ class PurchaseOrderLine(models.Model): supplier.min_qty_uom_id.category_id.id), ('uom_type', '=', 'reference')], limit=1) to_uom = to_uom and to_uom[0] - self.product_qty = supplier.min_qty_uom_id._compute_quantity( + self.product_qty = self.env['product.uom']._compute_qty_obj( + supplier.min_qty_uom_id, supplier.min_qty, to_uom ) self.packaging_id = supplier.packaging_id @@ -154,12 +158,13 @@ class PurchaseOrderLine(models.Model): return res @api.multi - def _prepare_stock_moves(self, picking): - self.ensure_one() - val = super(PurchaseOrderLine, self)._prepare_stock_moves(picking) - for v in val: - v['product_packaging'] = self.packaging_id.id - return val + def _create_stock_moves(self, picking): + moves = super(PurchaseOrderLine, self)._create_stock_moves(picking) + for move in moves: + move.product_packaging = self.filtered( + lambda order_line: order_line == move.purchase_line_id).\ + packaging_id + return moves @api.model def update_vals(self, vals): @@ -183,7 +188,8 @@ class PurchaseOrderLine(models.Model): to_uom = uom_obj.search( [('category_id', '=', product_purchase_uom.category_id.id), ('uom_type', '=', 'reference')], limit=1) - vals['product_qty'] = to_uom._compute_quantity( + vals['product_qty'] = uom_obj._compute_qty_obj( + to_uom, vals['product_purchase_qty'], to_uom) return super(PurchaseOrderLine, self).create(self.update_vals(vals)) diff --git a/purchase_packaging/readme/CONFIGURE.rst b/purchase_packaging/readme/CONFIGURE.rst new file mode 100644 index 000000000..f5214f687 --- /dev/null +++ b/purchase_packaging/readme/CONFIGURE.rst @@ -0,0 +1,6 @@ +To configure this module, you need to: + +* on product packaging define the unit of measure to use. +* on supplier info define the packaging and minimum unit of measure quantity + to use. +* use product packaging in purchase order to use the link unit of measure diff --git a/purchase_packaging/readme/CONTRIBUTORS.rst b/purchase_packaging/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..3d6d548f9 --- /dev/null +++ b/purchase_packaging/readme/CONTRIBUTORS.rst @@ -0,0 +1,2 @@ +* Laetitia Gangloff +* Laurent Mignon diff --git a/purchase_packaging/readme/DESCRIPTION.rst b/purchase_packaging/readme/DESCRIPTION.rst new file mode 100644 index 000000000..6df50ba28 --- /dev/null +++ b/purchase_packaging/readme/DESCRIPTION.rst @@ -0,0 +1,5 @@ +- Use packaging in supplierinfo +- Use uom set in the packaging instead of purchase uom for purchase +- Add minimum quantity measure unit in supplierinfo +- On purchase order line compute the quantity with the quantity and unit of + measure diff --git a/purchase_packaging/static/description/index.html b/purchase_packaging/static/description/index.html new file mode 100644 index 000000000..e96ca7540 --- /dev/null +++ b/purchase_packaging/static/description/index.html @@ -0,0 +1,443 @@ + + + + + + +Purchase Packaging + + + +
+

Purchase Packaging

+ + +

Beta License: AGPL-3 OCA/server-auth Translate me on Weblate Try me on Runbot

+
    +
  • Use packaging in supplierinfo
  • +
  • Use uom set in the packaging instead of purchase uom for purchase
  • +
  • Add minimum quantity measure unit in supplierinfo
  • +
  • +
    On purchase order line compute the quantity with the quantity and unit of
    +
    measure
    +
    +
  • +
+

Table of contents

+ +
+

Configuration

+

To configure this module, you need to:

+
    +
  • on product packaging define the unit of measure to use.
  • +
  • +
    on supplier info define the packaging and minimum unit of measure quantity
    +
    to use.
    +
    +
  • +
  • use product packaging in purchase order to use the link unit of measure
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ACSONE SA/NV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

This module is part of the OCA/server-auth project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/purchase_packaging/tests/__init__.py b/purchase_packaging/tests/__init__.py index 5eebe12ac..c16b34c73 100644 --- a/purchase_packaging/tests/__init__.py +++ b/purchase_packaging/tests/__init__.py @@ -1,7 +1,3 @@ -# -*- coding: utf-8 -*- -# Copyright 2015-2017 ACSONE SA/NV () -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - from . import test_product_supplier_info from . import test_purchase_order_line from . import test_procurement_order diff --git a/purchase_packaging/tests/test_procurement_order.py b/purchase_packaging/tests/test_procurement_order.py index be443b311..d24474740 100644 --- a/purchase_packaging/tests/test_procurement_order.py +++ b/purchase_packaging/tests/test_procurement_order.py @@ -2,8 +2,8 @@ # Copyright 2015-2017 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from datetime import timedelta -import odoo.tests.common as common -from odoo import fields +import openerp.tests.common as common +from openerp import fields class TestProcurementOrder(common.TransactionCase): diff --git a/purchase_packaging/tests/test_product_supplier_info.py b/purchase_packaging/tests/test_product_supplier_info.py index 4c01e4446..e60b8e28b 100644 --- a/purchase_packaging/tests/test_product_supplier_info.py +++ b/purchase_packaging/tests/test_product_supplier_info.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2015-2017 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -import odoo.tests.common as common +import openerp.tests.common as common class TestProductSupplierInfo(common.TransactionCase): diff --git a/purchase_packaging/tests/test_purchase_order_line.py b/purchase_packaging/tests/test_purchase_order_line.py index e8ef2c5ed..bac2205e3 100644 --- a/purchase_packaging/tests/test_purchase_order_line.py +++ b/purchase_packaging/tests/test_purchase_order_line.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2015-2017 ACSONE SA/NV () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -import odoo.tests.common as common +import openerp.tests.common as common class TestPurchaseOrderLine(common.TransactionCase): @@ -57,7 +57,7 @@ class TestPurchaseOrderLine(common.TransactionCase): po = self.env['purchase.order'].create( {'partner_id': self.product_supplier_info.name.id}) po_line = po.order_line.new({ - 'product_id': self.product_tmpl_id.product_variant_id, + 'product_id': self.product_tmpl_id.product_variant_ids[:1], 'product_purchase_qty': 1.0, 'product_purchase_uom_id': po.order_line._default_product_purchase_uom_id(), @@ -93,7 +93,7 @@ class TestPurchaseOrderLine(common.TransactionCase): po = self.env['purchase.order'].create( {'partner_id': self.product_supplier_info.name.id}) po_line = po.order_line.new({ - 'product_id': self.product_tmpl_id.product_variant_id, + 'product_id': self.product_tmpl_id.product_variant_ids[:1], 'product_purchase_qty': 1.0, 'product_purchase_uom_id': po.order_line._default_product_purchase_uom_id(), @@ -116,7 +116,7 @@ class TestPurchaseOrderLine(common.TransactionCase): po = self.env['purchase.order'].create( {'partner_id': self.product_supplier_info.name.id}) po_line = po.order_line.new({ - 'product_id': self.product_tmpl_id.product_variant_id, + 'product_id': self.product_tmpl_id.product_variant_ids[:1], 'product_purchase_qty': 1.0, 'product_purchase_uom_id': po.order_line._default_product_purchase_uom_id(),