refactor: Se extraen archivos
This commit is contained in:
		
							
								
								
									
										0
									
								
								core/Prospect/wizards/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								core/Prospect/wizards/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										83
									
								
								core/Prospect/wizards/assign_operator.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								core/Prospect/wizards/assign_operator.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,83 @@ | ||||
| # This file is part of Tryton.  The COPYRIGHT file at the top level of | ||||
| # this repository contains the full copyright notices and license terms. | ||||
|  | ||||
|  | ||||
| from trytond.wizard import Wizard, StateView, Button, StateTransition | ||||
| from trytond.model import ModelView, fields | ||||
| from trytond.pyson import Eval | ||||
| from trytond.pool import Pool | ||||
|  | ||||
|  | ||||
| class AssignOperatorStart(ModelView): | ||||
|     'Inicio de asignación de operador' | ||||
|     __name__ = 'sale.prospect.assign.start' | ||||
|  | ||||
|     prospects_chunk = fields.Integer( | ||||
|         'Prospects chunk', required=True, | ||||
|         states={ | ||||
|             'readonly': ~Eval('business_unit', False)}) | ||||
|  | ||||
|     operator = fields.Many2One('res.user', 'Operator', required=True) | ||||
|     prospects = fields.One2Many( | ||||
|         'sale.prospect', None, 'Prospects', readonly=True) | ||||
|  | ||||
|     business_unit = fields.Selection( | ||||
|         [('brigade', 'Brigade'), | ||||
|          ('optics', 'Optics'), | ||||
|          ('equipment', 'Equipment')], | ||||
|         'Business unit', | ||||
|         states={ | ||||
|             'readonly': Eval('prospects_chunk', False)} | ||||
|     ) | ||||
|  | ||||
|     @classmethod | ||||
|     def default_prospects_chunk(cls): | ||||
|         return 0 | ||||
|  | ||||
|     @fields.depends('prospects_chunk', 'prospects', 'business_unit') | ||||
|     def on_change_prospects_chunk(self): | ||||
|         pool = Pool() | ||||
|         Prospect = pool.get('sale.prospect') | ||||
|  | ||||
|         if self.prospects_chunk >= 1: | ||||
|             self.prospects = [] | ||||
|             self.prospects = Prospect.search( | ||||
|                 [('state', '=', 'unassigned'), | ||||
|                  ('business_unit', '=', self.business_unit)], | ||||
|                 limit=self.prospects_chunk) | ||||
|  | ||||
|  | ||||
| class AssignOperator(Wizard): | ||||
|     'Asignar operador a prospecto' | ||||
|     __name__ = 'sale.prospect.assign' | ||||
|  | ||||
|     start = StateView( | ||||
|         'sale.prospect.assign.start', | ||||
|         'sale_opportunity_management.assign_start_view_form', [ | ||||
|             Button("Cancel", 'end', 'tryton-cancel'), | ||||
|             Button("Assign", 'assign', 'tryton-ok', default=True)]) | ||||
|  | ||||
|     assign = StateTransition() | ||||
|  | ||||
|     def transition_assign(self): | ||||
|         pool = Pool() | ||||
|         ProspectTrace = pool.get('sale.prospect_trace') | ||||
|  | ||||
|         for prospect in self.start.prospects: | ||||
|             prospect.assigned_operator = self.start.operator | ||||
|             prospect.state = 'assigned' | ||||
|             prospect.save() | ||||
|  | ||||
|             prospect_trace = ProspectTrace( | ||||
|                 prospect=prospect, | ||||
|                 prospect_city=prospect.city, | ||||
|                 prospect_business_unit=prospect.business_unit, | ||||
|                 prospect_assigned_operator=prospect.assigned_operator, | ||||
|                 prospect_contacts=prospect.contact_methods | ||||
|             ) | ||||
|             prospect_trace.save() | ||||
|  | ||||
|             prospect.prospect_trace = prospect_trace | ||||
|             prospect.save() | ||||
|  | ||||
|         return 'end' | ||||
							
								
								
									
										61
									
								
								core/Prospect/wizards/reassign_prospect_by_operator.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								core/Prospect/wizards/reassign_prospect_by_operator.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| # This file is part of Tryton.  The COPYRIGHT file at the top level of | ||||
