Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
4307 Переглядів

Hello, i am trying to create a many2one field but am receiving an error. I'm creating a module for handling the growth of plants. One feature i require in the plant's module is a dropdown that contains the warehouses in a database. I have 2 problems. When i try to create my record, i get this error: [object with reference: code - code] and the other error is the "create" and "import" buttons in the warehouse section(inventory > config > warehouses) has disappeared.

Imgur displaying photos:

https://imgur.com/a/8mzjUi1

As you can tell from the code below, there is only 1 input field for this record. I received this error so i made seperate python and xml files just to test. Sure enough, it is this many2one field that is breaking. So how can i go about fixing these errors? 

Side notes: Manifest does have a dependency on inventory (stock_account). 

Here is my code:

Model: 

from odoo import api, fields, modela

from odoo.exceptions import UserError
class Facilities(models.Model):

_name = 'nursery.facilities'

_inherit = 'stock.warehouse'

_description = "A list of facilities involved in doing stuff; \ info from inventory > warehouse"

facility_id = fields.Many2one(comodel_name = 'stock.warehouse', string = 'Facility ID', delegate = True)

XML

<?xml version="1.0" encoding="UTF-8"?>
<odoo>
    <record model="ir.ui.view" id="nursery_facilities_form">
        <field name="name">Facilities Form View</field>
        <field name="model">nursery.facilities</field>
        <field name="arch" type="xml">
            <form string="Plant">
                <sheet>
                    <h1>
                        <field name="facility_id" ref='view_warehouse_tree'/>
                    </h1>
                </sheet>
            </form>
        </field>
    </record>
</odoo>

Аватар
Відмінити
Найкраща відповідь

it because you try to inherit "nursery.facilities" from "stock.warehouse"
In stock.warehouse model, there's few fields that required to fill... so when you try to saving the data (with form or import) its required all required field in stock.warehouse"

Wich odoo version did you use ??
In odoo 12 C.E,,you can check all required field by source (https://github.com/odoo/odoo/blob/12.0/addons/stock/models/stock_warehouse.py#L33)

Or you can check it in Settings->Technical->Database Structure->Fields --> Find / Search by model "stock.warehouse",, and you will get all listed fields on stock.warehouse,, and you can check wich fields that must be required to fill.

Аватар
Відмінити
Найкраща відповідь

Hi,

Add a field named Code in the the view and see, whether there is any change.

Thanks

Аватар
Відмінити
Найкраща відповідь

Kindly read the doc about building an Odoo Module.

https://www.odoo.com/documentation/11.0/howtos/backend.html

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
жовт. 19
4031
2
жовт. 19
3477
3
лип. 18
3800
0
бер. 15
4184
2
бер. 15
16204