first push message

This commit is contained in:
2026-07-01 14:41:49 +07:00
parent 6667dec2bf
commit 58b5f46cc4
2951 changed files with 316619 additions and 0 deletions
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
from . import mass_update_task_wiz
from . import create_task
from . import update_project_stage
@@ -0,0 +1,247 @@
# -*- coding: utf-8 -*-
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError
from dateutil.relativedelta import relativedelta
from odoo.tools import float_is_zero, float_compare, safe_eval, date_utils, email_split
class AddATask(models.TransientModel):
_name = 'sale.task.create'
_description = 'Add a Task'
@api.model
def default_get(self, field_vals):
res = super(AddATask, self).default_get(field_vals)
order_id = self.env['sale.order'].browse(self._context.get('active_id'))
date = fields.Date.context_today(self)
date_deadline = date + relativedelta(days=1)
team_id = order_id.team_id
res.update({
'order_id' : False,
'order_true' : False,
'product_id' : False,
'team_id' : team_id.id,
'project_id' : team_id.order_project_id.id,
'date' : date_deadline,
})
if self._context.get('active_model') == 'sale.order':
order_id = self.env['sale.order'].browse(self._context.get('active_id'))
date = fields.Date.context_today(self)
date_deadline = date + relativedelta(days=1)
res.update({
'order_id' : self._context.get('active_id'),
'order_true' : True,
'project_id' : order_id.team_id.order_project_id.id,
'date' : date_deadline,
'product_id' : False
})
return res
name = fields.Char(string='Task Title')
order_true = fields.Boolean(string='Order')
order_id = fields.Many2one('sale.order', string='Order.')
product_id = fields.Many2one('product.template', string='Product')
team_id = fields.Many2one('crm.team',string='Sales Team')
user_ids = fields.Many2many('res.users', relation='sale_project_task_user_rel', column1='task_id', column2='user_id',
string='Assignees', default=lambda self: self.env.user)
project_id = fields.Many2one('project.project', string='Project')
date = fields.Date('Date Deadline')
def save_nd_edit(self):
for task in self:
task_id = self.env['project.task']
if task.order_true:
stage_id = self.env['project.task.type'].search([
('name','=','Awaiting Internal')],limit=1)
record_id = self.env['project.task'].browse(self._context.get('active_id'))
task_id = self.env['project.task'].create({
'name': task.name or '',
'stage_id' : stage_id.id,
'project_id': task.project_id.id,
'order_id' : task.order_id.id,
'user_ids' : task.user_ids.ids,
'date_deadline' : task.date,
'order_task_created' : True
})
task.order_id.write({
'order_task_created' : True,
'task_ids' : [(4,task_id.id)],
'project_id' : task.project_id.id
})
project_ids = stage_id.mapped('project_ids')
if task.project_id not in project_ids:
stage_id.write({
'project_ids' : [(4, task.project_id.id)]
})
else:
stage_id = self.env['project.task.type'].search([
('name','=','Awaiting Internal')],limit=1)
record_id = self.env['project.task'].browse(self._context.get('active_id'))
task_id = self.env['project.task'].create({
'name': task.name or '',
'stage_id' : stage_id.id,
'project_id': task.project_id.id,
'order_id' : task.order_id.id,
'user_ids' : task.user_ids.ids,
'date_deadline' : task.date,
'order_task_created' : True
})
task.order_id.write({
'order_task_created' : True,
'task_ids' : [(4,task_id.id)],
'project_id' : task.project_id.id
})
project_ids = stage_id.mapped('project_ids')
if task.project_id not in project_ids:
stage_id.write({
'project_ids' : [(4, task.project_id.id)]
})
action = self.with_context(active_id=self.project_id.id).env.ref('bi_all_in_one_project_management_system.act_project_project_2_project_task_my').sudo().read()[0]
action['views'] = [(self.env.ref('project.view_task_form2').id, 'form')]
action['context'] = dict(self.env.context)
action['context']['form_view_initial_mode'] = 'edit'
action['res_id'] = task_id.id
return action
def save_nd_new(self):
for task in self:
task_id = self.env['project.task']
if task.order_true:
stage_id = self.env['project.task.type'].search([
('name','=','Awaiting Internal')],limit=1)
record_id = self.env['project.task'].browse(self._context.get('active_id'))
task_id = self.env['project.task'].create({
'name': task.name or '',
'stage_id' : stage_id.id,
'project_id': task.project_id.id,
'order_id' : task.order_id.id,
'user_ids' : task.user_ids.id,
'date_deadline' : task.date,
'order_task_created' : True
})
task.order_id.write({
'order_task_created' : True,
'task_ids' : [(4,task_id.id)],
'project_id' : task.project_id.id
})
project_ids = stage_id.mapped('project_ids')
if task.project_id not in project_ids:
stage_id.write({
'project_ids' : [(4, task.project_id.id)]
})
else:
stage_id = self.env['project.task.type'].search([
('name','=','Awaiting Internal')],limit=1)
record_id = self.env['project.task'].browse(self._context.get('active_id'))
task_id = self.env['project.task'].create({
'name': task.name or '',
'stage_id' : stage_id.id,
'project_id': task.project_id.id,
'order_id' : task.order_id.id,
'user_ids' : task.user_ids.ids,
'date_deadline' : task.date,
'order_task_created' : True
})
task.order_id.write({
'order_task_created' : True,
'task_ids' : [(4,task_id.id)],
'project_id' : task.project_id.id
})
project_ids = stage_id.mapped('project_ids')
if task.project_id not in project_ids:
stage_id.write({
'project_ids' : [(4, task.project_id.id)]
})
action = self.env.ref('bi_all_in_one_project_management_system.action_task_create_create').sudo().read()[0]
ctx = self._context.copy()
action['context'] = ctx
return action
def add_a_task(self):
for task in self:
task_id = self.env['project.task']
if task.order_true:
stage_id = self.env['project.task.type'].search([
('name','=','Awaiting Internal')],limit=1)
record_id = self.env['project.task'].browse(self._context.get('active_id'))
task_id = self.env['project.task'].create({
'name': task.name or '',
'stage_id' : stage_id.id,
'project_id': task.project_id.id,
'order_id' : task.order_id.id,
'user_ids' : task.user_ids.ids,
'date_deadline' : task.date,
'order_task_created' : True
})
task.order_id.write({
'order_task_created' : True,
'task_ids' : [(4,task_id.id)],
'project_id' : task.project_id.id
})
project_ids = stage_id.mapped('project_ids')
if task.project_id not in project_ids:
stage_id.write({
'project_ids' : [(4, task.project_id.id)]
})
else:
stage_id = self.env['project.task.type'].search([
('name','=','Awaiting Internal')],limit=1)
record_id = self.env['project.task'].browse(self._context.get('active_id'))
task_id = self.env['project.task'].create({
'name': task.name or '',
'stage_id' : stage_id.id,
'project_id': task.project_id.id,
'task_product_id' : task.product_id.id,
'user_ids' : task.user_ids.ids,
'date_deadline' : task.date,
})
task.product_id.write({
'task_ids' : [(4,task_id.id)],
'project_id' : task.project_id.id
})
project_ids = stage_id.mapped('project_ids')
if task.project_id not in project_ids:
stage_id.write({
'project_ids' : [(4, task.project_id.id)]
})
return True
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="task_create_form">
<field name="name">sale.task.create.form</field>
<field name="model">sale.task.create</field>
<field name="arch" type="xml">
<form string="Add a Task">
<sheet>
<group>
<group>
<field name="order_true" invisible="1"/>
<field name="product_id" invisible="1"/>
<field name="order_id" invisible="1"/>
<field name="name" required="1"/>
<field name="user_ids" required="1" widget="many2many_avatar_user"/>
<field name="date" required="1"/>
<field name="project_id" required="1"/>
</group>
</group>
</sheet>
<footer>
<button name="add_a_task" string="Save &amp; Close" type="object" class="btn btn-primary"/>
<button name="save_nd_edit" string="Save &amp; Edit" type="object" class="btn btn-primary" style="float:center;"/>
<button name="save_nd_new" string="Save &amp; New" type="object" class="btn btn-primary" style="float:right;"/>
</footer>
</form>
</field>
</record>
<record id="action_task_create_create" model="ir.actions.act_window">
<field name="name">Add a Task</field>
<field name="res_model">sale.task.create</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</data>
</odoo>
@@ -0,0 +1,64 @@
# -*- coding: utf-8 -*-
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, tools, _
class MassUpdateTaskWizard(models.TransientModel):
_name='mass.update.task.wiz'
_description = "Mass Update Task"
change_project = fields.Boolean('Change Project')
project_id = fields.Many2one(comodel_name='project.project', string='Select Project')
change_deadline = fields.Boolean('Change Deadline')
new_date_deadline = fields.Date(string='New Date Deadline')
change_stage = fields.Boolean('Change Stage')
new_stage = fields.Many2one('project.task.type', 'Select New Stage')
change_assignees = fields.Boolean('Change Assignees')
update_assignees_via = fields.Selection([('add', 'Add'), ('replace', 'Replace')], 'Update Via')
assignees_ids = fields.Many2many('res.users', 'wiz_assignees_rel')
change_tag = fields.Boolean('Change Tag')
update_tag_via = fields.Selection([('add', 'Add'), ('replace', 'Replace')], 'Update Via ')
tags = fields.Many2many('project.tags', 'wiz_tags_rel')
def update_values(self):
if self._context.get('active_model') == 'project.task':
all_task_ids = self.env['project.task'].browse(self._context.get('active_ids'))
for obj in all_task_ids:
if self.change_project:
obj.project_id = self.project_id.id
if self.change_deadline:
obj.date_deadline = self.new_date_deadline
if self.change_stage:
obj.stage_id = self.new_stage.id
if self.change_tag:
if self.update_tag_via == 'add':
obj.tag_ids = [(4, i) for i in self.tags.ids]
if self.update_tag_via == 'replace':
obj.tag_ids = [(6, 0, self.tags.ids) or []]
if self.change_assignees:
if self.update_assignees_via == 'add':
obj.user_ids = [(4, i) for i in self.assignees_ids.ids]
if self.update_assignees_via == 'replace':
obj.user_ids = [(6, 0, self.assignees_ids.ids) or []]
return True
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="mass_update_task_wiz_form_view" model="ir.ui.view">
<field name="name">mass.update.task.wiz.form.view</field>
<field name="model">mass.update.task.wiz</field>
<field name="arch" type="xml">
<form string="Mass update Task">
<group>
<group>
<field name="change_project"/>
<field name="project_id" invisible= "not change_project"/>
</group>
<group>
<field name="change_deadline"/>
<field name="new_date_deadline" invisible=" not change_deadline"/>
</group>
<group>
<field name="change_stage"/>
<field name="new_stage" invisible=" not change_stage"/>
</group>
<group>
<field name="change_tag"/>
<field name="update_tag_via" invisible=" not change_tag" required= "change_tag"/>
<field name="tags" widget="many2many_tags" invisible="not change_tag" required="change_tag"/>
</group>
<group>
<field name="change_assignees"/>
<field name="update_assignees_via" invisible="not change_assignees" required="change_assignees"/>
<field name="assignees_ids" widget="many2many_tags" invisible="not change_assignees" required="change_assignees"/>
</group>
</group>
<footer>
<button name="update_values" string="Update" type="object" class="btn-primary"/>
<button string="Cancel" class="btn-default" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_mass_update_task" model="ir.actions.act_window">
<field name="name">Mass Update Task</field>
<field name="res_model">mass.update.task.wiz</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="project.model_project_task"/>
<field name="binding_view_types">list</field>
</record>
</data>
</odoo>
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Part of BrowseInfo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _
from odoo.exceptions import UserError, RedirectWarning, ValidationError
class MassUpdateProjectStages(models.TransientModel):
_name = 'mass.update.project.stage'
_description = 'Mass Update Project Stages'
is_update = fields.Boolean(string="Mass Update Project",default=False)
project_ids = fields.Many2many('project.project',string='Project')
project_update_method = fields.Selection(
[('add', 'Add'), ('replace', 'Replace')], 'Project Update Method', default='add',
required=True)
def update_project_stage(self):
active_ids = self._context.get('active_ids', [])
project_ids = self.env['project.task.type'].browse(active_ids)
for project in project_ids:
if self.is_update == True:
if self.project_update_method == 'add':
project.project_ids = [(4, update_project) for update_project in self.project_ids.ids]
if self.project_update_method == 'replace':
project.project_ids = [(6, 0, self.project_ids.ids) or []]
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record id="view_sale_advance_payment_inv" model="ir.ui.view">
<field name="name">Mass Update Project Stages</field>
<field name="model">mass.update.project.stage</field>
<field name="arch" type="xml">
<form string="Mass Update Project Stages">
<group>
<field name="is_update"/>
<field name="project_update_method" class="oe_inline" widget="radio"
invisible="not is_update"/>
<field name="project_ids" invisible="not is_update" widget="many2many_tags"/>
</group>
<footer>
<button name="update_project_stage" string="Update" type="object" class="btn-primary" />
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
<record id="action_view_sale_advance_payment_inv" model="ir.actions.act_window">
<field name="name">Mass Update Project Stages</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">mass.update.project.stage</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="project.model_project_task_type"/>
<field name="binding_view_types">list</field>
</record>
</odoo>