odoo

Replace JS file in Odoo


<odoo>
        <template id="assets_inherit" inherit_id="website_slides.assets_frontend">
            <xpath expr="//script[@src='/website_slides/static/src/js/slides_upload.js']" position="replace">
                <script type="text/javascript" src="/website_slides_extend/static/src/js/slides_upload_inherit.js"></script>
            </xpath>
        </template>
</odoo>
Advertisements

open binary data (pdf) using controller odoo


URL :- http://192.168.56.11:8069/web/binary/download_pdf/12

import base64
import logging
import werkzeug

from odoo import http, _
from odoo.exceptions import AccessError, UserError
from odoo.http import request


class DownloadPDF(http.Controller):

    @http.route('/web/binary/download_pdf/<id>', type='http', auth="public",website=True)
    def download_pdf(self,id,**kw):        
        response = werkzeug.wrappers.Response()
        slide_slide_obj = request.env['slide.slide'].sudo().search([('id','=',id)])
        response.data = slide_slide_obj.datas and slide_slide_obj.datas.decode('base64') or ''
        response.mimetype = 'application/pdf'
        return response

show filename of binary files odoo


Pyhton Code

class MyModel(models.Model):
    _name = 'my.model'

    image = fields.Binary('Image', required=True)
    image_filename = fields.Char("Image Filename")

XML File

<record id="view_form_my_model" model="ir.ui.view">
  <field name="name">My Model Form</field>
  <field name="model">my.model</field>
  <field name="arch" type="xml">
    <form>
      <sheet>
        <group name="group_top">
          <group name="group_left">
            <field name="image_filename" invisible="0"/>
            <field widget="binary" height="64" name="image" filename="image_filename" />
          </group>
          <group name="group_right">
          </group>
        </group>
      </sheet>
    </form>
  </field>
</record>

Create sequence using code – odoo


@api.model
def _create_sequence(self, vals, refund=False):
""" Create new no_gap entry sequence for every new Journal"""
prefix = self._get_sequence_prefix(vals['code'], refund)
seq = {
'name': refund and vals['name'] + _(': Refund') or vals['name'],
'implementation': 'no_gap',
'prefix': prefix,
'padding': 4,
'number_increment': 1,
'use_date_range': True,
}
if 'company_id' in vals:
seq['company_id'] = vals['company_id']
return self.env['ir.sequence'].create(seq)