Initial commit: OCA Technical packages (595 packages)

This commit is contained in:
Ernad Husremovic 2025-08-29 15:43:03 +02:00
commit 2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions

View file

@ -0,0 +1,5 @@
# Copyright 2021 Sygel - Valentin Vinagre
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from . import crm_salesperson_planner_visit_close_wiz
from . import crm_salesperson_planner_visit_template_create

View file

@ -0,0 +1,63 @@
# Copyright 2021 Sygel - Valentin Vinagre
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from odoo import _, fields, models
class CrmSalespersonPlannerVisitCloseWiz(models.TransientModel):
_name = "crm.salesperson.planner.visit.close.wiz"
_description = "Get Close Reason"
def _default_new_date(self):
visits = self.env["crm.salesperson.planner.visit"].browse(
self.env.context.get("active_id")
)
return visits.date
def _default_new_sequence(self):
visits = self.env["crm.salesperson.planner.visit"].browse(
self.env.context.get("active_id")
)
return visits.sequence
reason_id = fields.Many2one(
comodel_name="crm.salesperson.planner.visit.close.reason",
string="Reason",
required=True,
)
image = fields.Image(max_width=1024, max_height=1024)
new_date = fields.Date(default=lambda self: self._default_new_date())
new_sequence = fields.Integer(
string="Sequence",
help="Used to order Visits in the different views",
default=lambda self: self._default_new_sequence(),
)
require_image = fields.Boolean(
string="Require Image", related="reason_id.require_image"
)
reschedule = fields.Boolean(default=True)
allow_reschedule = fields.Boolean(
string="Allow Reschedule", related="reason_id.reschedule"
)
notes = fields.Text()
def action_close_reason_apply(self):
visits = self.env["crm.salesperson.planner.visit"].browse(
self.env.context.get("active_id")
)
visit_close_find_method_name = "action_%s" % self.reason_id.close_type
if hasattr(visits, visit_close_find_method_name):
getattr(visits, visit_close_find_method_name)(
self.reason_id, self.image, self.notes
)
if self.allow_reschedule and self.reschedule:
visits.copy(
{
"date": self.new_date,
"sequence": self.new_sequence,
"opportunity_ids": visits.opportunity_ids.ids,
}
).action_confirm()
else:
raise ValueError(_("The close reason type haven't a function."))
return {"type": "ir.actions.act_window_close"}

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2021 Sygel - Valentin Vinagre
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="crm_salesperson_planner_visit_close_wiz_view_form" model="ir.ui.view">
<field name="name">crm.salesperson.lost.form</field>
<field name="model">crm.salesperson.planner.visit.close.wiz</field>
<field name="arch" type="xml">
<form string="Close Reason">
<group>
<field
name="reason_id"
options="{'no_create': True, 'no_edit': True, 'no_open': True}"
domain="[('close_type','=', context.get('att_close_type', 'cancel'))]"
/>
<field name="notes" />
<field name="allow_reschedule" invisible="1" />
<field
name="reschedule"
attrs="{'invisible': [('allow_reschedule', '=', False)]}"
/>
<field
name="new_date"
attrs="{'invisible': ['|', ('allow_reschedule', '=', False), ('reschedule', '=', False)]}"
/>
<field
name="new_sequence"
attrs="{'invisible': ['|', ('allow_reschedule', '=', False), ('reschedule', '=', False)]}"
/>
<field name="require_image" invisible="1" />
<field
name="image"
widget="image"
attrs="{'invisible': [('require_image', '=', False)], 'required': [('require_image', '=', True)]}"
/>
</group>
<footer>
<button
name="action_close_reason_apply"
string="Submit"
type="object"
class="btn-primary"
/>
<button string="Cancel" class="btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
<record
id="crm_salesperson_planner_visit_close_wiz_action"
model="ir.actions.act_window"
>
<field name="name">Close Reasons</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">crm.salesperson.planner.visit.close.wiz</field>
<field name="view_mode">form</field>
<field name="view_id" ref="crm_salesperson_planner_visit_close_wiz_view_form" />
<field name="target">new</field>
</record>
</odoo>

View file

@ -0,0 +1,34 @@
# Copyright 2021 Sygel - Valentin Vinagre
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html)
from datetime import timedelta
from odoo import _, fields, models
from odoo.exceptions import ValidationError
class CrmSalespersonPlannerVisitTemplateCreate(models.TransientModel):
_name = "crm.salesperson.planner.visit.template.create"
_description = "crm salesperson planner visit template create"
def _default_date_to(self):
template = self.env["crm.salesperson.planner.visit.template"].browse(
self.env.context.get("active_id")
)
date = template.last_visit_date or fields.Date.context_today(self)
return date + timedelta(days=7)
date_to = fields.Date(
string="Date to", default=lambda self: self._default_date_to(), required=True
)
def create_visits(self):
template = self.env["crm.salesperson.planner.visit.template"].browse(
self.env.context.get("active_id")
)
days = (self.date_to - fields.Date.context_today(self)).days
if days < 0:
raise ValidationError(_("The date can't be earlier than today"))
# Create visits + auto-confirm + auto-done
template.create_visits(days=days)
return {"type": "ir.actions.act_window_close"}

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2021 Sygel - Valentin Vinagre
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record
id="crm_salesperson_planner_visit_template_create_view_form"
model="ir.ui.view"
>
<field name="name">crm.salesperson.planner.visit.template.create.form</field>
<field name="model">crm.salesperson.planner.visit.template.create</field>
<field name="arch" type="xml">
<form string="Create Visits">
<group class="oe_title">
<field name="date_to" />
</group>
<footer>
<button
name="create_visits"
string="Create"
type="object"
class="btn-primary"
/>
<button string="Cancel" class="btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
<record
id="crm_salesperson_planner_visit_template_create_action"
model="ir.actions.act_window"
>
<field name="name">Create Visits</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">crm.salesperson.planner.visit.template.create</field>
<field name="view_mode">form</field>
<field
name="view_id"
ref="crm_salesperson_planner_visit_template_create_view_form"
/>
<field name="target">new</field>
</record>
</odoo>