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

[MIG] product_internal_code: Migration to 16.0 #493

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions product_internal_code/__manifest__.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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