Friends,
Need to remove this option from pop up manyone fields. (not in all fields.some fields need to remove this feature).i used widget="selection".then my domain filter not working.so please help me to find a solution.
There is a module for openerp 6.1 to remove the create and edit option(in the openerp apps site search for web remove) from the default selection of many2one field. You can use this as an example and create you own module. or you can modify the base codes goto your server, then navigate to openerp/addons/web/static/src/js/view_form.js and remove the quick create functionality defined from the line number 2860.
This is the Same answer that I have given in openerp help site.
I have faced the same problem, but I solved it easily.
You need to change your web add-ons.
Please follow the step:
Go to: web/static/src/js
open the file: view_form.js
Go to line number 2958 or you can find label: _t ("Create and
Edit..."),
comment it
Enjoy, you can now see in your many2one fields don't have 'Create and Edit'
Note : This will affect every many2one field.
In v7 you can use the answer as suggested in http://help.openerp.com/question/16498/how-to-disable-create-and-edit-from-from-a-menu/
<form string="My form" create="false">
I had this problem in v6.1 though, so I created a new option so that I could apply it to only some fields (not all fields as suggested by #Bipin)
<form string="My form" options='{"no_create": true}'>
and changed web/static/src/js/view_form.js
// Hack: check for new "no_create" option:
if (self.get_definition_options().no_create === undefined || !self.get_definition_options().no_create) {
// the rest of the code stays asis:
// quick create
var raw_result = _(data.result).map(function(x) {return x[1];});
if (search_val.length > 0 &&
!_.include(raw_result, search_val) &&
(!self.value || search_val !== self.value[1])) {
values.push({label: _.str.sprintf(_t('<em> Create "<strong>%s</strong>"</em>'),
$('<span />').text(search_val).html()), action: function() {
self._quick_create(search_val);
}});
}
// create...
values.push({label: _t("<em> Create and Edit...</em>"), action: function() {
self._change_int_value(null);
self._search_create_popup("form", undefined, {"default_name": search_val});
}});
} // here endith the hack
I want to make this into a module, as editing the source code isn't very maintainable.
Related
I have been moving website made in Cakephp into Django. In one place I found get_declared_classes(). I thinks this function returns list of previously used classes before running current class.
First time when I encounter this, I just store list of classes manually in one file and I was using that and this solution worked only for a particular web page but Now I have multiple pages calling this class and everytime list of classnames are very different so I can not store class name list.
This code is actually connecting and fetching data from here and I want to replace this class in python(We are replacing whole website). The only problem I have is how to replace get_declared_classes.
class HrbcConnect{
private $scope = '';
private $token = null;
private $token_expire = 0;
private $request_opt = array();
public $id;
public $id_arr = array();
public $write_error;
public function read($resource,$condition='',$field=array(),$order=null){
$declared_classes = get_declared_classes();
foreach(App::objects('Model') as $v){
if(in_array($v,$declared_classes)){
$instance = new $v;
if(property_exists($instance,'hrbc_cols') && array_key_exists(ucfirst($resource),$instance->hrbc_cols)){
foreach($instance->hrbc_cols[ucfirst($resource)] as $vv){
if(is_array($vv)){
$field[] = $vv[0];
}else{
$field[] = $vv;
}
}
}elseif(property_exists($instance,'hrbc_cols_arr')){
foreach($instance->hrbc_cols_arr as $kk=>$vv){
if(array_key_exists(ucfirst($resource),$vv)){
foreach($vv[ucfirst($resource)] as $vvv){
if(is_array($vvv) && !in_array($vvv[0],$field)){
$field[] = $vvv[0];
}elseif(!is_array($vvv) && !in_array($vvv,$field)){
$field[] = $vvv;
}
}
}
}
}
}
}
}
}
When I print the $v in the above code to find what are classes being used, I found list of classes that defined in my models.
If question is not clear please let me know, I can provide more information.
Is there any other library that can replace this function in Python? Or Is there any other solution I can try ?
Actually we bulit webapp from there we are passing variables to the terraform by
like below
terraform apply -input=false -auto-approve -var ami="%ami%" -var region="%region%" -var icount="%count%" -var type="%instance_type%"
Actually the problem here was backend does not support variables i need to pass there values also form app.
TO resolve this I find some solution like we need to create backend.tf before execution.
But I am unable to get the idea how to do it if anyone having any exmaples regarding this please help me.
Thanks in advance..
I need to create backend.tf file from python by using below variables.
And need to replace key="${profile}/tfstate
for each profile the profile need to replace
i am thinking of using git repo by using git we create files and pull the values and again commit and execute
Please help me with some examples and ideas.
Code is like below:
My main.tf like below
terraform {
backend “s3” {
bucket = “terraform-007”
key = “key”
region = “ap-south-1”
profile=“venu”
}
}
provider “aws” {
profile = “ var.awsprofile"
region="{var.aws_region}”
}
resource “aws_instance” “VM” {
count = var.icount
ami = var.ami
instance_type = var.type
tags = {
Environment = “${var.env_indicator}”
}
}
vars.tf like
variable “aws_profile” {
default = “default”
description = “AWS profile name, as set in ~/.aws/credentials”
}
variable “aws_region” {
type = “string”
default = “ap-south-1”
description = “AWS region in which to create resources”
}
variable “env_indicator” {
type = “string”
default = “dev”
description = “What environment are we in?”
}
variable “icount” {
default = 1
}
variable “ami” {
default =“ami-54d2a63b”
}
variable “bucket” {
default=“terraform-002”
}
variable “type” {
default=“t2.micro”
}
output.tf like:
output “ec2_public_ip” {
value = ["${aws_instance.VM.*.public_ip}"]
}
output “ec2_private_ip” {
value = ["${aws_instance.VM.*.private_ip}"]
}
Actually the problem here was backend does not support variables i need to pass there values also form app.
TO resolve this I find some solution like we need to create backend.tf before execution.
But I am unable to get the idea how to do it if anyone having any exmaples regarding this please help me.
Thanks in advance..
Since the configuration for the backend cannot use interpolation, we have used a configuration by convention approach.
The terraform for all of our state collections (microservices and other infrastructure) use the same S3 bucket for state storage and the same DynamoDB table for locking.
When executing terraform, we use the same IAM role (a dedicated terraform only user).
We define the key for the state via convention, so that it does not need to be generated.
key = "platform/services/{name-of-service}/terraform.tfstate"
I would avoid a process that results in changes to the infrastructure code as it is being deployed to ensure maximum understand-ability by the engineers reading/maintaining the code.
EDIT: Adding key examples
For the user service:
key = "platform/services/users/terraform.tfstate"
For the search service:
key = "platform/services/search/terraform.tfstate"
For the product service:
key = "platform/services/products/terraform.tfstate"
Is it possible to create information message with options like proceed or cancel in OpenERP ? If it is possible how to create one ?
You can extend a js web module to do that.
Create script.js under /module_name/static/src/js/ which contains:
openerp.module_name = function(instance) {
var _t = instance.web._t,
_lt = instance.web._lt;
var QWeb = instance.web.qweb;
/* For example */
instance.web.FormView.include({
});
};
You can create a wizard with cancel and proceed button within
Does anybody know how to automatically update the options of a "child" select box depending on the choice of the "parent" select box in the admin page?
The problem: I have two select boxes. In the first one I choose e.g. a car brand. Once I choose the car brand I want the "child" select box options to update with the models of that brand.
I am using ForeignKey properly in my models and all the models are correct but if you can give me some guidance to solve this issue I would be grateful. Thanks!
Solved: I've used smart_selects. https://github.com/digi604/django-smart-selects
You can do this with JavaScript and Elementmanipulation:
save the car-models to JavaScript Vars: ie
<script type="text/javascript">
var porsche = {{ porsche|safe }};
var vw = {{ vw|safe }};
</script>
And in you JavaScript you can specify a new Change Method for your Parent select box:
$('#parent_select').change(function(){
changeCars();
});
The function could then manipulate the child select box:
var newCarList = [];
val =$('#parent_select').val();
if (val=='porsche'){
newCarList = porsche;
}
else if (val == 'vw'){
newCarList = vw;
}
else{
//some Error handling
}
select = document.getElementById('child_select');
while (select.firstChild) {
select.removeChild(select.firstChild);
// to remove all previously added childs (option fields)
}
for (var i = 0; i < newCarList.length; i ++){
var opt = document.createElement('option');
opt.value = newCarList[i];
opt.innerHTML = newCarList[i];
select.appendChild(opt);
//append all new Childs to the child_select
}
This possibility will work but is quite slow since Object manipulation is not the fastest way.
Another possibility would be to create different child selects and use show/hide to only display the correct one according to the value of the parent_select.
I have solved my problem. I used Django smart_selects. github.com/digi604/django-smart-selects
Hi i got the site domain in the template name with the
{{request.META.HTTP_HOST}}
from which i got the value some thing like this
pydev.aviesta.com
and
pydev.aviesta.com.mx
i need to show different data for both domains but as this is the dev server i cant use the full doamin name for compare can i check only .mx or .com so there will be no problem when going to live site
You may need Custom filter for this.
#register.filter(name='split')
def split(value, arg):
return value.split('.')[-1]
Use it as {{request.META.HTTP_HOST|split}}
i got the solution with js
<script>
var str = location.host;
if( str.search(".mx") > 0 ){
var dom = 'mx';
}else{
var dom = 'com';
} </script>