跳至内容
菜单
此问题已终结

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

形象
丢弃
相关帖文 回复 查看 活动
2
10月 19
4024
2
10月 19
3469
3
7月 18
3792
0
3月 15
4180
2
3月 15
16200