Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
3442 Lượt xem

Dear All,


Odoo V16


I try to inherit a wizard but I have the below error: 

TypeError: transforms the transient model 'sale.advance.payment.inv' into a non-transient model. That class should either inherit from TransientModel, or set a different '_name'. 




I don't inherit XML file, I want only to override the function.


I try to inherit this code:

class SaleAdvancePaymentInv(models.TransientModel):
​​ _name = 'sale.advance.payment.inv'
​_description = "Sales Advance Payment Invoice"

​def create_invoices(self):
​​​​​self._create_invoices(self.sale_order_ids)
​​​​...​
return {'type': 'ir.actions.act_window_close'}


My code:

class SaleAdvancePaymentInvInherited(models.TransientModel):
​# Also, I try without using _name
​_name = 'sale.advance.payment.inv.inherited'
​_inherit = "sale.advance.payment.inv"

​def create_invoices(self)
:
​​self._create_invoices(self.sale_order_ids)

​logging.info('Hello function')
​...
​return {'type': 'ir.actions.act_window_close'}


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can remove the _name attribute from the code and try as follows:

class SaleAdvancePaymentInv(models.TransientModel):
_inherit = "sale.advance.payment.inv"

def _prepare_invoice_values(self, order, so_line):
res = super()._prepare_invoice_values(order, so_line)
if order.l10n_in_journal_id:
res['journal_id'] = order.l10n_in_journal_id.id
if order.country_code == 'IN':
res['l10n_in_gst_treatment'] = order.l10n_in_gst_treatment
if order.l10n_in_reseller_partner_id:
res['l10n_in_reseller_partner_id'] = order.l10n_in_reseller_partner_id
return res

Sample from: https://github.com/odoo/odoo/blob/16.0/addons/l10n_in_sale/wizard/sale_make_invoice_advance.py

Thanks

Ảnh đại diện
Huỷ bỏ
Tác giả

I have the same error.

please make sure to restart or ensure that the service is getting restarted and proper dependency is added

Tác giả

I just restarted my computer. The IDE was stuck. Sad

Câu trả lời hay nhất

Hi, you can follow following link for this:

https://youtu.be/oMnHpHH54QU

Thanks

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi

Try the code,

from odoo import models

class SaleAdvancePaymentInv(models.TransientModel):
    _inherit = 'sale.advance.payment.inv'

    def create_invoices(self):
        result = super(SaleAdvancePaymentInv, self).create_invoices()
       
        # Add your custom logic here
       
        return result

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 1 24
1731
1
thg 4 24
1680
1
thg 11 24
4112
1
thg 5 23
3562
0
thg 2 25
3271