0
in one2many行刪除按鈕是否存在當該行中的布爾值字段爲true時,該行不會刪除並引發異常。我喜歡以下代碼如何覆蓋one2many中的刪除按鈕從銷售訂單
但我不會影響代碼。沒有任何迴應行被刪除。請....告訴我任何一個
在此先感謝....
from odoo import api, models, fields, _, SUPERUSER_ID
import string
from odoo import exceptions
from odoo.exceptions import ValidationError
class ouc_sale_order(models.Model):
_inherit = 'sale.order'
c_state = fields.Selection(
[("draft", "Draft Proforma Invoice"), ("sent", "Proforma Invoice Sent"), ("cancel", "Cancelled"),
("waiting_date", "Waiting Schedule"), ("progress", "Sales Order"), ("manual", "Sale to Invoice"),
("shipping_except", "Shipping Exception"), ("invoice_except", "Invoice Exception"), ("done", "Done")],
string='State')
class ouc_sales_order_line(models.Model):
_inherit = 'sale.order.line'
c_status = fields.Selection([('New', 'New'), ('renewal', 'Renewal'), ('upgrade', 'Upgrade'), ('upsell', 'Upsell'), ('PDC', 'PDC'),
('etc', 'etc')], string='Status', default='New')
c_fptags_id = fields.Many2one('ouc.fptag', string='FPTAGs')
c_product_template_id = fields.Many2one('product.template', string='Product Template', related='product_id.product_tmpl_id')
c_package_id = fields.Many2one('ouc.package', string='Packages')
c_pkg_expiry_in_month = fields.Integer(string='Package Expires After(Months)', related='c_package_id.validity')
c_subtotaltax = fields.Float('Subtotal with Tax')
c_taxamount = fields.Float('Tax Amount')
c_client_id = fields.Char('Client Id')
c_default_discount = fields.Float('Default Discount (%)')
c_max_discount = fields.Float('Maximum Discount (%)')
c_subscription_status = fields.Boolean(string='Subscription')
#@api.multi
#def unlink(self):
# for record in self:
# if record.c_subscription_status:
# raise exceptions.ValidationError(_('You didn\'t delete this record'))
# return super(ouc_sales_order_line,self).unlink()
您能否在此指定模型結構? –
你的代碼似乎沒有問題。你能告訴我們你在模型中添加了這個方法嗎? –
我已經在父類的comodel中添加了。在sale.order.line –