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

I have two modules that contain an inheritance of the same model, each one overwrites the create function of the same model, I would like to know if it is possible to know which one will have the priority of the other one. Because the modifications are dependent on the first create. Here is an example

Module 1 > sale_order.py

---------------------------

# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
from odoo.tools.misc import format_date, formatLang
from datetime import date, datetime
import logging

_logger = logging.getLogger(__name__)


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

# Fields

# Methods
@api.model_create_multi
def create(self, vals_list):
res = super(SaleOrder, self).create(vals_list)
# Action to be taken by the module

Module 2 > sale_order.py

---------------------------

# -*- coding: utf-8 -*-
from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
from odoo.tools.misc import format_date, formatLang
from datetime import date, datetime
import logging

_logger = logging.getLogger(__name__)


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

# Fields

# Methods
@api.model_create_multi
def create(self, vals_list):
res = super(SaleOrder, self).create(vals_list)
# Actions that will be done by the module but depend on the actions done in the first module in the create

Thank you in advance for your help




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

Please check the below thread:
https://stackoverflow.com/questions/37594983/odoo-overriden-function-call-order

You can set the module hierarchy using depends in your manifest file so in your second module you can set depends as below:

'depends': ['first_module' , 'sale']

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

what if module 1 and module 2 functionalities are not dependant on each other? in this case its not write to add first_module in the dependencies of second module.

Tác giả Câu trả lời hay nhất

Perfect, thank you for your answer :)

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 4 15
5184
1
thg 10 23
3476
1
thg 5 24
4483
4
thg 10 15
9990
1
thg 3 15
7296