odoo 销售订单出库单操作代码简单剖析

odoo开发技术交流群【73934270

继上一章节的销售订单,我们打开对应的出库单:


点击检查可用,执行了 stock.picking 类的 action_assign 方法,具体代码:

def action_assign(self, cr, uid, ids, context=None):
    """ Checks the product type and accordingly writes the state.
    """
    import pdb;pdb.set_trace()
    context = context or {}
    quant_obj = self.pool.get("stock.quant")
    to_assign_moves = []
    main_domain = {}
    todo_moves = []
    operations = set()
    for move in self.browse(cr, uid, ids, context=context):
        if move.state not in ('confirmed', 'waiting', 'assigned'):
            continue
        if move.location_id.usage in ('supplier', 'inventory', 'production'):
            to_assign_moves.append(move.id)
            #in case the move is returned, we want to try to find quants before forcing the assignment
            if not move.origin_returned_move_id:
                continue
        if move.product_id.type == 'consu':
            to_assign_moves.append(move.id)
            continue
        else:
            todo_moves.append(move)

            #we always keep the quants already assigned and try to find the remaining quantity on quants not assigned only
            main_domain[move.id] = [('reservation_id', '=', False), ('qty', '>', 0)]

            #if the move is preceeded, restrict the choice of quants in the ones moved previously in original move
Odoo 13中,要使用`sale.report`视图生成QWEB销售订单名称列表,你需要定义一个报告的XML模板,并在其中使用QWEB的语法来构建你想要显示的数据。以下是一个简单的例子,说明了如何创建一个报告模板来展示销售订单的名称列表。 首先,在你的Odoo模块中创建一个XML视图文件(通常放在`views`目录下),然后定义一个新的`report`视图: ```xml <odoo> <template id="report_saleorder" name="Report Sale Order"> <t t-call="report.html_container"> <t t-foreach="docs" t-as="order"> <t t-set="order_name" t-value="order.name"/> <div class="page"> <h2>Sale Order: <span t-esc="order_name"/></h2> <!-- 更多的销售订单信息可以在这里展示 --> </div> </t> </t> </template> </odoo> ``` 在上面的代码中,`report_saleorder`是模板的唯一标识符。在这个模板中,我们使用了`t t-call`来调用Odoo的HTML容器模板,并使用`t t-foreach`来遍历传入的销售订单记录。`t t-as`定义了一个迭代变量`order`,用于访问当前迭代的销售订单记录。`t t-set`用于设置一个局部变量`order_name`,这样可以在模板的其他地方引用。 为了在报告中显示这个模板,你需要在模型中定义一个方法来渲染报告。这个方法将会被触发,当用户请求打印或预览报告时。例如,在`sale.order`模型中添加如下方法: ```python from odoo import models, fields, api class SaleOrder(models.Model): # ... 其他代码 ... @api.multi def action_print_report(self): self.ensure_one() return self.env.ref('your_module.report_saleorder').report_action(self) ``` 在这个例子中,`your_module`需要替换为你自己的模块名称,`report_saleorder`是之前定义的模板ID。`action_print_report`方法会通过`report_action`方法来触发报告的渲染和显示。 请记住,在实际使用之前,需要确保你的模块已经正确安装并且在Odoo的web界面中进行了相关配置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值