Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
5 Ответы
5285 Представления

Dear

We develop an application that inherits the contract module "Contracts Management - Recurring" by means of which a partner can have several contracts. The partner_id field can only be made mandatory at the view level, because other applications such as Project enter records into the account.analytic.account model for which this field is not mandatory. On the other hand in the Contacts module (res.partner) it is allowed to delete contacts, permission that can not be removed from the users. However, in the Contacts module there are 2 options to delete contacts, the first with the Action \ Delete button and the second by clicking on the kanban of the "Contacts & Address" page. In both cases the contact is deleted without taking into account that it has contracts in the contract module. What I need is that in the 2 deletion options it is not allowed to delete the contact that has associated contracts.

I would appreciate any suggestions.

We are working with Odoo 11.0

Аватар
Отменить

Hi Niyas, thank you for your kind answer!

But, it is not clear to me in which model I should put it, is it in account.analytic.account.py? What effect does the clause ondelete = 'restrict'? 

Best regards,
Claudio Zayas

On Monday, May 13, 2019, 9:44:53 AM GMT-4, Niyas Raphy <niyasraphyk@gmail.com> wrote:


A new question Do not allow deleting a contact with an associated contract on Help has been posted. Click here to access the question :

See question

Sent by Odoo S.A. using Odoo.

Hi Niyas, thank you for your kind answer!

But, it is not clear to me in which module I should put it, is it in account.analytic.account.py? What effect does the clause ondelete = 'restricted'? 

Лучший ответ

Hi Claudio Zayas,

You need to inherit the "account.analytic.account" object in your custom module and overwrite the partner_id field and add ondelete="restrict" in the field.

class AnalyticAccount(models.Model):
_inherit = 'account.analytic.account'

partner_id = fields.Many2one(ondelete="restrict")

ondelete restrict will now allow user to delete any partner record if it is associated with any Contract.

Аватар
Отменить
Лучший ответ

Hi,

You can use ondelete='restrict' with the partner field in your model.

partner = fields.Many2one('res.partner', string='Partner', ondelete='restrict')

Thanks

Аватар
Отменить
Автор Лучший ответ

Dear Sudhir & Niyas, thank you very much for your help. I applied your solution and it worked fine!

Best regards,

Claudio


Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
июл. 25
1329
3
нояб. 24
4891
3
нояб. 23
7703
1
апр. 23
2723
1
мар. 22
2345