| # this repository contains the full copyright notices and license terms. | ||||
|  | ||||
|  | ||||
| from trytond.wizard import Wizard, StateView, Button, StateTransition | ||||
| from trytond.model import ModelView, fields | ||||
| from trytond.pool import Pool | ||||
|  | ||||
|  | ||||
| class ReassignProspectByOperatorStart(ModelView): | ||||
|     'Inicio de reasignación de prospecto por operario' | ||||
|     __name__ = 'sale.prospect.reassign_by_operator.start' | ||||
|  | ||||
|     current_operator = fields.Many2One( | ||||
|         'res.user', "Current operator", required=True) | ||||
|     new_operator = fields.Many2One( | ||||
|         'res.user', "New operator", required=True) | ||||
|     prospects = fields.One2Many( | ||||
|         'sale.prospect', None, 'Prospects', readonly=True) | ||||
|  | ||||
|     @fields.depends('current_operator', 'prospects') | ||||
|     def on_change_current_operator(self): | ||||
|         pool = Pool() | ||||
|         Prospect = pool.get('sale.prospect') | ||||
|  | ||||
|         self.prospects = [] | ||||
|         self.prospects = Prospect.search( | ||||
|             [('state', '=', 'assigned'), | ||||
|              ('assigned_operator', '=', self.current_operator)]) | ||||
|  | ||||
|  | ||||
| class ReassignProspectByOperator(Wizard): | ||||
|     'Reasignar todos los prospectos de un operario, a otro operario' | ||||
|     __name__ = 'sale.prospect.reassign_by_operator' | ||||
|  | ||||
|     start = StateView( | ||||
|         'sale.prospect.reassign_by_operator.start', | ||||
|         'sale_opportunity_management.reassign_by_operator_start_view_form', | ||||
|         [Button("Cancel", 'end', 'tryton-cancel'), | ||||
|          Button("Reassign", 'reassign_by_operator', 'tryton-ok', default=True) | ||||
|          ]) | ||||
|  | ||||
|     reassign_by_operator = StateTransition() | ||||
|  | ||||
|     def transition_reassign_by_operator(self): | ||||
|         pool = Pool() | ||||
|         ProspectTrace = pool.get('sale.prospect_trace') | ||||
|  | ||||
|         for prospect in self.start.prospects: | ||||
|             prospect.assigned_operator = self.start.new_operator | ||||
|  | ||||
|             if prospect.prospect_trace: | ||||
|                 prospect_trace, = ProspectTrace.search( | ||||
|                     [('prospect', '=', prospect)]) | ||||
|                 prospect_trace.prospect_assigned_operator =\ | ||||
|                     self.start.new_operator | ||||
|                 prospect_trace.save() | ||||
|  | ||||
|             prospect.save() | ||||
|  | ||||
|         return 'end' | ||||
							
								
								
									
										48
									
								
								core/Prospect/wizards/reassign_prospect_by_prospect.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								core/Prospect/wizards/reassign_prospect_by_prospect.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| # This file is part of Tryton.  The COPYRIGHT file at the top level of | ||||
| # this repository contains the full copyright notices and license terms. | ||||
|  | ||||
|  | ||||
| from trytond.wizard import Wizard, StateView, Button, StateTransition | ||||
| from trytond.model import ModelView, fields | ||||
| from trytond.pool import Pool | ||||
|  | ||||
|  | ||||
| class ReassignProspectByProspectStart(ModelView): | ||||
|     'Inicio de reasignación de un prospecto en específico' | ||||
|     __name__ = 'sale.prospect.reassign_by_prospect.start' | ||||
|  | ||||
|     prospect = fields.Many2One( | ||||
|         'sale.prospect', 'Prospect', required=True, | ||||
|         domain=[('assigned_operator', '!=', None)]) | ||||
|  | ||||
|     new_operator = fields.Many2One('res.user', "New operator", required=True) | ||||
|  | ||||
|  | ||||
| class ReasignProspectByProspect(Wizard): | ||||
|     'Reasignar un prospecto en específico a un nuevo operario' | ||||
|     __name__ = 'sale.prospect.reassign_by_prospect' | ||||
|  | ||||
|     start = StateView( | ||||
|         'sale.prospect.reassign_by_prospect.start', | ||||
|         'sale_opportunity_management.reassign_by_prospect_start_view_form', | ||||
|         [Button("Cancel", 'end', 'tryton-cancel'), | ||||
|          Button("Reassign", 'reassign_by_prospect', 'tryton-ok', default=True) | ||||
|          ]) | ||||
|  | ||||
|     reassign_by_prospect = StateTransition() | ||||
|  | ||||
|     def transition_reassign_by_prospect(self): | ||||
|         pool = Pool() | ||||
|         ProspectTrace = pool.get('sale.prospect_trace') | ||||
|  | ||||
|         self.start.prospect.assigned_operator = self.start.new_operator | ||||
|  | ||||
|         if self.start.prospect.prospect_trace: | ||||
|             prospect_trace, = ProspectTrace.search( | ||||
|                 [('prospect', '=', self.start.prospect)]) | ||||
|             prospect_trace.prospect_assigned_operator =\ | ||||
|                 self.start.new_operator | ||||
|             prospect_trace.save() | ||||
|  | ||||
|         self.start.prospect.save() | ||||
|         return 'end' | ||||
		Reference in New Issue
	
	Block a user