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

[17.0][MIG] product_variant_default_code: Migration to 17.0 #369

Closed
Closed
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
4c93dbb
[NEW product_variant_default_code]
Oct 21, 2014
6cf0457
[FIX] product_variant_default_code: Fixed some problems and enhance code
pedrobaeza Nov 18, 2014
47c3a26
[IMP product_variant_default_code]
Nov 20, 2014
646e203
setup a mask to control the output of variant default code
digitalsatori Dec 29, 2014
57b6d14
[FIX product_variant_default_code]
Jan 16, 2015
37f424c
[FIX] product_variant_default_code: Fix error when no reference mask …
pedrobaeza Feb 22, 2015
0bb07de
Slovene translations of odoomrp modules
sysadminmatmoz Aug 15, 2015
2c0141d
[REF] product_variant_default_code: Modular programming on method ren…
Dec 23, 2015
058176b
[MIG] product_variant_default_code: Migration to 10.0
chienandalu Jul 25, 2017
215166f
[IMP] Attribute code integration
chienandalu Sep 14, 2017
dc582b5
[IMP] Merge product_code_builder functionalities
chienandalu Sep 20, 2017
3ef6ded
[IMP] dependency, field name, complete view
bealdav Oct 11, 2017
f05cee8
[MIG] product_variant_default_code
Feb 21, 2018
45fcedb
[IMP+FIX] product_variant_default_code: Several things:
Jun 7, 2018
ea89d67
[FIX] product_variant_default_code: Read parameters with sudo()
pedrobaeza Nov 7, 2018
159aa88
[MIG] product_variant_default_code: Migration to 12.0
mikelarre Sep 24, 2019
fc6ab64
Translated using Weblate (Croatian)
badbole Dec 4, 2019
dce9ee4
[FIX] product_variant_default_code: fix product.template write to acc…
Feb 20, 2020
6742e03
Added translation using Weblate (Portuguese)
pedrocs-exo Jun 2, 2020
9b2299a
Translated using Weblate (Portuguese)
pedrocs-exo Jun 2, 2020
f3b0b95
[IMP] product_variant_default_code: black, isort, prettier
joao-p-marques Nov 2, 2020
7ac1f45
[MIG] product_variant_default_code: Migration to 13.0
joao-p-marques Nov 3, 2020
2ac95c2
[UPD] Update product_variant_default_code.pot
oca-travis Nov 9, 2020
7f086d5
[IMP] product_variant_default_code: black, isort, prettier
joao-p-marques Nov 10, 2020
5c7adf6
[MIG] product_variant_default_code: Migration to 14.0
joao-p-marques Nov 10, 2020
e9316e0
[UPD] Update product_variant_default_code.pot
oca-travis Nov 11, 2020
b4eb4aa
[UPD] README.rst
OCA-git-bot Nov 11, 2020
f301a79
[14.0] [FIX] enable edit of attribute code in form view
andreampiovesana Dec 12, 2020
aa10693
[FIX] product_variant_default_code: Allow to edit attribute code
pedrobaeza Feb 5, 2021
a6ded79
[FIX] product_variant_default_code: don't translate mask
chienandalu Feb 16, 2021
6a07f40
product_variant_default_code 14.0.1.1.1
OCA-git-bot Feb 16, 2021
06162cf
[FIX] product_variant_default_code: fix onchange code value
chienandalu Feb 18, 2021
d1953ae
product_variant_default_code 14.0.1.1.2
OCA-git-bot Feb 19, 2021
dca78a1
[FIX] product_variant_default_code: FIx tests
joao-p-marques Feb 26, 2021
ce6601d
product_variant_default_code 14.0.1.1.3
OCA-git-bot Mar 7, 2021
552d8fc
product_variant_default_code 14.0.1.1.4
OCA-git-bot Jul 29, 2021
54e2cbc
[14.0][IMP] product_variant_default_code: prefix_code as default_code…
Kev-Roche Sep 13, 2021
01bbc85
[UPD] Update product_variant_default_code.pot
oca-travis Sep 18, 2021
189ccde
product_variant_default_code 14.0.2.0.0
OCA-git-bot Sep 18, 2021
0b9e96e
Update translation files
oca-transbot Sep 18, 2021
975f567
[IMP] update dotfiles [ci skip]
OCA-git-bot Mar 31, 2022
b0af316
[FIX]product_variant_default_code add tests
Kev-Roche Nov 17, 2021
63b7cc8
[FIX] product_variant_default_code fixes
Kev-Roche Nov 17, 2021
08a6778
[FIX] no update when both code_prefix and reference_mask changing
Kev-Roche Jan 26, 2022
5367694
[UPD] Update product_variant_default_code.pot
oca-travis May 19, 2022
963adb8
[UPD] README.rst
OCA-git-bot May 19, 2022
f71ec74
product_variant_default_code 14.0.3.0.0
OCA-git-bot May 19, 2022
eb3a413
Update translation files
oca-transbot May 19, 2022
c095078
Translated using Weblate (Italian)
francesco-ooops May 31, 2022
23be056
Translated using Weblate (Italian)
SicurSam May 31, 2022
cd427f9
Translated using Weblate (Italian)
francesco-ooops May 31, 2022
a277e9f
Translated using Weblate (Italian)
francesco-ooops May 31, 2022
2691d10
[IMP][14.0] product tmpl default_code as default prefix_code
Kev-Roche Sep 7, 2022
75d85d3
product_variant_default_code 14.0.3.0.1
OCA-git-bot Feb 9, 2023
01893f1
[FIX][product_variant_default_code] check code of active value_ids
Kev-Roche Oct 26, 2022
b0b3299
[16.0][MIG] product_variant_default_code: migration to 16.0
Rferri44-S73 Mar 13, 2023
220f02b
[UPD] Update product_variant_default_code.pot
May 2, 2023
2d4bc3e
[UPD] README.rst
OCA-git-bot May 2, 2023
0258370
Update translation files
weblate May 2, 2023
cd33060
Revert "[FIX][product_variant_default_code] check code of active valu…
pedrobaeza May 3, 2023
eb99083
product_variant_default_code 16.0.1.0.1
OCA-git-bot May 3, 2023
6a50122
[FIX] product_variant_default_code: fix template error
pilarvargas-tecnativa May 6, 2023
d70bc2a
product_variant_default_code 16.0.1.0.2
OCA-git-bot May 6, 2023
4495e56
[IMP] product_variant_default_code: pre-commit auto fixes
arantxa-s73 Oct 16, 2024
49e27f9
[MIG] product_variant_default_code: Migration to 17.0
arantxa-s73 Oct 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
Prev Previous commit
Next Next commit
[MIG] product_variant_default_code: Migration to 10.0
chienandalu authored and arantxa-s73 committed Oct 16, 2024
commit 058176b5e6a4b855cc298d4ad3c71862285ad0bc
127 changes: 101 additions & 26 deletions product_variant_default_code/README.rst
Original file line number Diff line number Diff line change
@@ -1,37 +1,112 @@
Product Variant Default Code(product_variant_default_code)
-----------------------------------------------------------
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

