Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #56

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open

Dev #56

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5783121
Add link to Technical Training for Odoo 16.0
nim-odoo Sep 10, 2018
99c900b
test
Akalai21 Jan 2, 2023
304f0fc
test
Akalai21 Jan 2, 2023
80f3f70
change estate folder
Akalai21 Jan 6, 2023
879e857
Add fields employee
Akalai21 Jan 6, 2023
f261671
Test creation employee
Akalai21 Jan 6, 2023
38bab65
test_v1
Akalai21 Jan 6, 2023
ab58b4f
test_v2
Akalai21 Jan 6, 2023
7f5c451
test_v3
Akalai21 Jan 6, 2023
5d3f3f8
test_v4
Akalai21 Jan 6, 2023
0fb6a0f
test_v5
Akalai21 Jan 6, 2023
cb2f97b
Project clean base
Akalai21 Jan 6, 2023
740a9f9
add employee
Akalai21 Jan 6, 2023
022ec2a
add employee_v2
Akalai21 Jan 6, 2023
03e8c9f
test_v6
Akalai21 Jan 6, 2023
3e010b2
project base_v2
Akalai21 Jan 6, 2023
30e5c93
first question
Akalai21 Jan 6, 2023
c76bc27
first question_v2
Akalai21 Jan 6, 2023
3468815
answer of question2
mbensafia Jan 6, 2023
8e79014
question2_test
mbensafia Jan 6, 2023
63fcf13
Update res_partner.xml
mbensafia Jan 6, 2023
563ee9a
update_pagesXML
mbensafia Jan 6, 2023
8f07ff1
add sale order limit
mbensafia Jan 6, 2023
9e77fca
Update sale_order.py
mbensafia Jan 7, 2023
bc50071
Update res_partner.xml
mbensafia Jan 7, 2023
44cd133
Update sale_order.py
mbensafia Jan 7, 2023
0f9e8da
updatefiles_test
mbensafia Jan 7, 2023
4a83acf
question4_test
mbensafia Jan 7, 2023
ca0e1f0
update_sale_order
mbensafia Jan 7, 2023
92a1f8d
Update sale_order.py
mbensafia Jan 7, 2023
bcaed6b
Update sale_order.xml
mbensafia Jan 7, 2023
85ad19a
Update sale_order.xml
mbensafia Jan 7, 2023
76420ef
add_incrementation_index
mbensafia Jan 7, 2023
b197789
Update sale_order_line.py
mbensafia Jan 7, 2023
0b0cc05
add_wizard_training_date
mbensafia Jan 7, 2023
c5e3f44
update_wizard
mbensafia Jan 7, 2023
5983fe1
Update __manifest__.py
mbensafia Jan 7, 2023
7ce8cb8
Update __manifest__.py
mbensafia Jan 7, 2023
cdbce0b
update_date_wizard
mbensafia Jan 7, 2023
5ffef41
update_ wizard
mbensafia Jan 7, 2023
94b19fc
update_wizardViews
mbensafia Jan 7, 2023
89e0d9b
Update training_date_wizard_form_view.xml
mbensafia Jan 7, 2023
9b62951
Update training_date_wizard_form_view.xml
mbensafia Jan 7, 2023
46bd1d5
Update training_date_wizard_form_view.xml
mbensafia Jan 7, 2023
f850b8f
Final_Version_Project
mbensafia Jan 7, 2023
a6f1988
update
mbensafia Jan 7, 2023
b903921
Last_version
mbensafia Jan 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Empty file modified .gitignore
100644 → 100755
Empty file.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Odoo 12.0 - Technical Training
# Odoo 16.0 - Technical Training

