File tree Expand file tree Collapse file tree 5 files changed +26
-22
lines changed
Expand file tree Collapse file tree 5 files changed +26
-22
lines changed Original file line number Diff line number Diff line change 33
44{
55 "name" : "Product Packaging Level" ,
6- "version" : "16 .0.1.2 .0" ,
6+ "version" : "17 .0.1.0 .0" ,
77 "development_status" : "Beta" ,
88 "category" : "Product" ,
99 "summary" : "This module binds a product packaging to a packaging level" ,
Original file line number Diff line number Diff line change 55from odoo import SUPERUSER_ID , api
66
77
8- def pre_init_hook (cr ):
9- if openupgrade .table_exists (cr , "product_packaging_type" ):
10- env = api .Environment (cr , SUPERUSER_ID , {})
8+ def pre_init_hook (env ):
9+ if openupgrade .table_exists (env . cr , "product_packaging_type" ):
10+ env = api .Environment (env . cr , SUPERUSER_ID , {})
1111 # Former version of the module is present
1212 models = [("product.packaging.type" , "product.packaging.level" )]
1313 openupgrade .rename_models (env .cr , models )
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class ProductPackagingLevel(models.Model):
1010 _order = "sequence, code"
1111
1212 def _default_language (self ):
13- lang_code = self .env ["ir.default" ].get ("res.partner" , "lang" )
13+ lang_code = self .env ["ir.default" ]._get ("res.partner" , "lang" )
1414 def_lang_id = self .env ["res.lang" ]._lang_get_id (lang_code )
1515 return def_lang_id or self ._active_languages ()[0 ]
1616
@@ -66,8 +66,8 @@ def _check_is_default(self):
6666 if msg :
6767 raise ValidationError (msg )
6868
69- def name_get ( self ):
70- result = []
71- for record in self :
72- result . append (( record . id , f"{ record .name } ({ record .code } )" ))
73- return result
69+ @ api . depends ( "name" , "code" )
70+ def _compute_display_name ( self ):
71+ for product_packaging_level in self :
72+ name = f"{ product_packaging_level .name } ({ product_packaging_level .code } )"
73+ product_packaging_level . display_name = name
Original file line number Diff line number Diff line change @@ -31,16 +31,26 @@ def setUpClass(cls):
3131 )
3232 cls .level_fr .with_context (lang = "fr_FR" ).name = "Packaging Level Test France"
3333 cls .packaging_default = cls .env ["product.packaging" ].create (
34- {"name" : "Packaging Default" , "qty" : 1.0 }
34+ {
35+ "name" : "Packaging Default" ,
36+ "qty" : 1.0 ,
37+ "product_id" : cls .env .ref ("product.product_product_5" ).id ,
38+ }
3539 )
3640 cls .packaging = cls .env ["product.packaging" ].create (
37- {"name" : "Packaging Test" , "packaging_level_id" : cls .level .id , "qty" : 1.0 }
41+ {
42+ "name" : "Packaging Test" ,
43+ "packaging_level_id" : cls .level .id ,
44+ "qty" : 1.0 ,
45+ "product_id" : cls .env .ref ("product.product_product_5" ).id ,
46+ }
3847 )
3948 cls .packaging_fr = cls .env ["product.packaging" ].create (
4049 {
4150 "name" : "Packaging Test" ,
4251 "packaging_level_id" : cls .level_fr .id ,
4352 "qty" : 1.0 ,
53+ "product_id" : cls .env .ref ("product.product_product_5" ).id ,
4454 }
4555 )
4656 cls .product = cls .env ["product.template" ].create (
Original file line number Diff line number Diff line change 1515 <field name =" barcode_required_for_gtin" invisible =" 1" />
1616 </field >
1717 <xpath expr =" //field[@name='barcode']" position =" attributes" >
18- <attribute
19- name =" attrs"
20- >{'required': [('barcode_required_for_gtin', '=', True)]}</attribute >
18+ <attribute name =" required" >barcode_required_for_gtin</attribute >
2119 </xpath >
2220 <field name =" name" position =" attributes" >
23- <attribute name =" invisible " >1</attribute >
21+ <attribute name =" column_invisible " >1</attribute >
2422 </field >
2523
2624 </field >
4644 <field name =" barcode_required_for_gtin" invisible =" 1" />
4745 </xpath >
4846 <xpath expr =" //field[@name='barcode']" position =" attributes" >
49- <attribute
50- name =" attrs"
51- >{'required': [('barcode_required_for_gtin', '=', True)]}</attribute >
47+ <attribute name =" required" >barcode_required_for_gtin</attribute >
5248 </xpath >
5349 <field name =" name" position =" attributes" >
5450 <attribute name =" force_save" >1</attribute >
55- <attribute
56- name =" attrs"
57- >{'readonly': [('name_policy', '!=', 'user_defined')]}</attribute >
51+ <attribute name =" readonly" >name_policy != 'user_defined'</attribute >
5852 </field >
5953
6054 </field >
You can’t perform that action at this time.
0 commit comments