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

[16.0][MIG] rotordc_autofill_product_variant: migration to 16.0 #117

Open
wants to merge 15 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
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
67 changes: 67 additions & 0 deletions rotordc_autofill_product_variant/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
================================
RotorDC Autofill Product Variant
================================

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

.. |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-coopiteasy%2Fcie--custom-lightgray.png?logo=github
:target: https://github.com/coopiteasy/cie-custom/tree/16.0/rotordc_autofill_product_variant
:alt: coopiteasy/cie-custom

|badge1| |badge2| |badge3|

Autofill the following field when creating a new product variant based
on fields of the product template :

* Internal reference
* Weight
* Dimensions (from product_dimension module)

**Table of contents**

.. contents::
:local:

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

Bugs are tracked on `GitHub Issues <https://github.com/coopiteasy/cie-custom/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/coopiteasy/cie-custom/issues/new?body=module:%20rotordc_autofill_product_variant%0Aversion:%2016.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
~~~~~~~

* Coop IT Easy SC

Contributors
~~~~~~~~~~~~

* `Coop IT Easy SC <https://coopiteasy.be>`_:

* Rémy Taymans

Maintainers
~~~~~~~~~~~

This module is part of the `coopiteasy/cie-custom <https://github.com/coopiteasy/cie-custom/tree/16.0/rotordc_autofill_product_variant>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions rotordc_autofill_product_variant/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
22 changes: 22 additions & 0 deletions rotordc_autofill_product_variant/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2022 Coop IT Easy SC
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "RotorDC Autofill Product Variant",
"summary": """Autofill some field of the product variant based on
the product template.""",
"version": "16.0.1.0.0",
"category": "Uncategorized",
"website": "https://coopiteasy.be",
"author": "Coop IT Easy SC",
"license": "AGPL-3",
"application": False,
"depends": [
"product",
"product_dimension",
],
"excludes": [],
"data": [],
"demo": [],
"qweb": [],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * rotordc_autofill_product_variant
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \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: rotordc_autofill_product_variant
#: model:ir.model,name:rotordc_autofill_product_variant.model_product_product
msgid "Product"
msgstr ""

1 change: 1 addition & 0 deletions rotordc_autofill_product_variant/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_product
40 changes: 40 additions & 0 deletions rotordc_autofill_product_variant/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2022 Coop IT Easy SCRL fs
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).


from itertools import groupby

from odoo import api, models


class ProductProduct(models.Model):
_inherit = "product.product"

@api.model_create_multi
def create(self, vals_list):
"""Copy some field from the product template to the new variant"""
# Be mindful that this method is also entered during the creation of a
# product_template.product_variant_id.

# Enter this loop once for every product.template. `group_vals` is an
# iterator of vals for each product that has the same template.
for tmpl_id, group_vals in groupby(
vals_list, lambda elem: elem.get("product_tmpl_id", None)
):
if not tmpl_id:
continue
product_tmpl_id = self.env["product.template"].browse(tmpl_id)
for vals in group_vals:
if "default_code" not in vals:
vals["default_code"] = product_tmpl_id.default_code
if "weight" not in vals:
vals["weight"] = product_tmpl_id.weight
if "dimensional_uom_id" not in vals:
vals["dimensional_uom_id"] = product_tmpl_id.dimensional_uom_id.id
if "product_length" not in vals:
vals["product_length"] = product_tmpl_id.product_length
if "product_height" not in vals:
vals["product_height"] = product_tmpl_id.product_height
if "product_width" not in vals:
vals["product_width"] = product_tmpl_id.product_width
return super().create(vals_list)
3 changes: 3 additions & 0 deletions rotordc_autofill_product_variant/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Coop IT Easy SC <https://coopiteasy.be>`_:

* Rémy Taymans
6 changes: 6 additions & 0 deletions rotordc_autofill_product_variant/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Autofill the following field when creating a new product variant based
on fields of the product template :

* Internal reference
* Weight
* Dimensions (from product_dimension module)
Loading
Loading