Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
8313 Lượt xem

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
Ảnh đại diện
Huỷ bỏ

Are you import this file in __init__.py folder

Tác giả

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

Câu trả lời hay nhất

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()


Ảnh đại diện
Huỷ bỏ
Tác giả

Thanks for the example. It works great.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 5 23
2215
1
thg 10 22
6864
2
thg 11 21
7939
3
thg 1 18
9209
2
thg 2 17
3060