Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MOV] product_packaging_type_required becomes product_packaging_level_required #1803

Draft
wants to merge 25 commits into
base: 18.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0f12d1c
[ADD] module 'product_packaging_type' and 'product_packaging_type_req…
damdam-s Nov 7, 2019
ee0e7b8
Improvements according to review
grindtildeath Nov 28, 2019
11f57b4
Optimize creation of required packagings
guewen Dec 13, 2019
3c6cc87
Migrate product_packaging_type_required to 13.0
guewen Dec 13, 2019
0d18b79
run pre-commit with new prettiers
guewen Mar 19, 2020
7ed34e4
[UPD] Update product_packaging_type_required.pot
oca-travis Mar 19, 2020
681304d
[UPD] README.rst
OCA-git-bot Mar 19, 2020
35f33e4
[ADD] icon.png
OCA-git-bot Mar 19, 2020
f3c8b7f
Added translation using Weblate (Spanish)
claudiagn Oct 14, 2020
5e831dd
Translated using Weblate (Spanish)
claudiagn Oct 14, 2020
810bae5
[IMP] product_packaging_type_required: black, isort, prettier
phuctranfxvn Feb 7, 2021
66b3085
[MIG] product_packaging_type_required: Migration to 14.0
phuctranfxvn Feb 7, 2021
5dfe390
[UPD] Update product_packaging_type_required.pot
oca-travis Aug 13, 2021
8242bf3
[UPD] README.rst
OCA-git-bot Aug 13, 2021
b4aa11a
product_packaging_type_required: add maintainers
simahawk Aug 11, 2021
7044e60
product_packaging_type_required: improve + add test
simahawk Aug 11, 2021
8fc87d3
[UPD] README.rst
OCA-git-bot Oct 11, 2021
08f0f02
[UPD] README.rst
OCA-git-bot Sep 3, 2023
da90cc8
Update translation files
weblate Oct 9, 2023
5935efd
Added translation using Weblate (Italian)
mymage Nov 2, 2023
a9c02e9
Translated using Weblate (Italian)
mymage Nov 3, 2023
927241d
Translated using Weblate (Spanish)
Ivorra78 Jan 15, 2024
dca7c36
[IMP] product_packaging_type_required: pre-commit auto fixes
trisdoan Nov 30, 2024
92cba80
[MOV] product_packaging_type_required becomes product_packaging_level…
trisdoan Nov 30, 2024
dc77e6a
[DON'T MERGE] test-requirements.txt
trisdoan Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions product_packaging_auto_create/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
=============================
Product Packaging Auto Create
=============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:e59d8c7902f6e14f3419fc352a13fa97a41db7ea8b7dc2afdbf8ae64a8996ac5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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%2Fproduct--attribute-lightgray.png?logo=github
:target: https://github.com/OCA/product-attribute/tree/18.0/product_packaging_auto_create
:alt: OCA/product-attribute
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/product-attribute-18-0/product-attribute-18-0-product_packaging_auto_create
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to mark a product packaging level as
auto-create-packaging.

A cron creates the missing product packages if the related packaging
level is auto-create-packaging.

**Table of contents**

.. contents::
:local:

Usage
=====

To set a packaging level as auto-create-packaging:

1. Go to *Inventory > Configuration > Product Packaging Level*.
2. You can make a level auto-create-packaging

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_packaging_auto_create%0Aversion:%2018.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
-------

* Camptocamp

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

- `Camptocamp <https://www.camptocamp.com>`__

- Damien Crier <[email protected]>
- Simone Orsi <[email protected]>
- Phuc Tran Thanh <[email protected]>
- Tris Doan <[email protected]>

Other credits
-------------

The development and migration of this module has been financially
supported by:

- Camptocamp

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

.. |maintainer-simahawk| image:: https://github.com/simahawk.png?size=40px
:target: https://github.com/simahawk
:alt: simahawk
.. |maintainer-dcrier| image:: https://github.com/dcrier.png?size=40px
:target: https://github.com/dcrier
:alt: dcrier

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-simahawk| |maintainer-dcrier|

This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/18.0/product_packaging_auto_create>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions product_packaging_auto_create/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
18 changes: 18 additions & 0 deletions product_packaging_auto_create/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2019 Camptocamp (<http://www.camptocamp.com>).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Product Packaging Auto Create",
"version": "18.0.1.0.0",
"development_status": "Beta",
"category": "Product",
"summary": "Product Packaging Auto Create",
"author": "Camptocamp, " "Odoo Community Association (OCA)",
"maintainers": ["simahawk", "dcrier"],
"website": "https://github.com/OCA/product-attribute",
"license": "AGPL-3",
"depends": ["product_packaging_level"],
"data": ["data/cron.xml", "views/product_packaging_level_views.xml"],
"installable": True,
"auto_install": False,
}
16 changes: 16 additions & 0 deletions product_packaging_auto_create/data/cron.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo noupdate="1">
<record forcecreate="True" id="ir_cron_packaging_required" model="ir.cron">
<field name="name">Packaging Required</field>
<field
ref="product_packaging_level.model_product_packaging_level"
name="model_id"
/>
<field name="state">code</field>
<field name="code">model.cron_check_create_required_packaging()</field>
<field eval="False" name="active" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">20</field>
<field name="interval_type">minutes</field>
</record>
</odoo>
44 changes: 44 additions & 0 deletions product_packaging_auto_create/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_packaging_auto_create
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-17 05:25+0000\n"
"PO-Revision-Date: 2024-01-15 19:34+0000\n"
"Last-Translator: Ivorra78 <[email protected]>\n"
"Language-Team: none\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: product_packaging_auto_create
#: model:ir.model.fields,help:product_packaging_auto_create.field_product_packaging_level__auto_create_packaging
msgid ""
"A cron will create a packaging for each product missing a packaging with "
"this level"
msgstr ""

#. module: product_packaging_auto_create
#: model:ir.model.fields,field_description:product_packaging_auto_create.field_product_packaging_level__auto_create_packaging
msgid "Auto Create Packaging"
msgstr ""

#. module: product_packaging_auto_create
#: model:ir.model,name:product_packaging_auto_create.model_product_packaging_level
#, fuzzy
msgid "Level management for product.packaging"
msgstr "Tipo de administración para empaquetado de producto"

#. module: product_packaging_auto_create
#: model:ir.actions.server,name:product_packaging_auto_create.ir_cron_packaging_required_ir_actions_server
msgid "Packaging Required"
msgstr "Empaquetado requerido"

#~ msgid "Required"
#~ msgstr "Requerido"
41 changes: 41 additions & 0 deletions product_packaging_auto_create/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_packaging_auto_create
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 14.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-17 05:25+0000\n"
"PO-Revision-Date: 2023-11-03 13:36+0000\n"
"Last-Translator: mymage <[email protected]>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.17\n"

#. module: product_packaging_auto_create
#: model:ir.model.fields,help:product_packaging_auto_create.field_product_packaging_level__auto_create_packaging
msgid ""
"A cron will create a packaging for each product missing a packaging with "
"this level"
msgstr ""

#. module: product_packaging_auto_create
#: model:ir.model.fields,field_description:product_packaging_auto_create.field_product_packaging_level__auto_create_packaging
msgid "Auto Create Packaging"
msgstr ""

#. module: product_packaging_auto_create
#: model:ir.model,name:product_packaging_auto_create.model_product_packaging_level
#, fuzzy
msgid "Level management for product.packaging"
msgstr "Gestione tipo per product.packaging"

#. module: product_packaging_auto_create
#: model:ir.actions.server,name:product_packaging_auto_create.ir_cron_packaging_required_ir_actions_server
msgid "Packaging Required"
msgstr "Richiesto imballo"
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_packaging_auto_create
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-12-17 05:25+0000\n"
"PO-Revision-Date: 2024-12-17 05:25+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: product_packaging_auto_create
#: model:ir.model.fields,help:product_packaging_auto_create.field_product_packaging_level__auto_create_packaging
msgid ""
"A cron will create a packaging for each product missing a packaging with "
"this level"
msgstr ""

#. module: product_packaging_auto_create
#: model:ir.model.fields,field_description:product_packaging_auto_create.field_product_packaging_level__auto_create_packaging
msgid "Auto Create Packaging"
msgstr ""

#. module: product_packaging_auto_create
#: model:ir.model,name:product_packaging_auto_create.model_product_packaging_level
msgid "Level management for product.packaging"
msgstr ""

#. module: product_packaging_auto_create
#: model:ir.actions.server,name:product_packaging_auto_create.ir_cron_packaging_required_ir_actions_server
msgid "Packaging Required"
msgstr ""
1 change: 1 addition & 0 deletions product_packaging_auto_create/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_packaging_level
55 changes: 55 additions & 0 deletions product_packaging_auto_create/models/product_packaging_level.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2019 Camptocamp (<http://www.camptocamp.com>).
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

import logging

from odoo import api, fields, models

_logger = logging.getLogger(__name__)


class ProductPackagingLevel(models.Model):
_inherit = "product.packaging.level"

auto_create_packaging = fields.Boolean(
help="A cron will create a packaging "
"for each product missing a packaging with this level"
)

@api.model
def cron_check_create_required_packaging(self):
"""Create required packagings for each consumable product if missing."""
existing_products = self.env["product.product"].search([("type", "=", "consu")])
required_packaging_levels = self.search([("auto_create_packaging", "=", True)])
packaging_model = self.env["product.packaging"]
create_values = []
for product in existing_products:
packagings = product.packaging_ids
existing_packaging_levels = packagings.mapped("packaging_level_id")
missing_packaging_levels = (
required_packaging_levels - existing_packaging_levels
)
if not missing_packaging_levels:
continue

Check warning on line 33 in product_packaging_auto_create/models/product_packaging_level.py

View check run for this annotation

Codecov / codecov/patch

product_packaging_auto_create/models/product_packaging_level.py#L33

Added line #L33 was not covered by tests
create_values.extend(
[
plevel._prepare_required_packaging_vals(product)
for plevel in missing_packaging_levels
]
)
if create_values:
# TODO: consider using queue.job to split this in smaller chunks
# and have less impact on perf.
packaging_model.create(create_values)
msg = f"CREATED {len(create_values)} required packaging"
_logger.info(msg)
return msg
return True

Check warning on line 47 in product_packaging_auto_create/models/product_packaging_level.py

View check run for this annotation

Codecov / codecov/patch

product_packaging_auto_create/models/product_packaging_level.py#L47

Added line #L47 was not covered by tests

def _prepare_required_packaging_vals(self, product):
res = {
"packaging_level_id": self.id,
"name": self.name,
"product_id": product.id,
}
return res
3 changes: 3 additions & 0 deletions product_packaging_auto_create/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
5 changes: 5 additions & 0 deletions product_packaging_auto_create/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- [Camptocamp](https://www.camptocamp.com)
- Damien Crier \<<[email protected]>\>
- Simone Orsi \<<[email protected]>\>
- Phuc Tran Thanh \<<[email protected]>\>
- Tris Doan \<<[email protected]>\>
3 changes: 3 additions & 0 deletions product_packaging_auto_create/readme/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The development and migration of this module has been financially supported by:

- Camptocamp
4 changes: 4 additions & 0 deletions product_packaging_auto_create/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module allows to mark a product packaging level as auto-create-packaging.

A cron creates the missing product packages if the related packaging
level is auto-create-packaging.
4 changes: 4 additions & 0 deletions product_packaging_auto_create/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To set a packaging level as auto-create-packaging:
1. Go to *Inventory \> Configuration \> Product Packaging
Level*.
2. You can make a level auto-create-packaging
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading