Odoo – Change specific column color in one2many tree view

I am using odoo 10. I have a customer view and in that customer form view i am also showing all order that are associated with that specific customer in one2many tree view (editable).

What i want to do is i want to show a button in one2many tree view but i want to change that button’s color only based on condition.

Here is what i tried but its not working.

<record id="amgl.customer_form" model="ir.ui.view">
        <field name="name">Customer</field>
        <field name="model">amgl.customer</field>
        <field name="arch" type="xml">
            <form string="Create New Customer" duplicate="0">
                    <group colspan="4">
                            <field name="is_admin" invisible="1"/>
                            <field name="is_custodian" invisible="1"/>
                            <field name="is_vault" invisible="1"/>
                            <field name="is_o2m" invisible="1"/>
                            <field name="is_goldstar" invisible="1"/>
                            <field name="custodian_edit" invisible="1"/>
                            <field name="first_name"
                                   attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
                            <field name="last_name"
                                   attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
                            <field name="account_number"
                                   attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
                            <field name="gst_account_number" string="GoldStar Account Number"
                                   attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)], 'invisible':[('is_goldstar','=',False)]}"/>
                            <field name="date_opened"
                                   attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
                            <field name="account_type"
                                   attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>
                            <field name="custodian_id" options='{"no_open": True}'
                                   attrs="{'readonly':[('is_admin','=', False)]}"/>
                            <field name="customer_notes"
                                   attrs="{'readonly':['|',('is_vault','=', True),('custodian_edit','=', True),('is_admin','=', False)]}"/>

                        <!--CURRENT INVENTORY-->
                        <page string="CURRENT INVENTORY">

                            <field name="customer_order_lines2"
                                   attrs="{'readonly':['|',('is_custodian','=', True),('is_o2m','=', False)]}"
                                   context="{'default_is_deposit_related': True,'group_by':'products'}"
                                   domain="[('state','=','completed')]" default_order='state desc'
                                <h4 style="float:right;">
                                    <field name="total_received_quantity"/>
                                <tree open="false" editable="bottom"
                                    <field name="is_deposit_related" invisible="1"/>

                                    <field name="is_vault_edit" invisible="1"/>
                                    <field name="is_admin" invisible="1"/>
                                    <field style="color:red !important;" name="products" attrs="{'readonly':[('is_vault_edit','=', True)]}"/>
                                    <field name="commodity"/>
                                    <field name="total_received_quantity"
                                           attrs="{'readonly':[('is_vault_edit','=', True)]}" class="oe_edit_only"
                                           col_border="1" string="Received"/>
                                    <field name="temp_received_weight" class="oe_edit_only" col_border="1"/>
                                    <field name="date_received" attrs="{'readonly':[('is_vault_edit','=', True)]}"
                                           class="oe_edit_only" col_border="1"/>
                                    <field name="state" invisible="1"/>
                                    <field name="notes_boolean" invisible="1"/>
                                    <button attrs="{'invisible':[('notes_boolean','=', False)]}" type="object" name="add_notes" class="btn btn-primary btn-sm o_list_button_add">
                                        <i class="fa-lg fa-pencil-square"></i>
                                    <button attrs="{'invisible':[('notes_boolean','=', True)]}" type="object" name="add_notes" class="btn btn-default">
                                        <i class="fa-lg fa-pencil-square"></i>
                                    <!--<button colors="red: notes_boolean is True" name="add_notes" type="object"-->
                                            <!--string="Add Notes" icon="fa-lg fa-pencil-square" class="btn btn-primary btn-sm o_list_button_addhlight"/>-->

Odoo one2many field creation and assign to self.variable

for fee_line in fee_criteria.fee_line_ids:
        fee_data = {
                       'name' : fee_line.name,
                       'amount' : int(fee_line.amount),
                       'type' : fee_line.type,
                       'fee_pay_type' : fee_line.fee_pay_type.id,
                       'sequence': fee_line.sequence,
        self.student_fee_line = fee_lst

This is out for below code :


fees.line(<openerp.models.NewId object at 0x7f86e0130110>, <openerp.models.NewId object at 0x7f86e0130390>, <openerp.models.NewId object at 0x7f86e00d6850>, <openerp.models.NewId object at 0x7f86e00d6610>, <openerp.models.NewId object at 0x7f86e00d63d0>, <openerp.models.NewId object at 0x7f86e00d6190>, <openerp.models.NewId object at 0x7f86e00d6d90>, <openerp.models.NewId object at 0x7f86e00dc050>)

I am not getting Ids so what i do.

How to translate an odoo email template but no invoice document attached

I have translated Odoo email templates from English to Spanish, Italian and French but I need to send the attached invoice in Spanish always, no matter the language.

How can I do that?

I have tried:

  • specifying <field name="lang">es_ES</field> but it translates the email template too.
  • forcing <t t-raw="translate_doc(doc_id, doc_model, 'es_ES', 'wms_report.report_document')"/> but it throws an error because param has to be an attribute of object.

How to resolve TypeError: can’t subtract offset-naive and offset-aware datetimes in Odoo 8?

I am working on a code of exporting values to excel using xlwt and came across the following error.

for leave in leave_data:
        tes = ''
        date1 = ''
        user_pool = self.env['res.users']
        user = user_pool.browse(SUPERUSER_ID)
        tz = pytz.timezone(user.partner_id.tz) or pytz.utc
        date1 = pytz.utc.localize(datetime.strptime(leave.date_from, 
        single_leave_data = []

The error ‘ TypeError: can’t subtract offset-naive and offset-aware datetimes’ gets raised and not able to figure out the reason behind this error. I have searched for many solutions, but none seem to work.

How to use a record id of a CSV file for programming?

If I have CSV file that I included for seed data. Then I want to use a record inside that CSV file for programming. How can I do it in Odoo?

For example

My CSV seed file product.category.csv

id       name
ctgry_1  Custom Category

In my model I want to do this:

product_template = self.env["product.template"]
product_new = product_template.create({
    "name" : "Custom Template",
    "categ_id" : # I want to use ctgry_1 here, but it does not work

Should I first do a search for my category id? But that seemed like wrong to me. Shouldn’t we be able to use the identifier from CSV?

how to split procurement scheduler in odoo

In my odoo instance, I added routing generation for product during the procurement generation of MOs.
Every routing generation lasts more or less 2 or 3 minutes and it is possible that the scheduler will have to manage even 100 products.
I think I could just setup limit_time_cpu and limit_time_real to very large values, but I don’t really like this solution (side question: is it possible to disable those limits? maybe a -1 or 0 value?)

I suppose the best solution would be to completely change the procurement scheduler in order to use 1 single worker for each procurement/product.

Do I have to change all the way from schedulers_all wizard generating n threads (basically moving the procurements search into the wizard) or there is a better solution?

Any suggestion?