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.
1. simply create the interface (xml)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<odoo> | |
<data> | |
<!-- webpage record --> | |
<template id="new_web_page" name="Your page name" page="True"> | |
<t t-call="website.layout"> | |
<div id="wrap" class="oe_structure oe_empty"> | |
<!-- Your content here --> | |
</div> | |
</t> | |
</template> | |
</data> | |
</odoo> | |
</xml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import odoo.http as http | |
class your_class(http.Controller): | |
@http.route('/custom/url', type='http', auth='user', website=True) | |
def show_custom_webpage(self, **kw): | |
# render qweb template and parse another parameter data type dictionary, so we have 2 parameter in render method. | |
return http.request.render('your_module.new_web_page', {}) |
Hi, there,
ReplyDeleteI 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()
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