In 'product.template' object new field 'Variant reference mask' is added
============================
Product Variant Default Code
============================

In 'product.attribute.value' object new field 'Attribute Code' is added.
This module allows to define a reference mask on the product templates so the
variants references are automatically set. For example:

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.
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 configure to your liking, make sure puting Attribut Name
inside '[]' mark.
- 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 'A' with two attributes, 'Size' and 'Color'::
Creating a product named *Jacket* with two attributes, *Size* and *Color*::

Product: A
Color: Red(r), Yellow(y), Black(b) #Red, Yellow, Black are the attribute
value, 'r', 'y', 'b' are the corresponding code
Size: L (l), XL(x)
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 then the 'default code' on the variants will be
something like `r-l` `b-l` `r-x` ...
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 custumizedwhatever 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.

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

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.com>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Tony Gu <tony@openerp.cn>
* David Vidal <david.vidal@tecnativa.com>

Maintainer
----------

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

This module is maintained by the OCA.

If you like, you can change the mask value whatever you like. You can even have
the attribute name appear more than once in the mask such as ,
`fancyA/[Size]~[Color]~[Size]`, when saved the default code on variants will be
something like `fancyA/l~r~l` (for variant with Color "Red" and Size "L")
`fancyA/x~y~x` (for variant with Color "Yellow" and Size "XL").
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.

