【问题标题】:Confirm a sale quotation into a sale order with some quantities set to 0将销售报价确认到销售订单中,其中一些数量设置为 0
【发布时间】:2013-01-05 07:43:25
【问题描述】:

在我的自定义销售报价报告中,我想显示一些数量为 0 的产品,因此为一些数量设置为 0 的产品创建了销售订单行。它工作正常并显示在销售报价报告中。

但是当我在销售订单中确认相同的销售报价时,OpenERP 会抛出以下消息:

“数据不足! 请检查采购订单中的数量,不能为0或更少!”

如何确认部分数量设置为 0 的订单?

【问题讨论】:

    标签: openerp


    【解决方案1】:

    首先您必须继承 Procurement,然后在您的自定义模块中覆盖 action_confirm 方法。

    procurement.py 中,在第 320 行找到“def action_confirm()”。复制并粘贴整个方法并删除那些引发异常的行。

    希望这能解决您的问题。

    谢谢。

    【讨论】:

    • 你的方法很好很干净,我真的应该试一试。但是我需要一个紧急的解决方案,我修改了 purchase.py 文件以满足我的要求,然后重新编译它。它现在工作正常。但我会尝试继承方法,这是一种更好的方式来做 IMO。
    • 是的,您应该在您的模块中执行此操作,而不是修改核心模块的代码。如果您的问题得到解决,那么您应该接受我的回答,或者如果您有更好的解决方案,那么您应该分享它。谢谢。
    • 一旦我创建了我的自定义provisioning_custom.order 视图,继承自provisioning.order 视图,我是否需要通过修改触发器来确保它被sale.py(sale.order 模块)调用将第 846 行从“procurement.order”调用到“procurement_custom.order”?否则,我的自定义继承视图在确认订单时如何调用?
    • class custom_procurement_order(osv.osv): _inherit = 'procurement.order' def action_confirm(self, cr, uid, ids, context=None) #copy and past the code and remove exception part return True您无需调用 super。只需复制并粘贴除异常部分之外的整个代码。
    【解决方案2】:
    class procurement_order(osv.osv):
        _inherit = 'procurement.order'
        def action_confirm(self, cr, uid, ids, context=None):
             move_obj = self.pool.get('stock.move')
            for procurement in self.browse(cr, uid, ids, context=context):
                #if procurement.product_qty <= 0.00:
                    #raise osv.except_osv(_('Data Insufficient !'),_('Please check the quantity in procurement order(s), it should not be 0 or less!'))
                if procurement.product_id.type in ('product', 'consu'):
                    if not procurement.move_id:
                        source = procurement.location_id.id
                    if procurement.procure_method == 'make_to_order':
                        source = procurement.product_id.product_tmpl_id.property_stock_procurement.id
                    id = move_obj.create(cr, uid, {
                        'name': procurement.name,
                        'location_id': source,
                        'location_dest_id': procurement.location_id.id,
                        'product_id': procurement.product_id.id,
                        'product_qty': procurement.product_qty,
                        'product_uom': procurement.product_uom.id,
                        'date_expected': procurement.date_planned,
                        'state': 'draft',
                        'company_id': procurement.company_id.id,
                        'auto_validate': True,
                    })
                    move_obj.action_confirm(cr, uid, [id], context=context)
                    self.write(cr, uid, [procurement.id], {'move_id': id, 'close_move': 1})
        self.write(cr, uid, ids, {'state': 'confirmed', 'message': ''})
        return True
    

    【讨论】:

    • 感谢您的代码,我已经通过将 product_qty
    • 如果要更改视图则需要在.xml中继承视图,否则不需要继承视图。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 2019-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多