İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
10007 Görünümler

Hello,

I'm using Odoo 13 Community Edition.


In my case I need a routing for every product.

So to assign every routing to a product I created this field in my custom module for product.template:


class ProductTemplate(models.Model):

    _inherit = ['product.template']

 

    routing_id = fields.Many2one(

        'mrp.routing', 'Arbeitsplan', compute='_compute_routing_id')


    @api.depends('routing_id')

    def _compute_routing_id(self):

        for product in self:

            product.routing_id = self.env['mrp.routing'].search([('product_id','=',product.id)])




And in mrp.routing:


class MrpRouting(models.Model):

    _inherit = ['mrp.routing']


    product_id = fields.Many2one(

        'product.template', 'Produkt', required=True)


    @api.onchange('product_id')    

    def _onchange_product_id_name(self):

        self.name = self.product_id.name


(The onchange method because I made the name field invisible in the form view.)




Now I thought I could show the operation_ids field directly in the product.template form view.


So I also added the field to product.template in my custom module like the routing_id:

class ProductTemplate(models.Model):

    _inherit = ['product.template']

 

    operation_ids = fields.One2many(

        'mrp.routing.workcenter', 'routing_id', 'Operations',

        copy=True)


And in the form view:

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

            <field name="name">product.template.product.form.mgtec</field>

            <field name="model">product.template</field>

            <field name="inherit_id" ref="product.product_template_only_form_view"/>

<field name="priority" eval="100"/>

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

<xpath expr="//page[@name='variants']" position="before">

<page string="Vorgänge" name="vorgaenge">

                        <field name="operation_ids" context="{'default_routing_id': routing_id}"/>

</page>

</xpath>

</field>

</record>




But when I want to change the operations in the product view and it opens the pop up form view from mrp.routing.workcenter to change the operations in the routingI get an error and its like a never ending story like it needs every field from product.template/product.product in mrp.routing.


I searched for a method that could cause the errors, but i dont find any solution.


Thanks in advance.


The full error code:


Odoo Server Error
Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5089, in _update_cache
    field_values = [(fields[name], value) for name, value in values.items()]
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5089, in <listcomp>
    field_values = [(fields[name], value) for name, value in values.items()]
KeyError: 'sale_delay'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 619, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 309, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\pycompat.py", line 14, in reraise
    raise value
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 664, in dispatch
    result = self._call_function(**self.params)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 345, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\service\model.py", line 93, in wrapper
    return f(dbname, *args, **kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 338, in checked_call
    result = self.endpoint(*a, **kw)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 909, in __call__
    return self.method(*args, **kw)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 510, in response_wrap
    response = f(*args, **kw)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1320, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1312, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\api.py", line 395, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\api.py", line 382, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 6030, in onchange
    record._update_cache(changed_values, validate=False)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5095, in _update_cache
    cache.set(self, field, field.convert_to_cache(value, self, validate))
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\fields.py", line 2393, in convert_to_cache
    id_ = record.env[self.comodel_name].new(value).id
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5432, in new
    record._update_cache(values, validate=False)
  File "C:\Program Files (x86)\Odoo 13.0\server\odoo\models.py", line 5091, in _update_cache
    raise ValueError("Invalid field %r on model %r" % (e.args[0], self._name))
ValueError: Invalid field 'sale_delay' on model 'mrp.routing'





Avatar
Vazgeç

Did you fix this error?

En İyi Yanıt

Try to create inline tree/form view for operation_ids field:

<field name="operation_ids" context="{'default_routing_id': routing_id}">
<tree>
<field name=""/>
</tree>
<form>
<field name=""/>
</form>
</field>


Avatar
Vazgeç
Üretici

Did not work, I'm still getting the same errors.

En İyi Yanıt

Any Idea guys ?!!
Please

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Oca 20
3704
0
Tem 21
3442
1
Eyl 20
2747
1
Ara 19
4773
0
Ağu 16
3762