when the code attribute is changed, it automatically regenerates the 'default
code'.
To contribute to this module, please visit https://odoo-community.org.
17 changes: 1 addition & 16 deletions product_variant_default_code/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
##############################################################################

from . import models
25 changes: 25 additions & 0 deletions product_variant_default_code/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- 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
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Product Variant Default Code',
'version': '10.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': [
'views/product_attribute_value_view.xml',
'views/product_view.xml',
],
'installable': True
}
36 changes: 0 additions & 36 deletions product_variant_default_code/__openerp__.py

This file was deleted.

79 changes: 0 additions & 79 deletions product_variant_default_code/i18n/product_variant_default_code.pot

This file was deleted.

17 changes: 1 addition & 16 deletions product_variant_default_code/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
##############################################################################

from . import product
72 changes: 27 additions & 45 deletions product_variant_default_code/models/product.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
##############################################################################
from openerp import models, fields, api, _
from openerp.exceptions import except_orm
# -*- 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
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import _, api, fields, models
from odoo.exceptions import UserError
import re
from string import Template
from collections import defaultdict
@@ -45,8 +35,8 @@ def sanitize_reference_mask(product, mask):
for line in product.attribute_line_ids:
attribute_names.add(line.attribute_id.name)
if not tokens.issubset(attribute_names):
raise except_orm(_('Error'), _('Found unrecognized attribute name in '
'"Variant Reference Mask"'))
raise UserError(_('Found unrecognized attribute name in "Variant '
'Reference Mask"'))


def get_rendered_default_code(product, mask):
@@ -109,7 +99,6 @@ def create(self, vals):
sanitize_reference_mask(product, vals['reference_mask'])
return super(ProductTemplate, self).create(vals)

@api.one
def write(self, vals):
product_obj = self.env['product.product']
if 'reference_mask' in vals and not vals['reference_mask']:
@@ -138,13 +127,12 @@ class ProductProduct(models.Model):
manual_code = fields.Boolean(string='Manual code')

@api.model
def create(self, values):
product = super(ProductProduct, self).create(values)
def create(self, vals):
product = super(ProductProduct, self).create(vals)
if product.reference_mask:
render_default_code(product, product.reference_mask)
return product

@api.one
@api.onchange('default_code')
def onchange_default_code(self):
self.manual_code = bool(self.default_code)
@@ -160,35 +148,29 @@ class ProductAttribute(models.Model):
class ProductAttributeValue(models.Model):
_inherit = 'product.attribute.value'

@api.one
@api.onchange('name')
def onchange_name(self):
if self.name:
self.attribute_code = self.name[0:2]

attribute_code = fields.Char(
string='Attribute Code', default=onchange_name)
string='Attribute Code',
default=onchange_name,
)

@api.model
def create(self, values):
if 'attribute_code' not in values:
values['attribute_code'] = values.get('name', '')[0:2]
value = super(ProductAttributeValue, self).create(values)
return value
def create(self, vals):
if 'attribute_code' not in vals:
vals['attribute_code'] = vals.get('name', '')[0:2]
return super(ProductAttributeValue, self).create(vals)

