コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
8323 ビュー

I need to override the action_button_confirm method  from the sales.order model, but i can't make the inheritance work. It seems that this code is never called during execution. 

I'ḿ using odoo  8.0. The module is installed and depends on sale module. 


# -*- coding: utf-8 -*-
from openerp import models, fields, api 
import logging
_logger =logging.getLogger(__name__)

class sales_warning(models.Model):
    _inherit = "sale.order"
@api.multi   
def action_button_confirm(self):
    _logger.info("begin overwritten action_button_confirm()")
    res = super(sales_warning, self).action_button_confirm()            
    return res
アバター
破棄

Are you import this file in __init__.py folder

著作者

Yes. I found out the problem was the indentation. This left my procedure outside the class.

最善の回答

HI,

here is an example of action_button_override:

class sale_order(models.Model):
_inherit = 'sale.order'

@api.multi
def action_button_confirm(self):
zero_price = [x.product_id.name for x in self.order_line if not x.price_unit]
if zero_price:
message= _("Please specify unit price for the following products:") + '\n'
message += '\n'.join(map(str,zero_price))
raise Warning(message.rstrip())
return super(sale_order,self).action_button_confirm()


アバター
破棄
著作者

Thanks for the example. It works great.

関連投稿 返信 ビュー 活動
2
5月 23
2217
1
10月 22
6870
2
11月 21
7951
3
1月 18
9211
2
2月 17
3063