Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
1933 Widoki

Hi odoo community I have a problem, this is my model:

from odoo import api, fields, models
class SaleOrderRepli(models.Model):
_inherit = "sale.order"
_name = "sale.order.repli"

but i have this error TypeError: Many2many fields sale.order.repli.transaction_ids and sale.order.transaction_ids use the same table and columns
how can i solve that? I need replicate the sale.order model but need independency in my custom model with the original model (sale.order)

Awatar
Odrzuć
Najlepsza odpowiedź

To resolve the error you're facing regarding the Many2many field in your custom model sale.order.repli, you can use the copy=True attribute when defining the field. This will create a separate table and columns for the Many2many relationship in your custom model. Here's an updated version of your code:

from odoo import api, fields, models

class SaleOrderRepli(models.Model):
_inherit = "sale.order"
_name = "sale.order.repli"

transaction_ids = fields.Many2many('sale.transaction', 'sale_order_repli_transaction_rel', 'order_id', 'transaction_id', copy=True)
In the above code, we added the copy=True attribute to the transaction_ids field definition. This will ensure that a separate table and columns are created for the Many2many relationship in your sale.order.repli model, avoiding conflicts with the same field in the original sale.order model.

After making this change, you should be able to create and use the sale.order.repli model independently without encountering the "TypeError: Many2many fields use the same table and columns" error.

Awatar
Odrzuć
Najlepsza odpowiedź

I had the same issue when inheriting res.partner it got fixed somehow my uninstall my custom module and rerun my code somehow it worked somehow. I dont know exact reason how it got fixed

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
lis 21
7738
1
mar 17
8005
2
kwi 15
10048
0
mar 15
5011
1
maj 25
771