in one2many Zeile löschen Schaltfläche ist vorhanden, wenn ein boolesches Feld in dieser Zeile wahr ist, wird die Zeile nicht löschen und eine Ausnahme auslösen. Ich mag den folgenden CodeWie überschreiben Sie die Schaltfläche Löschen in one2many aus Verkaufsauftrag
, aber ich werde nicht im Code betroffen. Es gibt keine Antwort die Zeile gelöscht. bitte .... sagen Sie mir alle ein
Dank im Voraus ....
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()
Können Sie bitte hier die Modellstruktur angeben? –
Ihr Code scheint korrekt, es gibt kein Problem. Können Sie uns bitte zeigen, wo Sie diese Methode im Modell hinzugefügt haben? –
Ich habe im comodel der Elternklasse hinzugefügt. das comodel ist sale.order.line –