Skip to Content
Menu
This question has been flagged
1 Reply
12273 Views

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>


Avatar
Discard
Best Answer

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

Avatar
Discard
Author

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

Related Posts Replies Views Activity
1
Jul 22
1152
0
Sep 21
213
1
Jun 21
2558
0
May 21
1543
1
Nov 24
1482