@api.one
def write(self, vals):
attribute_line_obj = self.env['product.attribute.line']
product_obj = self.env['product.product']
if 'attribute_code' not in vals:
return super(ProductAttributeValue, self).write(vals)
result = super(ProductAttributeValue, self).write(vals)
if 'attribute_code' in vals:
cond = [('attribute_id', '=', self.attribute_id.id)]
attribute_lines = attribute_line_obj.search(cond)
for line in attribute_lines:
cond = [('product_tmpl_id', '=', line.product_tmpl_id.id),
('manual_code', '=', False)]
products = product_obj.search(cond)
for product in products:
if product.reference_mask:
render_default_code(product, product.reference_mask)
# Rewrite reference on all product variants affected
for product in self.mapped('product_ids').filtered(
lambda x: x.product_tmpl_id.reference_mask and not
x.manual_code):
render_default_code(product, product.reference_mask)
return result
3 changes: 3 additions & 0 deletions product_variant_default_code/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- encoding: utf-8 -*-

from . import test_variant_default_code
125 changes: 125 additions & 0 deletions product_variant_default_code/tests/test_variant_default_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo.exceptions import UserError
from odoo.tests import common


class TestVariantDefaultCode(common.SavepointCase):

@classmethod
def setUpClass(cls):
super(TestVariantDefaultCode, cls).setUpClass()
cls.attr1 = cls.env['product.attribute'].create({'name': 'TSize'})
cls.attr2 = cls.env['product.attribute'].create({'name': 'TColor'})
cls.attr1_1 = cls.env['product.attribute.value'].create({
'name': 'L', 'attribute_id': cls.attr1.id
})
cls.attr1_2 = cls.env['product.attribute.value'].create({
'name': 'XL', 'attribute_id': cls.attr1.id
})
cls.attr2_1 = cls.env['product.attribute.value'].create({
'name': 'Red', 'attribute_id': cls.attr2.id
})
cls.attr2_2 = cls.env['product.attribute.value'].create({
'name': 'Green', 'attribute_id': cls.attr2.id
})
cls.template1 = cls.env['product.template'].create({
'name': 'Jacket',
'attribute_line_ids': [
(0, 0, {'attribute_id': cls.attr1.id,
'value_ids': [(6, 0, [cls.attr1_1.id, cls.attr1_2.id])]
}),
(0, 0, {'attribute_id': cls.attr2.id,
'value_ids': [(6, 0, [cls.attr2_1.id, cls.attr2_2.id])]
}),
],
})
# This one with a preset reference mask
cls.template2 = cls.env['product.template'].create({
'name': 'Pants',
'attribute_line_ids': [
(0, 0, {'attribute_id': cls.attr1.id,
'value_ids': [(6, 0, [cls.attr1_1.id, cls.attr1_2.id])]
}),
(0, 0, {'attribute_id': cls.attr2.id,
'value_ids': [(6, 0, [cls.attr2_1.id, cls.attr2_2.id])]
}),
],
'reference_mask': 'P01/[TSize][TColor]',
})

def test_01_check_default_codes(self):
# As no mask was set, a default one should be:
self.assertEqual(self.template1.reference_mask, '[TSize]-[TColor]')
# Check that variants code are generated according to rules
for product in self.template1.mapped('product_variant_ids'):
expected_code = (product.attribute_value_ids[0].name[0:2] +
'-' + product.attribute_value_ids[1].name[0:2])
self.assertEqual(product.default_code, expected_code)

def test_02_check_default_codes_preexistent_mask(self):
for product in self.template2.mapped('product_variant_ids'):
expected_code = ('P01/' +
product.attribute_value_ids[0].name[0:2] +
product.attribute_value_ids[1].name[0:2])
self.assertEqual(product.default_code, expected_code)

def test_03_reset_reference_mask_to_default(self):
# Erase the previous mask: 'P01/[TSize][TColor]'
self.template2.reference_mask = ''
# Mask is set to default now:
self.assertEqual(self.template1.reference_mask, '[TSize]-[TColor]')

def test_04_custom_reference_mask(self):
self.template1.reference_mask = u'JKTÜ/[TColor]#[TSize]'
for product in self.template1.mapped('product_variant_ids'):
expected_code = (u'JKTÜ/' +
product.attribute_value_ids[1].name[0:2] + '#' +
product.attribute_value_ids[0].name[0:2])
self.assertEqual(product.default_code, expected_code)

def test_05_manual_code(self):
self.assertEqual(self.template1.product_variant_ids[0].manual_code,
False)
self.template1.product_variant_ids[0].default_code = 'CANT-TOUCH-THIS'
self.template1.product_variant_ids[0].onchange_default_code()
self.assertEqual(self.template1.product_variant_ids[0].manual_code,
True)
# Set a reference mask and check the other variants are changed
self.template1.reference_mask = 'J[TColor][TSize]'
for product in self.template1.mapped('product_variant_ids')[1:]:
expected_code = ('J' +
product.attribute_value_ids[1].name[0:2] +
product.attribute_value_ids[0].name[0:2])
self.assertEqual(product.default_code, expected_code)
# But this one isn't:
self.assertEqual(self.template1.product_variant_ids[0].default_code,
'CANT-TOUCH-THIS')

def test_06_attribute_value_code_change_propagation(self):
self.attr1_1.attribute_code = 'OO'
# Check that the change spreads to every product
for product in self.attr1_1.mapped('product_ids'):
self.assertTrue('OO' in product.default_code)

def test_07_attribute_value_name_change(self):
self.attr1_1.name = 'Odoo'
self.attr1_1.onchange_name()
self.assertEqual(self.attr1_1.attribute_code, 'Od')
# Check that the change spreads to every product
for product in self.attr1_1.mapped('product_ids'):
self.assertTrue('Od' in product.default_code)

def test_08_sanitize_exception(self):
with self.assertRaises(UserError):
self.env['product.template'].create({
'name': 'Shirt',
'attribute_line_ids': [
(0, 0, {'attribute_id': self.attr1.id,
'value_ids': [(6, 0, [self.attr1_1.id])]
}),
],
'reference_mask': 'FAIL:[TSize][TWrongAttr]',
})
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="variants_template_tree_view_inh_variantdefaultcode" model="ir.ui.view">
<field name="name">variants.template.tree.view.inh.variantdefaultcode</field>
<field name="model">product.attribute.value</field>
<field name="inherit_id" ref="product.variants_template_tree_view"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="attribute_code" />
</field>
<odoo>

<record id="variants_tree_view_inh_variantdefaultcode"
model="ir.ui.view">
<field name="name">
variants.tree.view.inh.variantdefaultcode
</field>
</record>
<record id="variants_tree_view_inh_variantdefaultcode" model="ir.ui.view">
<field name="name">variants.tree.view.inh.variantdefaultcode</field>
<field name="model">product.attribute.value</field>
<field name="inherit_id" ref="product.variants_tree_view"/>
<field name="arch" type="xml">
@@ -21,5 +14,5 @@
</field>
</field>
</record>
</data>
</openerp>

</odoo>
28 changes: 18 additions & 10 deletions product_variant_default_code/views/product_view.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="product_template_only_form_view_inh_variantdefaultcode" model="ir.ui.view">
<field name="name">product.template.only.form.view.inh.variantdefaultcode</field>
<odoo>

<record id="product_template_only_form_view_inh_variantdefaultcode"
model="ir.ui.view">
<field name="name">
product.template.only.form.view.inh.variantdefaultcode
</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="inherit_id"
ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<field name="default_code" position="before">
<field name="reference_mask"
modifiers="{'invisible': [['attribute_line_ids', '=', False]]}"/>
attrs="{'invisible':
[('attribute_line_ids', '=', [])]}"/>
</field>
</field>
</record>
<record id="product_normal_form_view_inh_variantdefaultcode" model="ir.ui.view">
<field name="name">product.normal.form.view.inh.variantdefaultcode</field>
<record id="product_normal_form_view_inh_variantdefaultcode"
model="ir.ui.view">
<field name="name">
product.normal.form.view.inh.variantdefaultcode
</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
@@ -22,5 +30,5 @@
</field>
</field>
</record>
</data>
</openerp>

</odoo>