0

Good afternoon, I have an error in my Odoo 8 module, the error is like this: MissingError

One of the documents you are trying to access has been deleted, please try again after refreshing.

Screenshoot Error: Screenshoot Error 1 Screenshoot Error 2

Detail full error:

File "C:\Tunas_Ridean\Odoo-8.0\addons\sale\sale.py", line 1067, in product_id_change
    if product_obj.taxes_id:
  File "C:\Tunas_Ridean\Odoo-8.0\openerp\fields.py", line 840, in __get__
    return record._cache[self]
  File "C:\Tunas_Ridean\Odoo-8.0\openerp\models.py", line 6041, in __getitem__
    return value.get() if isinstance(value, SpecialValue) else value
  File "C:\Tunas_Ridean\Odoo-8.0\openerp\fields.py", line 56, in get
    raise self.exception
MissingError: ('MissingError', u'One of the documents you are trying to access has been deleted, please try again after refreshing.')

My Code Modul:

File Script Models sale_order.py:

# models/sale_order.py
from openerp import models, fields
from openerp import api

class SaleOrderLine(models.Model):
    _inherit = 'sale.order.line'

    product_id = fields.Many2one(
        'product.custom', string='Product', required=True,
        domain=[('state', 'in', ['confirmed', 'approved'])]
    )

    price_unit = fields.Float(
        string='Price Unit',
        related='product_id.price',  # Mengambil harga dari `product.custom`
        store=True,
        readonly=True
    )
    
    @api.onchange('product_id.price','price_unit')
    def _onchange_product_id(self):
        #import ipdb; ipdb.set_trace()
        self.price_unit = self.product_id.price
        self.name = self.product_id.description
        self.product_uom_qty = self.product_id.qty

File Script XML sale_order_view.xml:

<!-- views/sale_order_view.xml -->
<openerp>
<data>
    <record id="view_order_form_custom" model="ir.ui.view">
        <field name="name">sale.order.form.inherit</field>
        <field name="model">sale.order</field>
        <field name="inherit_id" ref="sale.view_order_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='product_id']" position="replace">
                <field name="product_id"/>
            </xpath>
            <xpath expr="//field[@name='price_unit']" position="attributes">
                <attribute name="readonly">1</attribute>
            </xpath>
        </field>
    </record>
    </data>
</openerp>

1 Answer 1

0

You have changed the relation in the Many2one field product_id to a different model. But product_id is used in a lot of business logic. Part of this business logic probably calls subfields that your model simply does not have. This is just a guess, but it should be very close to a correct answer.

My advice: I would not radically change such a core component as products in order lines as you are doing. Better try another way, e.g. a new field custom_product_id or something similar.

Sign up to request clarification or add additional context in comments.

3 Comments

How to solve? Iam don't understand you mean
I wrote an advice... there are several ways to fix. Just two: let your changes stay and try to fix every business logic where product_id is involved (could take you days to weeks of work) OR take my advice into consideration and don't change product_id at all.
Okay, thanks for solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.