Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
13847 Представления

hi all, its my custom module, when trying to run Category view from menu, it is showing error below:

ValueError: Invalid field 'category_name' on model 'pos.category'

same error even when i removed line:  _rec_name = 'category_name'

please help to solve the problem.


category.py

from odoo import api, fields, models



class PosCategory(models.Model):

    _name = "pos.category"

    _rec_name = "category_name"

    _description = "Categories for POS"


    category_name = fields.Char(string='Category Name', required=True)

    group_id = fields.Many2one('pos.group', widget="many2one_tags", string='Related Group')



category.xml

<?xml version="1.0"?>

<odoo>

    <record id="view_tree_category" model="ir.ui.view">

        <field name="name">Category List</field>

        <field name="model">pos.category</field>

        <field name="arch" type="xml">

            <tree>

                <field name="id"/>

                <field name="category_name"/>

                <field name="group_id"/>

            </tree>

        </field>

    </record>

    <record id="view_form_category" model="ir.ui.view">

        <field name="name">Category Form</field>

        <field name="model">pos.category</field>

        <field name="arch" type="xml">

            <form>

                <sheet>

                    <group name="group_top">

                        <field name="category_name"/>

                        <field name="group_id"/>

                    </group>

                </sheet>

            </form>

        </field>

    </record>    

</odoo>


Аватар
Отменить
Лучший ответ

Hello Smithjohn45,

In the point_of_sale base Odoo module there is already pos. category model is declared so in your case you have 2 option

1. Rename your model name (don't use pos. category) 

2. Inherit pos. category and add your custom field

Thanks...

For more information Contact us:- https: //kanakinfosystems.com/odoo-development-services

Аватар
Отменить
Автор

yeah, i resolved it renaming my model with pos.categories ... thanks

Related Posts Ответы Просмотры Активность
1
июл. 22
2499
0
сент. 21
214
1
июн. 21
3761
0
мая 21
2441
1
июл. 25
2319