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

[IMP] sale_order_renovate_event: Poner nombre al contrato. #342

Open
wants to merge 1 commit into
base: 8.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sale_order_renovate_event/__openerp__.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@
"category": "Human Resources",
"depends": [
"sale_order_renovate_contract",
"sale_order_create_event"
"sale_order_create_event",
"calendar_holiday"
],
"data": [
"data/sale_order_renovate_event_data.xml",
1 change: 1 addition & 0 deletions sale_order_renovate_event/models/__init__.py
Original file line number Diff line number Diff line change
@@ -2,3 +2,4 @@
# (c) 2017 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import sale_order
from . import hr_contract
36 changes: 36 additions & 0 deletions sale_order_renovate_event/models/hr_contract.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# (c) 2017 Alfredo de la Fuente - AvanzOSC
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import models, fields, api


class HrContract(models.Model):
_inherit = 'hr.contract'

@api.multi
def automatic_process_generate_calendar(self):
print ('11111111111111 inicio tratamiento')
cron_renovate_event_contract = self.env.ref(
'sale_order_renovate_event.ir_cron_renovate_contract_event_action')
cron_renovate_event_contract.active = False
self.env.cr.commit()
contract_obj = self.env['hr.contract']
date_begin = '{}-01-01'.format(fields.Date.from_string(
fields.Date.today()).year)
date_begin = '2022-01-01'
cond = ['|', ('date_end', '=', False),
('date_end', '>=', date_begin)]
contracts = contract_obj.search(cond)
contador = 0
for contract in contracts:
contador += 1
print ('11111 trato contrato: ' + str(contador) + ', de: ' + str(len(contracts)) + ', id contrato: ' + str(contract.id))
contract._generate_calendar_from_wizard(
2022)
# fields.Date.from_string(fields.Date.today()).year)
print ('111111 contador: ' + str(contador))
print ('111111 total contratos: ' + str(len(contracts)))
if contador > 0 and contador == len(contracts):
print ('111 entro en if')
cron_renovate_event_contract.active = True
print ('1111111111111111111 fin del tratamiento')
15 changes: 12 additions & 3 deletions sale_order_renovate_event/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -13,8 +13,9 @@ class SaleOrder(models.Model):
@api.multi
def automatic_renovate_contract_event(self):
sale_orders = self.env['sale.order']
date = '{}-12-31'.format(
int(fields.Date.from_string(fields.Date.today()).year)-1)
# date = '{}-12-31'.format(
# int(fields.Date.from_string(fields.Date.today()).year)-1)
date = '2021-12-31'
cond = [('project_id', '!=', False),
('project_id.state', '=', 'open'),
('project_id.type', '=', 'contract'),
@@ -35,7 +36,15 @@ def automatic_renovate_contract_event(self):
('order_line', '!=', False)]
new_sale = self.env['sale.order'].search(cond, limit=1)
new_sale.action_button_confirm()
if new_sale.project_id:
year = int(fields.Date.from_string(
new_sale.project_id.date_start).year)
new_sale.project_id.name = u'{} {}'.format(
new_sale.project_id.partner_id.name, year)
cond = [('analytic_account_id', '=', new_sale.project_id.id)]
project = self.env['project.project'].search(cond, limit=1)
if project:
project.name = new_sale.project_id.name
sale.generated_next_year = True
# self.env.cr.commit()
except Exception:
continue