Hi, I want to delete the records in the one2many fields when the original record that had them is deleted. I tried adding ondelete="cascade" to the one2many declaration but the records in the one2many table still remains when i delete the record holding it. How do i achieve this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilità
- Magazzino
- PoS
- Project
- MRP
La domanda è stata contrassegnata
1
Rispondi
32664
Visualizzazioni
Hi,
You should put ondelete="cascade"
in the field relation id like here:
class sale_order(osv.osv):
_name = 'sale.order'
_columns = {
'name': fields.char('Order Reference', size=64, required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True),
'order_line': fields.one2many('sale.order.line', 'order_id', 'Order Lines', readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
....
sale_order()
class sale_order_line(osv.osv):
_name = 'sale.order.line'
_columns = {
'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade', select=True, readonly=True, states={'draft':[('readonly',False)]}),
.
.
.
sale_order_line()
Thanks, i was doing it the other way round. Now it solved the problem
Ti stai godendo la conversazione? Non leggere soltanto, partecipa anche tu!
Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!
RegistratiPost correlati | Risposte | Visualizzazioni | Attività | |
---|---|---|---|---|
|
0
mar 15
|
3241 | ||
|
2
mag 24
|
9188 | ||
Confirm on delete one2many line
Risolto
|
|
5
lug 20
|
10689 | |
|
5
gen 24
|
17095 | ||
|
0
set 15
|
3876 |