odoo

Run Odoo on port 80 instead of 8069


1.) Connect with ssh client to your Ubuntu server
2.) Use your favorite text editor (vim, nano…) to edit /etc/rc.local file

sudo nano /etc/rc.local

3.) Paste this into /etc/rc.local file

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8069

4.) Reboot your Ubuntu server to see effect

sudo reboot

5.) Access Odoo on port 80

Advertisements

Redirect to tree view from button click odoo


.py file

from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
from odoo import tools


class Project(models.Model):
    _inherit = "project.project"

    @api.multi
    def action_view_project_cashflow_report(self):
        project_ids = self.id
        return{
            'name'          :   ('Project Cashflow Report'),
            'type'          :   'ir.actions.act_window',
            'view_type'     :   'form',
            'view_mode'     :   'pivot',
            'target'        :   'new', 
            'res_model'     :   'project.cashflow.report',
            'view_id'       :   False,
            'domain'        :   [('project_id','in',[project_ids])]
            }
      }

.xml file

<xpath expr="//button[@name='attachment_tree_view']" position="after">
<button class="oe_stat_button" name="action_view_project_cashflow_report"
        string="Cash Flow" type="object"
        icon="fa-bars"/>
</xpath>

get one2many parent id odoo



<notebook colspan="4">
<page string="Cash Inflow Planning">
<fieldname="cash_inflow_ids"context="{'project_id': parent.id}">
<tree editable="bottom">
<field name="period_date"/>
<field name="deliverables_ids" widget="many2many_checkboxes" domain="[('project_id','=',context.get('project_id'))]">
<field name="name"/>
</field>
</tree>
</field>
</page>
</notebook>

extend t-name in odoo templates


I created the new template file in static/src/xml directory and updated the code like:


<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-extend="FieldMany2ManyCheckBoxes">
<t t-jquery="div"t-operation="replace">
<divt-foreach="widget.get('records')"t-as="record"style="background-color: #efeff8 !important">
<divclass="o_checkbox">
<inputt-if="widget.get('value').indexOf(record[0]) !== -1"type="checkbox"t-att-data-record-id="JSON.stringify(record[0])"checked="checked"/>
<inputt-if="widget.get('value').indexOf(record[0]) === -1"type="checkbox"t-att-data-record-id="JSON.stringify(record[0])"/>
<span/>
</div>
<labelclass="o_form_label"><tt-esc="record[1]"/></label>
</div>
</t>
</t>
</templates>

and included the file in __manifest__.py file

'qweb': [
            'static/src/xml/base.xml',
            ],

create dictionary using python- odoo


Example -1
a = [1,2,3,4,5]
result = {}
for item in a:
    result.setdefault(item,{}).update({'name':'name','age':'30'})
print(result)

Example -2
a = [
["1", "ananthu","30"],
["2", "arun","30"],
["3", "shyju","30"],
["4", "sreekanth","30"],
["5", "nishar","30"],
]

items = {}
for id, name,age in a:
    id_dict = items.setdefault(id, {})
    id_dict.update({'name':name,'age':age})
print(items)
output
{'1': {'name': 'ananthu', 'age': '30'}, '5': {'name': 'nishar', 'age': '30'}, '2': {'name': 'arun', 'age': '30'}, '4': {'name': 'sreekanth', 'age': '30'}, '3': {'name': 'shyju', 'age': '30'}}