Skip to main content

Odoo: Create Web Page/Controller

This simple tutorial will give you an idea how data flow/concept of odoo route to render xml template(interface)

1. simply create the interface (xml)
2. define new route via controller (python)
Here we go. now everytime "/custom/url" triggered, it will cexecute the python code in the controller and render desired xml template.

Comments

  1. Hi, there,
    I have a question about odoo 8, I am trying to add a second product in the same line of order and my question is how do I make the movement of stock, I have inherited the button confirm sale and try to make the movement of stock but something I do not do well can you help me?

    I leave you with a descriptive image of what I'm trying to achieve https://i.stack.imgur.com/uHiby.png

    and code

    def action_button_confirm(self, context=None):
    zero_price = [x.product_id.name for x in self.order_line]
    zero_env1 = [x.tipo_env_1.name for x in self.order_line]
    context = dict(context or {})
    procurement_obj = self.pool.get('procurement.order')
    sale_line_obj = self.pool.get('sale.order.line')
    res = {}
    Move = self.env['stock.move']
    warehouse = self.env['stock.warehouse']

    item = self.quant_move_item_model.new({'quant': self.quant1.id})
    item.onchange_quant()
    self.assertEquals(item.source_loc, self.quant1.location_id)


    for transfer in self.order_line:
    moves = self.env['stock.move']
    stock_location = self.env['stock.quant'].search([('product_id', '=', transfer.tipo_env_1.id)])
    move = Move.create({
    'name': transfer.tipo_env_1.name,
    'product_id': transfer.tipo_env_1.id,
    'restrict_lot_id': False,
    'product_uom_qty':transfer.cantidad_1,
    'product_uom': 1, #TODO: Change the test value 1 to produc_uom
    'partner_id': 1, #TODO: Change the test value 1 to partner_id
    'location_id': stock_location.id,
    'location_dest_id': 1,
    })
    return super(sale_order,self).action_button_confirm()

    ReplyDelete
  2. you adding the same product in the same line is not really a ggod practice,, i suggest you add the product in the new orderline

    ReplyDelete

Post a Comment

Popular posts from this blog

Odoo: Get File Name of Uploaded Binary File

When uploading a file binary on odoo sometimeS we need to store the original file name for informative purpose. So thats why this tutorial will come in handy. well that was ridiculously fast !!! Things that need to take into account is make sure you add those xml on your formview because most of uploading file operation happen in formview. And then ypu can use the field file name in treeview.

Install odoo 12 : Linux/Ubuntu/Debian

clone/download odoo 12 community from odoo github: https://github.com/odoo/odoo (optional) clone odoo 12 enterprise addons from github: https://github.com/odoo/enterprise move odoo 12 and enterprise addons to "System Disk" so we have this directory: Directory path would be /odoo12 Download this install script and execute/modify to adjust folder position (if you plan to store odoo in different directory than mine) https://github.com/akhmadkresna/odoo12-_install_script.git # Adjust the script to match your environment sudo nano odoo-install.sh # Adjust permission sudo chmod +x odoo-install.sh # Execute the script to install Odoo: ./odoo-install install python requirement  pip3 install libsass THATS IT !!!

Odoo: Create Sequence or Running Number

Odoo sequence ussually needed for automatically generated and suppose to be unique value to identified certain object or in this context is document. For example company need unique document number for every Sales document they have. When we need to create NEW sequence in odoo ? When we have new object and this object suppose to have unique and auto generated number. in this example we have new object called 'sale.doc' will be used to store any document related to SO such as contract, delivery doc etc. 1. create xml code to declare the sequence 2. call the sequence and set it on certain char field ('name) that belongs to the same object