Skip to content

Commit

Permalink
Merge 1277348 into 26b6d89
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelarre committed Sep 24, 2019
2 parents 26b6d89 + 1277348 commit 3d827b3
Show file tree
Hide file tree
Showing 35 changed files with 3,742 additions and 0 deletions.
129 changes: 129 additions & 0 deletions product_variant_default_code/README.rst
@@ -0,0 +1,129 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

============================
Product Variant Default Code
============================

This module automatically generate Product Reference (default_code)
according to attributes data with a configurable behavior.

It defines a reference mask on the product templates so the
variants references are automatically set. For example:

- Product template: Jacket
- Attributes:
- Color: White, Black
- Size: M, L
- Reference mask: `JKT01-[Color]-[Size]`

- Reference on variants:

- `JKT01-Wh-M` Jacket White M
- `JKT01-Bl-M` Jacket Black M
- `JKT01-Wh-L` Jacket White L
- `JKT01-Bl-L` Jacket Black L

Configuration
=============

To set the reference mask up on any product template 'Variant reference mask'
new field.

When creating a new product template without specifying the *Variant reference
mask*, a default value for *Variant reference mask* will be automatically
generated according to the attribute line settings on the product template (if
any). The mask will then be used as an instruction to generate default code of
each product variant of the product template with the corresponding *Attribute
Code* (of the attribute value) inserted. Besides the default value, *Variant
reference mask* can be configured to your liking, make sure putting the
*Attribute Name* inside `[]` marks (it is case sensitive).

Example:

Creating a product named *Jacket* with two attributes, *Size* and *Color*::

Product: Jacket
Color: Black(Bl), White(Wh) # Black and White are the attribute values;
'Bl' and 'Wh' are the corresponding codes
Size: L (L), XL(XL)
The automatically generated default value for the Variant reference mask will
be `[Color]-[Size]` and so the 'default code' on the variants will be `Bl-L`,
`Wh-L`, `Bl-XL` and `Wh-XL`.

The mask value can be fully customized whatever you like. You can even have
the attribute name appear more than once in the mask such as,
`Jacket/[Size]~[Color]~[Size]`, and the generated code on variants will be
something like `Jacket/L~Bl~L` (for variant with Color "Black" and Size "L").

When the code attribute is changed, it automatically regenerates the 'default
code' on all variants affected.

Aditionally, a product attribute can be set and so it will be appended to the
product `default_code`. In the first example, setting a `Color` code to `CO`
would give `default_code` like this: `COBl-L`, `COWh-L`, `COBl-XL` and
`COWh-XL`.

Avoiding mask in variants
-------------------------

You can avoid this behavior or force a manual default_code on variant. To do
so, go to *Product Variants > [any variant you want to set up]* and set
manually its reference code. The field `manual code` will be set to on and the
variant internal reference will no longer be changed by this module.

Unset `manual code` and the reference code will be unlocked again.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/137/10.0


Known issues / Roadmap
======================

In case of attribute name update, related mask are not updated.


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

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/product_variant/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing 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
------------

* Alfredo de la Fuente <alfredodelafuente@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Tony Gu <tony@openerp.cn>
* David Vidal <david.vidal@tecnativa.com>
* David Beal <david.beal@akretion.com>
* Daniel Campos <danielcampos@avanzosc.es>

Maintainer
----------

.. 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 https://odoo-community.org.
3 changes: 3 additions & 0 deletions product_variant_default_code/__init__.py
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import models
34 changes: 34 additions & 0 deletions product_variant_default_code/__manifest__.py
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Copyright 2014 AvancOSC - Alfredo de la Fuente
# Copyright 2014 Tecnativa - Pedro M. Baeza
# Copyright 2014 Shine IT - Tony Gu
# Copyright 2017 Tecnativa - David Vidal
# Copyright 2017 Akretion - David Beal
# Copyright 2018 AvancOSC - Daniel Campos
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Product Variant Default Code',
'version': '12.0.1.0.0',
'author': 'AvancOSC,'
'Shine IT,'
'Tecnativa,'
'Odoo Community Association (OCA)',
'website': 'https://odoo-community.org/',
'license': 'AGPL-3',
'category': 'Product',
'depends': [
'product',
],
'data': [
'security/product_security.xml',
'data/ir_config_parameter.xml',
'views/product_attribute_value_view.xml',
'views/product_attribute_view.xml',
'views/product_view.xml',
'views/config_settings_view.xml',
],
'demo': [
'demo/attribute_demo.xml',
],
'installable': True
}
16 changes: 16 additions & 0 deletions product_variant_default_code/data/ir_config_parameter.xml
@@ -0,0 +1,16 @@
<?xml version='1.0' encoding='UTF-8' ?>
<odoo noupdate="1">

<record id="default_reference_separator"
model="ir.config_parameter">
<field name="key">default_reference_separator</field>
<field name="value">-</field>
</record>

<record id="default_reference_missing_placeholder"
model="ir.config_parameter">
<field name="key">default_reference_missing_placeholder</field>
<field name="value">/</field>
</record>

</odoo>
19 changes: 19 additions & 0 deletions product_variant_default_code/demo/attribute_demo.xml
@@ -0,0 +1,19 @@
<?xml version='1.0' encoding='UTF-8' ?>
<odoo noupdate="1">

<record id="product.product_attribute_1" model="product.attribute">
<!-- Memory -->
<field name="code">M</field>
</record>

