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:
- CRM
- e-Commerce
- Účetnictví
- Sklad
- PoS
- Project
- MRP
This question has been flagged
3330
Zobrazení
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Přihlásit seRelated Posts | Odpovědi | Zobrazení | Aktivita | |
---|---|---|---|---|
|
1
zář 24
|
3409 | ||
|
1
bře 22
|
3212 | ||
|
3
lis 23
|
5453 | ||
|
0
dub 23
|
2750 | ||
|
0
kvě 24
|
2837 |