Hi everyone,
I created a new model in odoo15 to create products. This model is completely separate from the existing product.product and product.template models (I don’t want to deal with their existing fields and functions and need to add many new ones).
Now I would like to create invoices based on these products, and in odoo13 it worked to simply create a new class that inherits the existing account.move.line and redefines the product_id field like this:
class CustomAccountMoveLine(models.Model):"""Create Class for all V-Label invoice lines."""_inherit = 'account.move.line'_description = 'Custom Invoice Lines'product_id = fields.Many2one('MyCustomModule', string="Custom Product")(...)(I also had to add some fields to my custom module and change the _get_computed_price_unit function in account.move.line to make it work)
Now I can select the products correctly in my invoice lines and their quantity, prices, taxes, labels etc. are computed correctly. But when I click on “save”, I get the following error message:
Missing Record
Record does not exist or has been deleted.
(Record: product.product(1,), User: 2)
This happens, because in the Sales module I don’t have any record in the ‘product.product’ class - and I don’t want to have those, because after all I have my own product module. But why does this happen? Why is account.move(.line) still looking for product.product when I click the save button, even though everything up to that point is working fine? Also, why did this work in odoo13 but not odoo15? Could anyone please enlighten me?
Another approach I tried was to inherit the product module in my custom module:
_inherit = ‘product.product’But when I try to upgrade my module, I get this database error below which I don’t know how to solve. Do I need to hack the database for this? Thank you very much in advance!
psycopg2.errors.UndefinedColumn: column "MyCustomModule_product_id" referenced in foreign key constraint does not exist
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- إدارة علاقات العملاء
- e-Commerce
- المحاسبة
- المخزون
- PoS
- Project
- MRP
لقد تم الإبلاغ عن هذا السؤال
3336
أدوات العرض
هل أعجبك النقاش؟ لا تكن مستمعاً فقط. شاركنا!
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيلالمنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
---|---|---|---|---|
|
1
سبتمبر 24
|
3414 | ||
|
1
مارس 22
|
3212 | ||
|
3
نوفمبر 23
|
5456 | ||
|
0
أبريل 23
|
2750 | ||
|
0
مايو 24
|
2837 |