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: How to Inherit Controller

Sometime we need to modify a certain behavior when accessing odoo url (route). That time we need to do inheritance to odoo controller and then put our desired custom behavior when the url triggered. The way to inherit an odoo controller is slightly different than to inherit odoo object/model. In this tutorial i will do inheritance on odoo route "/shop/checkout" which is the url route when doing website sale checkout, because i want to show some specific product information on the website that i cant call in the xml template unless i parse the data from python controller to xml view. Lets jump into it. Here is the base controller Here is the inheritance controller in the example above i import base controller class (WebsiteSale) and use it as parameter on my new class (WebsiteSaleInherit). Thats it !! Comment below if you have any questions.

Odoo Javascript Debugging

When it comes to programming, we can all agree that out code is rarely work on a first try. Because of the sheer virtue of fact that, even if you can conceptualize a problem and reduce it to it’s base states, to fully envision it into it’s most granular detail in terms of hundreds of lines of code - Is just not realistic. Thats why i can say that debugging is crucial part of programming. Here few tips to do javascript debugging in odoo using google chrome developer tools. some points also applicable on debugging general website not just odoo. Odoo Developer Mode (with assets) When it comes to javascript debugging in odoo, we should enable ‘asset debugging’. Trust me it will saves your ass a lot of time. Odoo internally use assets like CSS and JavaScript. In normal mode this asset will combined to a file. So debug with assets will prevent asset to be merged to one file and display actual CSS and JavaScript files on chrome dev tools. Of course this mode will reduce per...