I have added a field document to the project.project model and field attach_compulsory to project.config.settings model and extended the method called by the Create button on the project wizard view to make sure that a document is attached if the attach_compulsory field is selected in the Project settings.
However, when i click on the attach_compulsory field in the settings, the button doesn't respond.
Here are my codes:
# -*- coding: utf-8 -*-
from odoo import models, fields, api, _
from odoo.exceptions import UserError
import logging
from odoo.exceptions import Warning
_logger = logging.getLogger(__name__) # Need for message in console.
class ProjectWorkflow(models.Model):
_inherit = "project.project"
state = fields.Selection([
('draft', 'In Progress'),
('cancelled', 'Cancelled'),
('pending', 'Pending'),
('closed', 'Closed'),
],string='State',
readonly=True,
default='draft',
track_visibility='onchange'
)
document = fields.Binary('Project Start File')
@api.one
def close_project(self):
self.state="closed"
@api.one
def cancel_project(self):
self.state = "cancelled"
@api.one
def pending_project(self):
self.state="pending"
@api.multi
def close_dialog(self):
print "=====================Check here========================="
config_set = self.env['project.config.settings']
if config_set.fields_get().get('attach_compulsory', None) is not None:
if not self.document:
raise UserError("Please attach a project commencement document!")
return super(ProjectWorkflow, self).close_dialog()
class ProjectConfig(models.TransientModel):
_inherit = 'project.config.settings'
attach_compulsory = fields.Boolean
('Project Start Document Compulsory', default=False)
Here is the xml file:
Project Workflow View
project.project
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
2183
Vues
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrire