如何在打印后将报价从“草稿”转换为“已发送”?

2024-06-11 06:35:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个自定义的报价报告,并希望,在打印(生成PDF),从“草稿”到“发送”状态的报价。我怎样才能做到这一点?在

报告是由RML的前任撰写的。我尝试添加一个write方法来更改状态,但没有成功:

import time
from openerp.report import report_sxw

class customquote(report_sxw.rml_parse):
        def __init__(self, cr, uid, name, context):
            super(customquote, self).__init__(cr, uid, name, context=context)
            self.localcontext.update({
                'time': time,
            })
            sale_order = self.pool.get('sale.order')
            order_id = sale_order.search(cr,uid,[('name','=',name)])
            order = sale_order.browse(cr,uid,order_id)
            for record in order:
                print record
                record.write({'state': 'sent'})
                #Neither of the following worked at either...
                #record.state = 'sent'
                #record.signal_workflow('quotation_sent')

report_sxw.report_sxw(
    'report.sale.order.customquote',
    'sale.order',
    'My_Quotation/report/customquote.rml',
    parser=customquote,
    header=False,
    )

Tags: nameselfreportuidtime报告contextorder
1条回答
网友
1楼 · 发布于 2024-06-11 06:35:52

通过使用表单页面上的其他按钮找到了解决方法。注意'销售订单我的报价单'是以前创建的自定义报表。在

  1. 我的_销售.py在

    从打开程序.osv导入osv,字段

    分类销售订单(osv.osv公司)公司名称:

    _inherit = 'sale.order'
    
    def print_quotation_custom(self, cr, uid, ids, context=None):
        #Copied from /sale/sale.py
        assert len(ids) == 1,
        self.signal_workflow(cr, uid, ids, 'quotation_sent')
        return self.pool['report'].get_action(cr, uid, ids, 'sale.order.my_quotation', context=context)
    
  2. 我的销售_视图.xml在

    在 在

    ^{pr2}$

  3. 初始化.py

    导入ioi报价单添加了此项

  4. 打开程序.py

    在{ 'name':'我的销售', “版本”:“1.0”, '类别':'销售', '说明':'我的定制销售模块', 作者:'jeszy', 'depends':['base','sale'], '数据':['我的销售_视图.xml'], “演示”:[], “可安装”:为真, “自动安装”:False, }

相关问题 更多 >