Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
4310 Visualizzazioni

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>

Avatar
Abbandona
Risposta migliore

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.

Avatar
Abbandona
Risposta migliore

Hi,

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

Thanks

Avatar
Abbandona
Risposta migliore

Kindly read the doc about building an Odoo Module.

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
ott 19
4035
2
ott 19
3483
3
lug 18
3809
0
mar 15
4187
2
mar 15
16206