Tuesday, September 3, 2019

checkbox background color in odoo

ODOO

we can go to the css file and write the code below

div.o_checkbox > input:checked + span {
    background-color: #000000;
}

change date background color in odoo


 
we have to go to the css file and write the code bellow to change the defualt color with #33cc33 color

.datepicker .table-condensed > thead {
    color: white;
    /*background-color: #106bac;*/
    /*background-color:#bfb9b9;*/
    /*background-color:#d11f22;*/
    background-color:#33cc33;
}

.datepicker .table-condensed > tbody > tr , .datepicker .table-condensed > tbody > tr > td {
    /*color: white;
    background-color: #1fa135;*/
    background-color:white;
    border-color: white;
    /*border-style: solid;*/
}


.datepicker .table-condensed > thead > tr:first-child th:hover {
    color: white;
    /*background-color: #71b5e5;*/
    /*background-color: #ccc;*/
    /*background-color: #d11f22;*/
    background-color: #33cc33;
}

.datepicker {
    .table-condensed {
        > tbody {
            > tr {
                > td {
                    &.active, .active {
                        background-color: #33cc33;
                        border-radius: 40%;
                    }
                }
            }
        }
    }
}

navbar background color in odoo

ODOO


 

 

to do that we must go to our theme , and open css file and write the code bellow 

.navbar-default {
  background-color: #1fa135;
 
  }

Thursday, August 29, 2019

name_search with One2many field in odoo

ODOO

name_search()

how to use name_search() function with One2many field in odoo 11 

to explain the main reason to use this function let us say that we have one2many field in some object and inside this filed there is many2one filed which we have to avoid rebating it 

E.G let us say we have three objects (aobject , bobject, cobject) as below 

class aobject(models.Model):
     _name = "a.object"
     bobject_ids = fields.One2many('b.object', string="B Object", 'aobject_id')

class bobject(models.Model):
     _name = "b.object"
     aobject_id = fields.Many2one('a.object', string="A Object")
     cobject_id = fields.Many2one('c.object', string="C Object")

class cobject(models.Model):
     _name = "c.object"

and we want to avoid re-show the chosen records of cobject_id field when we create records in bobject_ids field in the first object , so we have to ...
 
inside cobject class we have to add name_search() function , just like

class cobject(models.Model):
     _name = "c.object" 
 
     @api.model
     def name_search(self, name, args=None, operator='ilike', limit=100):
     args = args or []
     domain = []
     post = []
     if 'bـobjectـids' in self._context:
     lineـids = self.env['b.object'].resolve_2many_commands('cobject_id' ,self._context.get('bـobjectـids'))
     for line in lineـids:
     if 'aobjectـid' in line:
     if line['aobjectـid']:
     post.append(line['aobjectـid'])
     args.append(('id', 'not in',post))
     return self.search(domain + args).name_get() 

then we go to aobject view file (xml) & add 

<field name="bobjectـids" nolabel="1" >
       <tree editable="bottom">
              <field name="cobjectـid" context="{'bـobjectـids':parent.bobjectـids}"/>
       </tree>
</field>

Wednesday, August 21, 2019

default field value from xml in odoo

ODOO



to explain it , Let us say we have selection field type which is has two selection values "in , out " as bellow 

type = fields.Selection([('in','In'),('out','Out'), string="Type"])

 and we want to make it's default value "in" from xml , so when we create our view we can pass the default value "in" with context as bellow 

<record id="view_id_form" model="ir.ui.view">
            <field name="name">model.model.form</field>
            <field name="model">
model.model</field>
            <field name="context">{'default_type':'in'}</field>
            <field name="arch" type="xml"> 
            <form>

create active filter in odoo

ODOO

we can create active filter that we think we will use it usually to filter data 

E.G :

 let us say we have active field in our object and we want to make active filter by it , so we must go to search view in xml file , and do it as bellow 

<search >
       <filter string="Archive" domain="[('active','=',False)]"/>
</search>

Tuesday, August 20, 2019

domain to field in odoo

ODOO

we can add domain for field in both python file and xml file as bellow 
E.G : let us say we have department_id file which it's domain must be the company 

in python file :

department_id = fields.Many2one('hr.department', domain="[('company_id', '=', company_id)]", string="Department")

// the department object must has field call company_id and the current object too 

in xml file : 

<field name="department_id" domain="[('company_id','=',company_id)]"/>

Odoo Invoice Qr code issues

There are two main issues must of us facing with the QR code in Odoo invoice & these issues are 1/ QR code displayed as broken image w...