[IMP] product: move product packaging field from product.product to product.template
This commit is contained in:
parent
74600a8035
commit
36cdac48b7
|
@ -29,7 +29,7 @@ function openerp_pos_db(instance, module){
|
||||||
this.category_parent = {};
|
this.category_parent = {};
|
||||||
this.category_search_string = {};
|
this.category_search_string = {};
|
||||||
this.packagings_by_id = {};
|
this.packagings_by_id = {};
|
||||||
this.packagings_by_product_id = {};
|
this.packagings_by_product_tmpl_id = {};
|
||||||
this.packagings_by_ean13 = {};
|
this.packagings_by_ean13 = {};
|
||||||
},
|
},
|
||||||
/* returns the category object from its id. If you pass a list of id as parameters, you get
|
/* returns the category object from its id. If you pass a list of id as parameters, you get
|
||||||
|
@ -130,7 +130,7 @@ function openerp_pos_db(instance, module){
|
||||||
if(product.default_code){
|
if(product.default_code){
|
||||||
str += '|' + product.default_code;
|
str += '|' + product.default_code;
|
||||||
}
|
}
|
||||||
var packagings = this.packagings_by_product_id[product.id] || [];
|
var packagings = this.packagings_by_product_tmpl_id[product.product_tmpl_id] || [];
|
||||||
for(var i = 0; i < packagings.length; i++){
|
for(var i = 0; i < packagings.length; i++){
|
||||||
str += '|' + packagings[i].ean;
|
str += '|' + packagings[i].ean;
|
||||||
}
|
}
|
||||||
|
@ -149,6 +149,7 @@ function openerp_pos_db(instance, module){
|
||||||
if (product.variants){
|
if (product.variants){
|
||||||
product.name = product.name+" ("+product.variants+")";
|
product.name = product.name+" ("+product.variants+")";
|
||||||
}
|
}
|
||||||
|
product.product_tmpl_id = product.product_tmpl_id[0];
|
||||||
if(!stored_categories[categ_id]){
|
if(!stored_categories[categ_id]){
|
||||||
stored_categories[categ_id] = [];
|
stored_categories[categ_id] = [];
|
||||||
}
|
}
|
||||||
|
@ -186,10 +187,10 @@ function openerp_pos_db(instance, module){
|
||||||
for(var i = 0, len = packagings.length; i < len; i++){
|
for(var i = 0, len = packagings.length; i < len; i++){
|
||||||
var pack = packagings[i];
|
var pack = packagings[i];
|
||||||
this.packagings_by_id[pack.id] = pack;
|
this.packagings_by_id[pack.id] = pack;
|
||||||
if(!this.packagings_by_product_id[pack.product_id[0]]){
|
if(!this.packagings_by_product_tmpl_id[pack.product_tmpl_id[0]]){
|
||||||
this.packagings_by_product_id[pack.product_id[0]] = [];
|
this.packagings_by_product_tmpl_id[pack.product_tmpl_id[0]] = [];
|
||||||
}
|
}
|
||||||
this.packagings_by_product_id[pack.product_id[0]].push(pack);
|
this.packagings_by_product_tmpl_id[pack.product_tmpl_id[0]].push(pack);
|
||||||
if(pack.ean){
|
if(pack.ean){
|
||||||
this.packagings_by_ean13[pack.ean] = pack;
|
this.packagings_by_ean13[pack.ean] = pack;
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,18 +204,19 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||||
self.accounting_precision = precision;
|
self.accounting_precision = precision;
|
||||||
console.log("PRECISION",precision);
|
console.log("PRECISION",precision);
|
||||||
*/
|
*/
|
||||||
return self.fetch('product.packaging',['ean','product_id']);
|
return self.fetch('product.packaging',['ean','product_tmpl_id']);
|
||||||
}).then(function(packagings){
|
}).then(function(packagings){
|
||||||
self.db.add_packagings(packagings);
|
self.db.add_packagings(packagings);
|
||||||
|
|
||||||
return self.fetch('pos.category', ['id','name','parent_id','child_id','image'])
|
return self.fetch('pos.category', ['id','name','parent_id','child_id','image']);
|
||||||
}).then(function(categories){
|
}).then(function(categories){
|
||||||
self.db.add_categories(categories);
|
self.db.add_categories(categories);
|
||||||
|
|
||||||
return self.fetch(
|
return self.fetch(
|
||||||
'product.product',
|
'product.product',
|
||||||
['name', 'list_price','price','pos_categ_id', 'taxes_id', 'ean13', 'default_code', 'variants',
|
['name', 'list_price','price','pos_categ_id', 'taxes_id', 'ean13', 'default_code', 'variants',
|
||||||
'to_weight', 'uom_id', 'uos_id', 'uos_coeff', 'mes_type', 'description_sale', 'description'],
|
'to_weight', 'uom_id', 'uos_id', 'uos_coeff', 'mes_type', 'description_sale', 'description',
|
||||||
|
'product_tmpl_id'],
|
||||||
[['sale_ok','=',true],['available_in_pos','=',true]],
|
[['sale_ok','=',true],['available_in_pos','=',true]],
|
||||||
{pricelist: self.pricelist.id} // context for price
|
{pricelist: self.pricelist.id} // context for price
|
||||||
);
|
);
|
||||||
|
@ -230,7 +231,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||||
}).then(function(bankstatements){
|
}).then(function(bankstatements){
|
||||||
var journals = [];
|
var journals = [];
|
||||||
_.each(bankstatements,function(statement) {
|
_.each(bankstatements,function(statement) {
|
||||||
journals.push(statement.journal_id[0])
|
journals.push(statement.journal_id[0]);
|
||||||
});
|
});
|
||||||
self.bankstatements = bankstatements;
|
self.bankstatements = bankstatements;
|
||||||
return self.fetch('account.journal', undefined, [['id','in', journals]]);
|
return self.fetch('account.journal', undefined, [['id','in', journals]]);
|
||||||
|
@ -238,7 +239,7 @@ function openerp_pos_models(instance, module){ //module is instance.point_of_sal
|
||||||
self.journals = journals;
|
self.journals = journals;
|
||||||
|
|
||||||
// associate the bank statements with their journals.
|
// associate the bank statements with their journals.
|
||||||
var bankstatements = self.bankstatements
|
var bankstatements = self.bankstatements;
|
||||||
for(var i = 0, ilen = bankstatements.length; i < ilen; i++){
|
for(var i = 0, ilen = bankstatements.length; i < ilen; i++){
|
||||||
for(var j = 0, jlen = journals.length; j < jlen; j++){
|
for(var j = 0, jlen = journals.length; j < jlen; j++){
|
||||||
if(bankstatements[i].journal_id[0] === journals[j].id){
|
if(bankstatements[i].journal_id[0] === journals[j].id){
|
||||||
|
|
|
@ -532,10 +532,8 @@ class product_template(osv.osv):
|
||||||
help="Small-sized image of the product. It is automatically "\
|
help="Small-sized image of the product. It is automatically "\
|
||||||
"resized as a 64x64px image, with aspect ratio preserved. "\
|
"resized as a 64x64px image, with aspect ratio preserved. "\
|
||||||
"Use this field anywhere a small image is required."),
|
"Use this field anywhere a small image is required."),
|
||||||
|
'packaging_ids' : fields.one2many('product.packaging', 'product_tmpl_id', 'Logistical Units',
|
||||||
'packaging' : fields.one2many('product.packaging', 'product_id', 'Logistical Units',
|
|
||||||
help="Gives the different ways to package the same product. This has no impact on the picking order and is mainly used if you use the EDI module."),
|
help="Gives the different ways to package the same product. This has no impact on the picking order and is mainly used if you use the EDI module."),
|
||||||
|
|
||||||
'seller_ids': fields.one2many('product.supplierinfo', 'product_tmpl_id', 'Supplier'),
|
'seller_ids': fields.one2many('product.supplierinfo', 'product_tmpl_id', 'Supplier'),
|
||||||
'seller_delay': fields.related('seller_ids','delay', type='integer', string='Supplier Lead Time',
|
'seller_delay': fields.related('seller_ids','delay', type='integer', string='Supplier Lead Time',
|
||||||
help="This is the average delay in days between the purchase order confirmation and the reception of goods for this product and for the default supplier. It is used by the scheduler to order requests based on reordering delays."),
|
help="This is the average delay in days between the purchase order confirmation and the reception of goods for this product and for the default supplier. It is used by the scheduler to order requests based on reordering delays."),
|
||||||
|
@ -879,7 +877,6 @@ class product_product(osv.osv):
|
||||||
'active': fields.boolean('Active', help="If unchecked, it will allow you to hide the product without removing it."),
|
'active': fields.boolean('Active', help="If unchecked, it will allow you to hide the product without removing it."),
|
||||||
'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True, ondelete="cascade", select=True),
|
'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True, ondelete="cascade", select=True),
|
||||||
'ean13': fields.char('EAN13 Barcode', size=13, help="International Article Number used for product identification."),
|
'ean13': fields.char('EAN13 Barcode', size=13, help="International Article Number used for product identification."),
|
||||||
'packaging': fields.one2many('product.packaging', 'product_id', 'Packaging', help="Gives the different ways to package the same product. This has no impact on the picking order and is mainly used if you use the EDI module."),
|
|
||||||
'name_template': fields.related('product_tmpl_id', 'name', string="Template Name", type='char', store={
|
'name_template': fields.related('product_tmpl_id', 'name', string="Template Name", type='char', store={
|
||||||
'product.template': (_get_name_template_ids, ['name'], 10),
|
'product.template': (_get_name_template_ids, ['name'], 10),
|
||||||
'product.product': (lambda self, cr, uid, ids, c=None: ids, [], 10),
|
'product.product': (lambda self, cr, uid, ids, c=None: ids, [], 10),
|
||||||
|
@ -1075,7 +1072,7 @@ class product_packaging(osv.osv):
|
||||||
'ul_container': fields.many2one('product.ul', 'Pallet Logistic Unit'),
|
'ul_container': fields.many2one('product.ul', 'Pallet Logistic Unit'),
|
||||||
'rows' : fields.integer('Number of Layers', required=True,
|
'rows' : fields.integer('Number of Layers', required=True,
|
||||||
help='The number of layers on a pallet or box'),
|
help='The number of layers on a pallet or box'),
|
||||||
'product_id' : fields.many2one('product.product', 'Product', select=1, ondelete='cascade', required=True),
|
'product_tmpl_id' : fields.many2one('product.template', 'Product', select=1, ondelete='cascade', required=True),
|
||||||
'ean' : fields.char('EAN', size=14, help="The EAN code of the package unit."),
|
'ean' : fields.char('EAN', size=14, help="The EAN code of the package unit."),
|
||||||
'code' : fields.char('Code', help="The code of the transport unit."),
|
'code' : fields.char('Code', help="The code of the transport unit."),
|
||||||
'weight': fields.float('Total Package Weight',
|
'weight': fields.float('Total Package Weight',
|
||||||
|
|
|
@ -657,7 +657,7 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Packaging" version="7.0">
|
<form string="Packaging" version="7.0">
|
||||||
<group col="4">
|
<group col="4">
|
||||||
<field name="product_id"/>
|
<field name="product_tmpl_id"/>
|
||||||
<newline/>
|
<newline/>
|
||||||
<field name="ean"/>
|
<field name="ean"/>
|
||||||
<field name="sequence" invisible="1"/>
|
<field name="sequence" invisible="1"/>
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
<field name="ul" ref="product.product_ul_box" />
|
<field name="ul" ref="product.product_ul_box" />
|
||||||
<field name="ul_qty">6</field>
|
<field name="ul_qty">6</field>
|
||||||
<field name="rows">4</field>
|
<field name="rows">4</field>
|
||||||
<field name="product_id" ref="product_product_jambon" />
|
<field name="product_tmpl_id" ref="product_product_jambon_product_template" />
|
||||||
<field name="ean"></field>
|
<field name="ean"></field>
|
||||||
<field name="weight">10</field>
|
<field name="weight">10</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<field name="ul" ref="product.product_ul_box" />
|
<field name="ul" ref="product.product_ul_box" />
|
||||||
<field name="ul_qty">6</field>
|
<field name="ul_qty">6</field>
|
||||||
<field name="rows">4</field>
|
<field name="rows">4</field>
|
||||||
<field name="product_id" ref="product_product_from" />
|
<field name="product_tmpl_id" ref="product_product_from_product_template" />
|
||||||
<field name="ean"></field>
|
<field name="ean"></field>
|
||||||
<field name="weight">10</field>
|
<field name="weight">10</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
<field name="ul" ref="product.product_ul_box" />
|
<field name="ul" ref="product.product_ul_box" />
|
||||||
<field name="ul_qty">6</field>
|
<field name="ul_qty">6</field>
|
||||||
<field name="rows">4</field>
|
<field name="rows">4</field>
|
||||||
<field name="product_id" ref="product_product_pain" />
|
<field name="product_tmpl_id" ref="product_product_pain_product_template" />
|
||||||
<field name="ean"></field>
|
<field name="ean"></field>
|
||||||
<field name="weight">10</field>
|
<field name="weight">10</field>
|
||||||
</record>
|
</record>
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
<field name="ul" ref="product.product_ul_box" />
|
<field name="ul" ref="product.product_ul_box" />
|
||||||
<field name="ul_qty">6</field>
|
<field name="ul_qty">6</field>
|
||||||
<field name="rows">4</field>
|
<field name="rows">4</field>
|
||||||
<field name="product_id" ref="product_product_lait" />
|
<field name="product_tmpl_id" ref="product_product_lait_product_template" />
|
||||||
<field name="ean"></field>
|
<field name="ean"></field>
|
||||||
<field name="weight">10</field>
|
<field name="weight">10</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
@ -277,7 +277,7 @@ class sale_order_line(osv.osv):
|
||||||
warning_msgs = res.get('warning') and res['warning'].get('message', '') or ''
|
warning_msgs = res.get('warning') and res['warning'].get('message', '') or ''
|
||||||
|
|
||||||
products = product_obj.browse(cr, uid, product, context=context)
|
products = product_obj.browse(cr, uid, product, context=context)
|
||||||
if not products.packaging:
|
if not products.packaging_ids:
|
||||||
packaging = result['product_packaging'] = False
|
packaging = result['product_packaging'] = False
|
||||||
|
|
||||||
if packaging:
|
if packaging:
|
||||||
|
|
Loading…
Reference in New Issue