콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

In an Odoo 15 project, a field has been created using Odoo Studio specifically in the product_template model. However, I want to interact with this field through code. When I try to install the module that inherits from product_template, it says that the field does not exist. I will provide an example of my code. I am not looking for the exact solution, but I want to understand how to interact with Odoo Studio fields through code: 

class ProductTemplate(models.Model):

    _inherit = 'product.template'


    valorizado_box_cero = fields.Float(string='Valorizado Box Cero', compute='_compute_valorizados', store=True)

    valorizado_box_uno = fields.Float(string='Valorizado Box Uno', compute='_compute_valorizados', store=True)

    valorizado_box_dos = fields.Float(string='Valorizado Box Dos', compute='_compute_valorizados', store=True)


    @api.depends('x_studio_box_cero', 'x_studio_box_uno', 'x_studio_box_dos')

    def _compute_valorizados(self):

        for record in self:

            x_studio_box_cero = record.x_studio_box_cero if record.x_studio_box_cero else 0

            x_studio_box_uno = record.x_studio_box_uno if record.x_studio_box_uno else 0

            x_studio_box_dos = record.x_studio_box_dos if record.x_studio_box_dos else 0


            record.valorizado_box_cero = x_studio_box_cero

            record.valorizado_box_uno = x_studio_box_uno

            record.valorizado_box_dos = x_studio_box_dos


아바타
취소
베스트 답변

Hi,
You can try by adding web_studio or studio_customization in the depends and see. Not remember which one exactly it was, try and let us know.

Thanks

아바타
취소
작성자 베스트 답변

Great, that seems to work. When I install the module, it looks like it installs, but when I enter the module, the "Cancel Installation" button is still active, as if it hasn't finished. I'm not sure if using computed fields in Odoo 15 causes it to stay in this state until it finishes loading the values into the database. Please correct me if I'm wrong.


아바타
취소
관련 게시물 답글 화면 활동
1
9월 24
1010
0
7월 25
648
0
5월 24
1123
0
5월 24
976
1
8월 25
427