forked from grap/grap-odoo-incubator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "[REM] remove obsolete module purchase_package_qty, replace by…
… product_supplierinfo_qty_multiplier" This reverts commit 7126c71.
- Loading branch information
1 parent
1cb46e3
commit 09dcf00
Showing
20 changed files
with
552 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
=========================== | ||
Purchase - Package Quantity | ||
=========================== | ||
|
||
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! 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-grap%2Fgrap--odoo--incubator-lightgray.png?logo=github | ||
:target: https://github.com/grap/grap-odoo-incubator/tree/12.0/purchase_package_qty | ||
:alt: grap/grap-odoo-incubator | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
This module extends the functionality of purchase module to support package | ||
quantity. | ||
|
||
In the product supplierinfo, add a "Package Qty" field to register how many | ||
purchase UoM of the product there are in the package the supplier uses. | ||
All purchase lines for this product+supplier must have a quantity that is a | ||
multiple of that package quantity. | ||
|
||
For example: | ||
|
||
* A supplier sells beers with a price per unit, thus the purchase UoM is PCE. | ||
* The supplier put them in 6pcs boxes, and the purchaser have to buy a multiple | ||
of 6. | ||
* The supplier has a minimum quantity of 60. | ||
|
||
So the settings of the product will be the following : | ||
|
||
.. image:: https://raw.githubusercontent.com/grap/grap-odoo-incubator/12.0/purchase_package_qty/static/description/product_supplierinfo_form.png | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/grap/grap-odoo-incubator/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 <https://github.com/grap/grap-odoo-incubator/issues/new?body=module:%20purchase_package_qty%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* GRAP | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* Julien WESTE | ||
* Sylvain LE GAL (https://www.twitter.com/legalsylvain) | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is part of the `grap/grap-odoo-incubator <https://github.com/grap/grap-odoo-incubator/tree/12.0/purchase_package_qty>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) | ||
# @author Julien WESTE | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
{ | ||
"name": "Purchase - Package Quantity", | ||
"version": "12.0.1.1.3", | ||
"category": "Purchase", | ||
"author": "GRAP", | ||
"website": "https://github.com/grap/grap-odoo-incubator", | ||
"license": "AGPL-3", | ||
"depends": [ | ||
"purchase", | ||
], | ||
"data": [ | ||
"views/view_product_supplierinfo.xml", | ||
], | ||
"demo": [ | ||
"demo/res_groups.xml", | ||
"demo/product_template.xml", | ||
"demo/product_supplierinfo.xml", | ||
"demo/purchase_order.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<odoo> | ||
|
||
<record id="supplierinfo_supplier_1" model="product.supplierinfo"> | ||
<field name="name" ref="base.res_partner_1"/> | ||
<field name="package_qty">6</field> | ||
<field name="min_qty">60</field> | ||
<field name="price">12.0</field> | ||
<field name="product_tmpl_id" ref="product_template_package_6"/> | ||
</record> | ||
|
||
<record id="supplierinfo_supplier_3" model="product.supplierinfo"> | ||
<field name="name" ref="base.res_partner_3"/> | ||
<field name="package_qty">0</field> | ||
<field name="min_qty">0</field> | ||
<field name="price">2.25</field> | ||
<field name="product_tmpl_id" ref="product_template_package_6"/> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<odoo> | ||
|
||
<record id="product_template_package_6" model="product.template"> | ||
<field name="name">Beers (package x6)</field> | ||
<field name="categ_id" ref="product.product_category_all"/> | ||
</record> | ||
|
||
<record id="product_product_package_6" model="product.product"> | ||
<field name="product_tmpl_id" ref="product_template_package_6"/> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<odoo> | ||
|
||
|
||
<record id="purchase_order" model="purchase.order"> | ||
<field name="name">Purchase Order (Package)</field> | ||
<field name="partner_id" ref="base.res_partner_1"/> | ||
</record> | ||
|
||
<record id="purchase_order_line" model="purchase.order.line"> | ||
<field name="order_id" ref="purchase_order"/> | ||
<field name="name">Beers (package x6)</field> | ||
<field name="product_uom" ref="uom.product_uom_unit"/> | ||
<field name="product_id" ref="product_product_package_6"/> | ||
<field name="product_qty">12</field> | ||
<field name="price_unit">20</field> | ||
<field name="date_planned">1970-01-01</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (C) 2019 - Today: GRAP (http://www.grap.coop) | ||
@author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
--> | ||
<odoo> | ||
|
||
<record id="uom.group_uom" model="res.groups"> | ||
<field name="users" eval="[(4, ref('base.user_admin'))]"/> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * purchase_package_qty | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 12.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2019-11-22 13:18+0000\n" | ||
"PO-Revision-Date: 2019-11-22 13:18+0000\n" | ||
"Last-Translator: <>\n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: purchase_package_qty | ||
#: model:product.product,name:purchase_package_qty.product_product_package_6 | ||
#: model:product.template,name:purchase_package_qty.product_product_package_6_product_template | ||
msgid "Beers (package x6)" | ||
msgstr "Bières (x 6)" | ||
|
||
#. module: purchase_package_qty | ||
#: model:ir.model.fields,field_description:purchase_package_qty.field_product_supplierinfo__package_qty | ||
msgid "Package Quantity" | ||
msgstr "Quantité de Conditionnement" | ||
|
||
#. module: purchase_package_qty | ||
#: model:ir.model,name:purchase_package_qty.model_purchase_order_line | ||
msgid "Purchase Order Line" | ||
msgstr "Ligne de commande d'achat" | ||
|
||
#. module: purchase_package_qty | ||
#: model:ir.model,name:purchase_package_qty.model_product_supplierinfo | ||
msgid "Supplier Pricelist" | ||
msgstr "Liste de prix du fournisseur" | ||
|
||
#. module: purchase_package_qty | ||
#: model:ir.model.fields,help:purchase_package_qty.field_product_supplierinfo__package_qty | ||
msgid "The quantity of products in the supplier package. You will always have to buy a multiple of this quantity." | ||
msgstr "La quantité de produit conditionnée par le fournisseur. Vous devez toujours acheter un multiple de cette quantité." | ||
|
||
#. module: purchase_package_qty | ||
#: model:product.product,uom_name:purchase_package_qty.product_product_package_6 | ||
#: model:product.template,uom_name:purchase_package_qty.product_product_package_6_product_template | ||
msgid "Unit(s)" | ||
msgstr "Unité(s)" | ||
|
||
#. module: purchase_package_qty | ||
#: model:product.product,weight_uom_name:purchase_package_qty.product_product_package_6 | ||
#: model:product.template,weight_uom_name:purchase_package_qty.product_product_package_6_product_template | ||
msgid "kg" | ||
msgstr "kg" |
22 changes: 22 additions & 0 deletions
22
purchase_package_qty/migrations/12.0.2.0.1/pre-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright (C) 2023 - Today: GRAP (http://www.grap.coop) | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from openupgradelib import openupgrade | ||
|
||
|
||
def migrate(cr, version): | ||
if not openupgrade.column_exists(cr, "product_supplierinfo", "multiplier_qty"): | ||
cr.execute( | ||
""" | ||
ALTER TABLE product_supplierinfo | ||
ADD COLUMN multiplier_qty double precision; | ||
""" | ||
) | ||
|
||
cr.execute( | ||
""" | ||
UPDATE product_supplierinfo | ||
SET multiplier_qty = package_qty; | ||
""" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import product_supplierinfo | ||
from . import purchase_order_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) | ||
# @author Julien WESTE | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from math import ceil | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ProductSupplierinfo(models.Model): | ||
_inherit = "product.supplierinfo" | ||
|
||
package_qty = fields.Float( | ||
string="Package Quantity", | ||
default=0, | ||
help="The quantity of products in the supplier package." | ||
" You will always have to buy a multiple of this quantity.", | ||
) | ||
|
||
@api.multi | ||
def _get_quantity_according_package(self, product_qty, uom): | ||
self.ensure_one() | ||
# For the time being, Odoo is limited and doesn't | ||
# recover seller if the unit of the purchase order line is different | ||
# from the unit of the supplierinfo. | ||
# this function should be improved using uom arg, | ||
# when Odoo purchase module will be improved. (>12.0) | ||
if self.package_qty and product_qty % self.package_qty: | ||
return ceil(product_qty / self.package_qty) * self.package_qty | ||
else: | ||
return product_qty | ||
|
||
@api.onchange("package_qty") | ||
def onchange_package_qty(self): | ||
if self.package_qty: | ||
if self.package_qty > self.min_qty: | ||
self.min_qty = self.package_qty | ||
elif self.min_qty % self.package_qty: | ||
# check if min_qty is a multiple of package_qty | ||
self.min_qty = ceil(self.min_qty // self.package_qty) * self.package_qty | ||
|
||
@api.onchange("min_qty") | ||
def onchange_min_qty(self): | ||
if self.package_qty: | ||
if self.package_qty > self.min_qty: | ||
self.package_qty = self.min_qty | ||
elif self.min_qty % self.package_qty: | ||
# check if min_qty is a multiple of package_qty | ||
self.min_qty = ceil(self.min_qty / self.package_qty) * self.package_qty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (C) 2013 - Today: GRAP (http://www.grap.coop) | ||
# @author Julien WESTE | ||
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
|
||
from odoo import api, models | ||
|
||
|
||
class PurchaseOrderLine(models.Model): | ||
_inherit = "purchase.order.line" | ||
|
||
@api.onchange("product_qty", "product_uom") | ||
def _onchange_quantity(self): | ||
if not self.product_id: | ||
return | ||
seller = self.product_id._select_seller( | ||
partner_id=self.partner_id, | ||
quantity=self.product_qty, | ||
date=self.order_id.date_order and self.order_id.date_order.date(), | ||
uom_id=self.product_uom, | ||
params={"order_id": self.order_id}, | ||
) | ||
if seller: | ||
self.product_qty = seller._get_quantity_according_package( | ||
self.product_qty, self.product_uom | ||
) | ||
return super()._onchange_quantity() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* Julien WESTE | ||
* Sylvain LE GAL (https://www.twitter.com/legalsylvain) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
This module extends the functionality of purchase module to support package | ||
quantity. | ||
|
||
In the product supplierinfo, add a "Package Qty" field to register how many | ||
purchase UoM of the product there are in the package the supplier uses. | ||
All purchase lines for this product+supplier must have a quantity that is a | ||
multiple of that package quantity. | ||
|
||
For example: | ||
|
||
* A supplier sells beers with a price per unit, thus the purchase UoM is PCE. | ||
* The supplier put them in 6pcs boxes, and the purchaser have to buy a multiple | ||
of 6. | ||
* The supplier has a minimum quantity of 60. | ||
|
||
So the settings of the product will be the following : | ||
|
||
.. image:: ../static/description/product_supplierinfo_form.png |
Binary file added
BIN
+33.5 KB
purchase_package_qty/static/description/product_supplierinfo_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import test_module |
Oops, something went wrong.