<record id="product.product_attribute_2" model="product.attribute">
<!-- Color -->
<field name="code">C</field>
</record>

<record id="product.product_attribute_3" model="product.attribute">
<!-- Wifi -->
<field name="code">W</field>
</record>

</odoo>
157 changes: 157 additions & 0 deletions product_variant_default_code/i18n/ar.po
@@ -0,0 +1,157 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_variant_default_code
#
# Translators:
# abdullah alsabi <alsabi.abdullah@gmail.com>, 2017
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-12-23 03:56+0000\n"
"PO-Revision-Date: 2017-12-23 03:56+0000\n"
"Last-Translator: abdullah alsabi <alsabi.abdullah@gmail.com>, 2017\n"
"Language-Team: Arabic (https://www.transifex.com/oca/teams/23907/ar/)\n"
"Language: ar\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 "
"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n"

#. module: product_variant_default_code
#: model:ir.model.fields,help:product_variant_default_code.field_product_product_code_prefix
#: model:ir.model.fields,help:product_variant_default_code.field_product_template_code_prefix
msgid "Add prefix to product variant reference (default code)"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model.fields,field_description:product_variant_default_code.field_product_attribute_code
msgid "Attribute Code"
msgstr ""

#. module: product_variant_default_code
#: code:addons/product_variant_default_code/models/product.py:182
#: sql_constraint:product.attribute:0
#, python-format
msgid "Attribute Name must be unique!"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model.fields,field_description:product_variant_default_code.field_product_attribute_value_code
msgid "Attribute Value Code"
msgstr ""

#. module: product_variant_default_code
#: selection:res.config.settings,group_product_default_code:0
msgid "Automask"
msgstr ""

#. module: product_variant_default_code
#: model:ir.ui.view,arch_db:product_variant_default_code.view_general_configuration
msgid "Defines how you want to manage the Variant default code"
msgstr ""

#. module: product_variant_default_code
#: code:addons/product_variant_default_code/models/product.py:38
#, python-format
msgid "Found unrecognized attribute name in \"Variant Reference Mask\""
msgstr ""

#. module: product_variant_default_code
#: selection:res.config.settings,group_product_default_code:0
msgid "Manual Mask"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model.fields,field_description:product_variant_default_code.field_product_product_manual_code
msgid "Manual Reference"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model,name:product_variant_default_code.model_product_product
msgid "Product"
msgstr "المنتج"

#. module: product_variant_default_code
#: model:ir.model,name:product_variant_default_code.model_product_attribute
msgid "Product Attribute"
msgstr ""

#. module: product_variant_default_code
#: model:res.groups,name:product_variant_default_code.group_product_default_code
msgid "Product Default Code Behavior"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model.fields,field_description:product_variant_default_code.field_res_config_settings_group_product_default_code
#: model:ir.ui.view,arch_db:product_variant_default_code.view_general_configuration
msgid "Product Default Code behaviour"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model,name:product_variant_default_code.model_product_template
msgid "Product Template"
msgstr ""

#. module: product_variant_default_code
#: model:ir.ui.view,arch_db:product_variant_default_code.view_general_configuration
#, fuzzy
msgid "Product Variants"
msgstr "المنتج"

#. module: product_variant_default_code
#: model:ir.model.fields,field_description:product_variant_default_code.field_product_product_code_prefix
#: model:ir.model.fields,field_description:product_variant_default_code.field_product_template_code_prefix
msgid "Reference Prefix"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model.fields,help:product_variant_default_code.field_product_product_reference_mask
#: model:ir.model.fields,help:product_variant_default_code.field_product_template_reference_mask
msgid ""
"Reference mask for building internal references of a variant generated from "
"this template.\n"
"Example:\n"
"A product named ABC with 2 attributes: Size and Color:\n"
"Product: ABC\n"
"Color: Red(r), Yellow(y), Black(b) #Red, Yellow, Black are the attribute "
"value, `r`, `y`, `b` are the corresponding code\n"
"Size: L (l), XL(x)\n"
"When setting Variant reference mask to `[Color]-[Size]`, the default code on "
"the variants will be something like `r-l` `b-l` `r-x` ...\n"
"If you like, You can even have the attribute name appear more than once in "
"the mask. Such as,`fancyA/[Size]~[Color]~[Size]`\n"
" When saved, the default code on variants will be something like \n"
" `fancyA/l~r~l` (for variant with Color \"Red\" and Size \"L\") `fancyA/"
"x~y~x` (for variant with Color \"Yellow\" and Size \"XL\")\n"
"Note: make sure characters \"[,]\" do not appear in your attribute name"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model.fields,help:product_variant_default_code.field_res_config_settings_group_product_default_code
msgid ""
"Set behaviour of codes (depends on variant use: see Sales/Purchases "
"configuration)"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model.fields,field_description:product_variant_default_code.field_product_product_reference_mask
#: model:ir.model.fields,field_description:product_variant_default_code.field_product_template_reference_mask
msgid "Variant reference mask"
msgstr ""

#. module: product_variant_default_code
#: model:ir.ui.view,arch_db:product_variant_default_code.product_template_only_form_view
msgid "[attribute3]-[attribute1]"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model,name:product_variant_default_code.model_product_attribute_value
msgid "product.attribute.value"
msgstr ""

#. module: product_variant_default_code
#: model:ir.model,name:product_variant_default_code.model_res_config_settings
msgid "res.config.settings"
msgstr ""

0 comments on commit 3d827b3

Please sign in to comment.