Skip to Content
Menu
This question has been flagged

I have been trying to inherit sale.order into my student.certificate. they showing some errors like

TypeError: Many2many fields student.certificate.transaction_ids and sale.order.transaction_ids use the same table and columns


 and I want to show the sale.view_order_form into my custom module. 

from odoo import api, models, fields, _


class StudentCertificate(models.Model):
_name = 'student.certificate'
_inherit = 'sale.order'
_description = 'student ceritficate verification'


So the student.certificate is added to menu list.

xml version="1.0" encoding="utf-8" ?>


id="action_student_certificate" model="ir.actions.act_window">
name="name">Students
name="type">ir.actions.act_window
name="res_model">student.certificate
name="view_mode">tree,form

id="menu_student_ceritficate" name="Certificate Verification" sequence="10"
action="action_student_certificate"/>

id="action_student_certificate_inherit" model="ir.ui.view">
name="name">student.certificate.form
name="model">student.certificate
name="inherit_id" ref="sale.view_order_form"/>
name="arch" type="xml">
name="partner_id"/>



Avatar
Discard
Best Answer

Hi,

You have redefine the transaction_ids in the newly created model with a different name for many2many table.

In sale order model:

transaction_ids = fields.Many2many('payment.transaction', 'sale_order_transaction_rel', 'sale_order_id', 'transaction_id',

string='Transactions', copy=False, readonly=True)


In your new model add this field:

transaction_ids = fields.Many2many('payment.transaction', 'student_certificate_transaction_rel', 'sale_order_id', 'transaction_id',

string='Transactions', copy=False, readonly=True)


Not sure what is the purpose of inheriting the sale.order model here, see if t is really needed.


Thanks

Avatar
Discard

Check following link to inherit and add a field in Odoo model

https://youtu.be/A-0uQnJr3QA

Best Regards & Thanks

Best Answer

Hi, 

transaction_ids is an existing field in sales, so please rename the transaction_ids field in student.certificate and try.

How To Inherit And Add Field To A Model

Thanks

Avatar
Discard
Related Posts Replies Views Activity
5
Jun 21
15570
1
Dec 22
2387
4
Oct 20
8794
4
Aug 20
5070
0
Apr 19
2536