The Technical Training of Odoo 16.0 is available on the
[Tutorial](https://www.odoo.com/documentation/master/developer/howtos/rdtraining.html)
3 changes: 3 additions & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-

from . import models
12 changes: 12 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
{
'name': "helb_project",
'summary': """Project for HELB Student""",
'author': "My Company",
'website': "http://www.yourcompany.com",
'category': 'Uncategorized',
'version': '15.0.0.1',
'license' : 'LGPL-3',
'depends': ['base', 'sale_management', 'calendar', 'hr'],
'data': ["views/res_groups.xml", "views/res_partner.xml", "views/sale_order.xml", "views/training_date_wizard_form_view.xml"]
}
6 changes: 6 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-

from . import sale_order_line
from . import sale_order
from . import res_groups
from . import res_partner
6 changes: 6 additions & 0 deletions estate/models/res_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from odoo import fields, models

class ResGroups(models.Model):
_inherit = 'res.groups' #The _inherit attribute specifies that this model will inherit all the fields and behavior of the res.groups model, and add some new functionality to it.
max_amount = fields.Float(string="Training max price approval") #The max_amount field is a new field that is being added to the ResGroups model. It is a floating point field that will store a value representing the maximum price for which training approval is required. The field has a string attribute, "Training max price approval", which will be used as the label for this field in the user interface.

5 changes: 5 additions & 0 deletions estate/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from odoo import fields, models

class ResPartner(models.Model):
_inherit = 'res.partner' # The _inherit attribute specifies that this model will inherit all the fields and behavior of the res.partner model, and add some new functionality to it.
# max_amount = fields.Float(string="Maximum allowed amount") #The max_amount field is a new field that is being added to the ResPartner model. It is a floating point field that will store a value representing the maximum allowed amount. The field has a string attribute, "Maximum allowed amount", which will be used as the label for this field in the user interface.
85 changes: 85 additions & 0 deletions estate/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from odoo import api, models, _, fields
from odoo.exceptions import ValidationError

class SaleOrder(models.Model):
_inherit = 'sale.order'
#This method checks if the total amount of a sale order exceeds the maximum allowed for the partner. It is currently commented out and will not be used unless the # characters at the beginning of the lines are removed.

# def check_max_amount(self):
# for order in self:
# max_amount = order.partner_id.max_amount
# if max_amount:
# total_amount = sum(line.price_total for line in order.order_line)
# if total_amount > max_amount:
# raise ValidationError(_("The total amount of this sale order exceeds the maximum allowed for the partner."))

# # 56

#This method overrides the base create() method for sale orders and calls the check_max_amount() method after the sale order is created.
# def create(self, vals):
# order = super().create(vals)
# order.check_max_amount()
# return order

# This method overrides the base write() method for sale orders and calls the check_max_amount() method after the sale order is modified.
# def write(self, vals):
# res = super().write(vals)
# self.check_max_amount()
# return res


# This method overrides the base action_confirm() method for sale orders, and adds additional functionality to it. When a sale order is confirmed, the method creates calendar events for training sessions based on the training dates and employees specified in the sale order lines.
def action_confirm(self):
res = super(SaleOrder, self).action_confirm()
for order in self:
for line in order.order_line:
if line.training_dates and line.employee_id:
self.env['calendar.event'].create({
'name': 'Training session',
'start_date': line.training_dates,
'stop_date': line.training_dates + timedelta(hours=1),
'partner_ids': [(4, line.employee_id.id)],
})
return res

#This method is defined twice in the code, with the second definition overwriting the first. The method creates an activity for a manager, requesting approval for a quotation. The manager is either the one with the least approvals waiting to be assigned, or the one with the manageruser user id.
def request_approval(self):
self.ensure_one()
# create an activity for a manager
self.activity_schedule(
'mail.mail_activity_data_todo',
user_id=self.env.ref('my_module.manageruser').id,
note=('Approval needed for quotation %s') % self.name,
)



def request_approval(self):
self.ensure_one()
# get the manager with the least approvals waiting to be assigned
manager = self.env['res.users'].search([('groups_id', '=', self.env.ref('my_module.manager_group').id)],
order='approval_count ASC').id
# create an activity for the selected manager
self.activity_schedule(
'mail.mail_activity_data_todo',
userid=manager,
note=('Approval needed for quotation %s') % self.name,
)

# Add the 'approval_count' field to the SaleOrder model
# This will add an approval_count field to the SaleOrder model, and every time the action_confirm method is called (which happens when the sale order is approved), the approval_count field will be incremented by 1.
class SaleOrder(models.Model):
_inherit = 'sale.order'
approval_count = fields.Integer(string='Approval Count', default=0)

# Increment the 'approval_count' field every time the sale order is approved
def action_confirm(self):
# Call the super method to confirm the sale order
super(SaleOrder, self).action_confirm()
# Increment the 'approval_count' field
self.approval_count += 1





90 changes: 90 additions & 0 deletions estate/models/sale_order_line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
from odoo import fields, models, Command

class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'
training_date = fields.Char(string="Training Date")
employee_id = fields.Many2one('hr.employee', string="Employee")
is_recurring = fields.Boolean(string='Is Recurring')


# # That will open the wizard when clicked,
# <button name="%(training_date_wizard_action)d" string="Choose Training Date" type="action" class="oe_highlight"/>

# Add a selection field to specify the recurrence frequency
recurrence_frequency = fields.Selection([
('daily', 'Daily'),
('weekly', 'Weekly'),
('monthly', 'Monthly'),
('yearly', 'Yearly'),
], string='Recurrence Frequency')

# Add a integer field to specify the number of recurrences
recurrence_count = fields.Integer(string='Recurrence Count')

# Add a method to generate recurring training records

def create_recurring_training(self):
# Iterate through each record
for record in self:
# Check if the training is recurring
if record.is_recurring:
# Calculate the recurrence interval in days based on the frequency
if record.recurrence_frequency == 'daily':
interval = 1
elif record.recurrence_frequency == 'weekly':
interval = 7
elif record.recurrence_frequency == 'monthly':
interval = 30
elif record.recurrence_frequency == 'yearly':
interval = 365

# Generate the recurring training records
for i in range(1, record.recurrence_count+1):
# Create a new training record with the same values as the original record
new_record = record.copy()
# Increment the training date by the recurrence interval
new_record.training_date = fields.Date.from_string(new_record.training_date) + timedelta(days=interval)
# Save the new record
new_record.save()


# This function takes a partner and an amount as inputs, and returns an integer value representing the required approval level for the sale. The value is determined by the amount of the sale, with higher amounts requiring higher approval levels.
def get_approval_level(partner, amount):
if amount < 500:
return 0 # no approval needed
elif amount < 2000:
return 1 # level 1 and above can approve
elif amount < 5000:
return 2 # level 2 and above can approve
else:
return 3 # level 3 and above can approve

#This function takes a manager level as an input and returns a string representing the group that the manager belongs to, based on their level.
def get_manager_group(manager_level):
if manager_level == 0:
return "no approval privileges"
elif manager_level == 1:
return "manager level 1 "
elif manager_level == 2:
return "manager level 2"
else:
return "manager level 3 and above"


#This function takes a partner, an amount, and a manager level as inputs, and uses the get_approval_level() and get_manager_group() functions to determine whether the sale can be confirmed by the manager. If the sale can be confirmed, the function returns True, otherwise it returns False
def can_confirm_sale_order(partner, amount, manager_level):
required_approval_level = get_approval_level(partner, amount)
manager_group = get_manager_group(manager_level)
if required_approval_level <= manager_level:
print(f"Sale order can be confirmed by {manager_group}.")
return True
else:
print(f"Sale order cannot be confirmed by {manager_group}.")
return False

# example usage
partner = "ABC Partners"
amount = 1500
manager_level = 1

can_confirm_sale_order(partner, amount, manager_level)
7 changes: 7 additions & 0 deletions estate/models/training.date.wizard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from odoo import api, fields, models

class TrainingDateWizard(models.TransientModel):
_name = 'training.date.wizard'

# Add a field to hold the selected training date
training_date = fields.Date(string='Training Date')
11 changes: 11 additions & 0 deletions estate/odoo/.github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Impacted versions:

Steps to reproduce:

Current behavior:

Expected behavior:

Video/Screenshot link (optional):

Support ticket number submitted via odoo.com/help (optional):
11 changes: 11 additions & 0 deletions estate/odoo/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:




---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
49 changes: 49 additions & 0 deletions estate/odoo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# sphinx build directories
_build/

# dotfiles
.*
!.gitignore
!.github
!.mailmap
# compiled python files
*.py[co]
__pycache__/
# setup.py egg_info
*.egg-info
# emacs backup files
*~
# hg stuff
*.orig
status
# odoo filestore
odoo/filestore
# maintenance migration scripts
odoo/addons/base/maintenance

# generated for windows installer?
install/win32/*.bat
install/win32/meta.py

# needed only when building for win32
setup/win32/static/less/
setup/win32/static/wkhtmltopdf/
setup/win32/static/postgresql*.exe

# js tooling
node_modules
jsconfig.json
tsconfig.json
package-lock.json
package.json
.husky

# various virtualenv
/bin/
/build/
/dist/
/include/
/lib/
/man/
/share/
/src/
14 changes: 14 additions & 0 deletions estate/odoo/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Contributing to Odoo
====================

[Full contribution guidelines](https://github.com/odoo/odoo/wiki/Contributing)

TL;DR

* If you [make a pull request](https://github.com/odoo/odoo/wiki/Contributing#making-pull-requests),
do not create an issue! Use the PR description for that
* Issues are handled with a much lower priority than pull requests
* Use this [template](https://github.com/odoo/odoo/tree/16.0/.github/ISSUE_TEMPLATE.md)
when reporting issues. Please search for duplicates first!
* Pull requests must be made against the [correct version](https://github.com/odoo/odoo/wiki/Contributing#against-which-version-should-i-submit-a-patch)
* There are restrictions on the kind of [changes allowed in stable series](https://github.com/odoo/odoo/wiki/Contributing#what-does-stable-mean)
15 changes: 15 additions & 0 deletions estate/odoo/COPYRIGHT
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

Most of the files are

Copyright (c) 2004-2015 Odoo S.A.

Many files also contain contributions from third
parties. In this case the original copyright of
the contributions can be traced through the
history of the source version control system.

When that is not the case, the files contain a prominent
notice stating the original copyright and applicable
license, or come with their own dedicated COPYRIGHT
and/or LICENSE file.

Loading