Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
odoo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cooperatic-foodcoops
odoo
Commits
18714da9
Commit
18714da9
authored
Sep 08, 2021
by
François C.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout cron fin extension si à jour
parent
866532a2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
__openerp__.py
lacagette_addons/lacagette_membership/__openerp__.py
+1
-1
ir_cron.xml
lacagette_addons/lacagette_membership/data/ir_cron.xml
+5
-6
res_partner.py
lacagette_addons/lacagette_membership/models/res_partner.py
+18
-0
No files found.
lacagette_addons/lacagette_membership/__openerp__.py
View file @
18714da9
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
#
#
'category'
:
'Uncategorized'
,
'category'
:
'Uncategorized'
,
'version'
:
'0.0.
2
'
,
'version'
:
'0.0.
3
'
,
# any module necessary for this one to work correctly
# any module necessary for this one to work correctly
'depends'
:
[
'base'
,
'coop_shift'
],
'depends'
:
[
'base'
,
'coop_shift'
],
...
...
lacagette_addons/lacagette_membership/data/ir_cron.xml
View file @
18714da9
...
@@ -5,16 +5,15 @@
...
@@ -5,16 +5,15 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
-->
<odoo>
<odoo>
<record
forcecreate=
"True"
id=
"cron_
ending_abcd_shift_preiod
"
model=
"ir.cron"
>
<record
forcecreate=
"True"
id=
"cron_
close_unnecessary_extensions
"
model=
"ir.cron"
>
<field
name=
"name"
>
Ending ABCD shift period
</field>
<field
name=
"name"
>
Close unnecessary Extensions
</field>
<field
name=
"user_id"
ref=
"base.user_root"
/>
<field
name=
"user_id"
ref=
"base.user_root"
/>
<field
name=
"interval_number"
>
1
</field>
<field
name=
"interval_number"
>
1
</field>
<field
name=
"interval_type"
>
days
</field>
<field
name=
"interval_type"
>
days
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"nextcall"
eval=
"(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 20:00:00')"
/>
<field
name=
"doall"
eval=
"True"
/>
<field
name=
"doall"
eval=
"False"
/>
<field
name=
"model"
eval=
"'res.partner'"
/>
<field
name=
"model"
eval=
"'shift.registration'"
/>
<field
name=
"function"
eval=
"'run_close_unnecessary_opened_extensions'"
/>
<field
name=
"function"
eval=
"'send_shift_missing_emails'"
/>
<field
name=
"args"
eval=
"'()'"
/>
<field
name=
"args"
eval=
"'()'"
/>
<field
name=
"active"
eval=
"False"
/>
<field
name=
"active"
eval=
"False"
/>
<field
name=
"priority"
>
2
</field>
<field
name=
"priority"
>
2
</field>
...
...
lacagette_addons/lacagette_membership/models/res_partner.py
View file @
18714da9
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from
openerp
import
_
,
api
,
models
,
fields
from
openerp
import
_
,
api
,
models
,
fields
import
datetime
class
ResPartner
(
models
.
Model
):
class
ResPartner
(
models
.
Model
):
_inherit
=
'res.partner'
_inherit
=
'res.partner'
...
@@ -11,3 +12,20 @@ class ResPartner(models.Model):
...
@@ -11,3 +12,20 @@ class ResPartner(models.Model):
default
=
0
)
default
=
0
)
#@api.onchange('cooperativestate') : could be used only if it is called from client
@api.model
def
run_close_unnecessary_opened_extensions
(
self
):
"""Method called by cron task"""
sql
=
"""
SELECT s.id
FROM shift_extension as s
WHERE s.date_stop > now()
AND partner_id IN (SELECT id FROM res_partner WHERE cooperative_state='up_to_date')
"""
self
.
env
.
cr
.
execute
(
sql
)
extension_ids
=
self
.
env
.
cr
.
fetchall
()
if
len
(
extension_ids
)
>
0
:
extension_model
=
self
.
env
[
'shift.extension'
]
today
=
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
d"
)
for
ext
in
extension_model
.
search
([(
'id'
,
'in'
,
extension_ids
)]):
ext
.
update
({
'date_stop'
:
today
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment