Skip to content

Commit

Permalink
[MIG] product_internal_code: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vib-adhoc committed Jan 31, 2023
1 parent 4187cc6 commit c5c3d4a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions product_internal_code/__manifest__.py
Expand Up @@ -20,7 +20,7 @@

{
"name": "Product Internal Code",
'version': "15.0.1.0.0",
'version': "16.0.1.0.0",
'category': 'Tools',
'sequence': 14,
'author': 'ADHOC SA',
Expand All @@ -39,7 +39,7 @@
],
'test': [
],
'installable': False,
'installable': True,
'auto_install': False,
'application': False,
}
10 changes: 5 additions & 5 deletions product_internal_code/data/product_data.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo noupdate="1">
<record id="sequence" model="ir.sequence">
<field name="name">product</field>
<field name="code">product.internal.code</field>
<field name="padding">4</field>
</record>
<record id="sequence" model="ir.sequence">
<field name="name">product</field>
<field name="code">product.internal.code</field>
<field name="padding">4</field>
</record>
</odoo>
15 changes: 8 additions & 7 deletions product_internal_code/models/product_product.py
Expand Up @@ -12,13 +12,14 @@ class ProductProduct(models.Model):
internal_code = fields.Char(
'Internal Code', copy=False)

@api.model
def create(self, vals):
if (not vals.get('internal_code', False) and not self.
_context.get('default_internal_code', False)):
vals['internal_code'] = self.env[
'ir.sequence'].next_by_code('product.internal.code')
return super().create(vals)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if (not vals.get('internal_code', False) and not self.
_context.get('default_internal_code', False)):
vals['internal_code'] = self.env[
'ir.sequence'].next_by_code('product.internal.code')
return super().create(vals_list)

_sql_constraints = {
('internal_code_uniq', 'unique(internal_code)',
Expand Down
13 changes: 7 additions & 6 deletions product_internal_code/models/product_template.py
Expand Up @@ -14,9 +14,10 @@ class ProductTemplate(models.Model):
string='Internal Code',
readonly=False)

@api.model
def create(self, vals):
if vals.get('internal_code'):
self = self.with_context(
default_internal_code=vals.get('internal_code'))
return super().create(vals)
@api.model_create_multi
def create(self, vals_list):
for vals in vals_list:
if vals.get('internal_code'):
self = self.with_context(
default_internal_code=vals.get('internal_code'))
return super().create(vals_list)
2 changes: 1 addition & 1 deletion product_internal_code/views/product_views.xml
Expand Up @@ -7,7 +7,7 @@
<field name="priority">10</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<field name="pricelist_id" position="before">
<field name="attribute_line_ids" position="after">
<field name="internal_code" filter_domain="[('internal_code','=',self)]"/>
</field>
</field>
Expand Down

0 comments on commit c5c3d4a

Please sign in to comment.