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

In website quote module, we have copy method. Below given code

    @api.multi
    def copy(self, default=None):
        if self.template_id and self.template_id.number_of_days > 0:
            default = dict(default or {})
            default['validity_date'] = fields.Date.to_string(datetime.now() + timedelta(self.template_id.number_of_days))
        return super(SaleOrder, self).copy(default=default)

I don't want to call this method while duplicating quotation. This can be achieved without commenting code at core module? (Website_quote)


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Hem,

To override code from another module you can use the following method:


from odoo import api, fields, models
from odoo.addons.website_quote.models.sale_order import SaleOrder

def copy(self, default=None):
    return super(SaleOrder, self).copy(default)

SaleOrder.copy = copy
This grabs the SaleOrder class from the website_quote module, creates a copy function that just calls the website_quote SaleOrder's super, and then assigns the new function to that class, overriding the old definition.

Regards,

Jake Robinson

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

Thank you so much!

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

my question is this. new version of odoo still using accessing mechanism ?

Ảnh đại diện
Huỷ bỏ