[IMP] Replace JS with function field to manage the visibility of default_wh in module stock
bzr revid: jke@openerp.com-20131022111103-sm2nnlj8ijryfvt3
This commit is contained in:
parent
14cc990846
commit
38a583f88c
|
@ -113,8 +113,7 @@ Dashboard / Reports for Warehouse Management will include:
|
|||
'static/lib/sparkline/jquery.sparkline.js',
|
||||
'static/lib/justgage.js',
|
||||
'static/src/js/stock_picking_type.js',
|
||||
'static/src/js/widgets.js',
|
||||
'static/src/js/CheckHide.js',
|
||||
'static/src/js/widgets.js',
|
||||
],
|
||||
'qweb': ['static/src/xml/picking.xml'],
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
function openerp_wh_hide(openerp) {
|
||||
var module = openerp.stock;
|
||||
var _t = openerp.web._t;
|
||||
|
||||
openerp.web.form.FieldMany2ManyCheckBoxes.include({
|
||||
render_value: function(){
|
||||
this._super();
|
||||
var self = this;
|
||||
setTimeout(function () {
|
||||
self.ShowHide();
|
||||
}, 0);
|
||||
},
|
||||
from_dom: function(){
|
||||
this._super();
|
||||
this.ShowHide();
|
||||
},
|
||||
ShowHide: function() {
|
||||
var bShow = false;
|
||||
this.$("input").each(function() {
|
||||
bShow = bShow || ($(this).attr("checked") ? true : false)
|
||||
});
|
||||
if (bShow) {
|
||||
$(".resupply_ids").show();
|
||||
}
|
||||
else {
|
||||
$(".resupply_ids").hide();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
openerp.web.form.custom_widgets.add("m2m_hide_resupply","openerp.stock.manageResupply");
|
||||
|
||||
//var a = false; $(".m2m_whids div").find(':checkbox').each( function(){ a = a | $(this)[0].checked; } ); alert(a);
|
||||
}
|
|
@ -65,6 +65,5 @@ openerp.stock = function(openerp) {
|
|||
|
||||
openerp.stock = openerp.stock || {};
|
||||
openerp_picking_widgets(openerp);
|
||||
openerp_wh_hide(openerp);
|
||||
|
||||
};
|
||||
|
|
|
@ -2215,6 +2215,14 @@ class stock_inventory_line(osv.osv):
|
|||
class stock_warehouse(osv.osv):
|
||||
_name = "stock.warehouse"
|
||||
_description = "Warehouse"
|
||||
|
||||
|
||||
def show_field_default_wh_resupply(self,cr,uid,ids,name,args,context=None):
|
||||
res = {}
|
||||
for wh in self.browse(cr,uid,ids,context=context):
|
||||
res[wh.id] = (len(wh.resupply_wh_ids) > 0)
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=128, required=True, select=True),
|
||||
'company_id': fields.many2one('res.company', 'Company', required=True, select=True),
|
||||
|
@ -2247,8 +2255,30 @@ class stock_warehouse(osv.osv):
|
|||
'resupply_wh_ids': fields.many2many('stock.warehouse', 'stock_wh_resupply_table', 'supplied_wh_id', 'supplier_wh_id', 'Resupply Warehouses'),
|
||||
'resupply_route_ids': fields.one2many('stock.location.route', 'supplied_wh_id', 'Resupply Routes'),
|
||||
'default_resupply_wh_id': fields.many2one('stock.warehouse', 'Default Resupply Warehouse'),
|
||||
'show_default_resupply_wh_id': fields.function(show_field_default_wh_resupply,type='boolean',string="Show field default_resupply_wh_id"),
|
||||
|
||||
}
|
||||
|
||||
|
||||
def onchange_filtre_default_resupply_wh_id(self, cr, uid, ids, resupply_wh_ids,default_resupply_wh_id, context=None):
|
||||
resupply_wh_ids = [x['id'] for x in (self.resolve_2many_commands(cr, uid, 'resupply_wh_ids',resupply_wh_ids, ['id']))]
|
||||
print(default_resupply_wh_id,resupply_wh_ids)
|
||||
|
||||
retval = {'show_default_resupply_wh_id' : len(resupply_wh_ids)>0 }
|
||||
warning = {}
|
||||
|
||||
if (default_resupply_wh_id and default_resupply_wh_id not in resupply_wh_ids):
|
||||
retval['default_resupply_wh_id'] = False
|
||||
warning = {
|
||||
'title': 'Information',
|
||||
'message': 'Default resupply warehouse has been changed because ol default value is not in this list !'
|
||||
}
|
||||
return {
|
||||
'value': retval,
|
||||
'domain':{ 'default_resupply_wh_id':[('id','in',resupply_wh_ids)] },
|
||||
'warning': warning
|
||||
}
|
||||
|
||||
def _get_inter_wh_location(self, cr, uid, warehouse, context=None):
|
||||
''' returns a tuple made of the browse record of customer location and the browse record of supplier location'''
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
|
|
|
@ -667,8 +667,9 @@
|
|||
<group colspan="4">
|
||||
<field name="reception_steps" widget='radio'/>
|
||||
<field name="delivery_steps" widget='radio'/>
|
||||
<field name="resupply_wh_ids" domain="[('id', '!=', id)]" widget='many2many_checkboxes' class="m2m_whids"/> <!--many2many_checkboxes-->
|
||||
<field name="default_resupply_wh_id" attrs="{'invisible': [('resupply_wh_ids','=',False)] }" class="resupply_ids"/> <!-- TODO should be filtered on resupply_wh_ids only... -->
|
||||
<field name="resupply_wh_ids" domain="[('id', '!=', id)]" widget='many2many_checkboxes' on_change="onchange_filtre_default_resupply_wh_id(resupply_wh_ids, default_resupply_wh_id)"/>
|
||||
<field name="default_resupply_wh_id" attrs="{'invisible': [('show_default_resupply_wh_id','=',False)]}" widget='selection' />
|
||||
<field name="show_default_resupply_wh_id" invisible="1"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Technical Information" groups='base.group_no_one'>
|
||||
|
|
Loading…
Reference in New Issue