[MERGE]Lunch_new application
bzr revid: api@openerp.com-20121024142025-ihjkfieq5tj829jw
This commit is contained in:
parent
ccdec6f158
commit
0ac6c9eff2
|
@ -21,10 +21,4 @@
|
|||
|
||||
import lunch
|
||||
import partner
|
||||
import wizard
|
||||
import lunch_preference
|
||||
import lunch_product
|
||||
import lunch_alert
|
||||
import lunch_cashmove
|
||||
import lunch_order_line
|
||||
import report
|
|
@ -32,7 +32,7 @@ The base module to manage lunch.
|
|||
keep track for the Lunch Order, Cash Moves and Product. Apply Different
|
||||
Category for the product.
|
||||
""",
|
||||
'data': ['security/groups.xml','view/lunch_view.xml','view/partner_view.xml','wizard/lunch_validation_view.xml','wizard/lunch_cancel_view.xml','lunch_report.xml',
|
||||
'data': ['security/groups.xml','view/lunch_view.xml','view/partner_view.xml','view/lunch_validation_view.xml','view/lunch_cancel_view.xml','lunch_report.xml',
|
||||
'report/report_lunch_order_view.xml',
|
||||
'security/ir.model.access.csv',],
|
||||
'demo': ['lunch_demo.xml',],
|
||||
|
|
|
@ -246,3 +246,228 @@ class lunch_order(osv.Model):
|
|||
'preferences': _default_preference_get,
|
||||
}
|
||||
|
||||
class lunch_order_line(osv.Model): #define each product that will be in one ORDER.
|
||||
""" lunch order line """
|
||||
_name = 'lunch.order.line'
|
||||
_description = 'lunch order line'
|
||||
|
||||
def _price_get(self,cr,uid,ids,name,arg,context=None):
|
||||
orderLines = self.browse(cr,uid,ids,context=context)
|
||||
result={}
|
||||
for orderLine in orderLines:
|
||||
result[orderLine.id]=orderLine.product.price
|
||||
return result
|
||||
|
||||
def onchange_price(self,cr,uid,ids,product,context=None):
|
||||
if product:
|
||||
price = self.pool.get('lunch.product').read(cr, uid, product, ['price'])['price']
|
||||
return {'value': {'price': price}}
|
||||
return {'value': {'price': 0.0}}
|
||||
|
||||
|
||||
def confirm(self,cr,uid,ids,context=None):
|
||||
#confirm one or more order.line, update order status and create new cashmove
|
||||
cashmove_ref = self.pool.get('lunch.cashmove')
|
||||
orders_ref = self.pool.get('lunch.order')
|
||||
|
||||
for order in self.browse(cr,uid,ids,context=context):
|
||||
if order.state!='confirmed':
|
||||
new_id = cashmove_ref.create(cr,uid,{'user_id': order.user_id.id, 'amount':0 - order.price,'description':order.product.name, 'order_id':order.id, 'state':'order', 'date':order.date})
|
||||
self.write(cr,uid,[order.id],{'cashmove':[('0',new_id)], 'state':'confirmed'},context)
|
||||
for order in self.browse(cr,uid,ids,context=context):
|
||||
isconfirmed = True
|
||||
for product in order.order_id.products:
|
||||
if product.state == 'new':
|
||||
isconfirmed = False
|
||||
if product.state == 'cancelled':
|
||||
isconfirmed = False
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'partially'},context)
|
||||
if isconfirmed == True:
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'confirmed'},context)
|
||||
return {}
|
||||
|
||||
def cancel(self,cr,uid,ids,context=None):
|
||||
#confirm one or more order.line, update order status and create new cashmove
|
||||
cashmove_ref = self.pool.get('lunch.cashmove')
|
||||
orders_ref = self.pool.get('lunch.order')
|
||||
|
||||
for order in self.browse(cr,uid,ids,context=context):
|
||||
self.write(cr,uid,[order.id],{'state':'cancelled'},context)
|
||||
for cash in order.cashmove:
|
||||
cashmove_ref.unlink(cr,uid,cash.id,context)
|
||||
for order in self.browse(cr,uid,ids,context=context):
|
||||
hasconfirmed = False
|
||||
hasnew = False
|
||||
for product in order.order_id.products:
|
||||
if product.state=='confirmed':
|
||||
hasconfirmed= True
|
||||
if product.state=='new':
|
||||
hasnew= True
|
||||
if hasnew == False:
|
||||
if hasconfirmed == False:
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'cancelled'},context)
|
||||
return {}
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'partially'},context)
|
||||
return {}
|
||||
|
||||
_columns = {
|
||||
'date' : fields.related('order_id','date',type='date', string="Date", readonly=True,store=True),
|
||||
'supplier' : fields.related('product','supplier',type='many2one',relation='res.partner',string="Supplier",readonly=True,store=True),
|
||||
'user_id' : fields.related('order_id', 'user_id', type='many2one', relation='res.users', string='User', readonly=True, store=True),
|
||||
'product' : fields.many2one('lunch.product','Product',required=True), #one offer can have more than one product and one product can be in more than one offer.
|
||||
'note' : fields.text('Note',size=256,required=False),
|
||||
'order_id' : fields.many2one('lunch.order','Order',ondelete='cascade'),
|
||||
'price' : fields.function(_price_get, string="Price",store=True),
|
||||
'state': fields.selection([('new', 'New'),('confirmed','Confirmed'), ('cancelled','Cancelled')], \
|
||||
'Status', readonly=True, select=True),
|
||||
'cashmove': fields.one2many('lunch.cashmove','order_id','Cash Move',ondelete='cascade'),
|
||||
|
||||
}
|
||||
_defaults = {
|
||||
'state': lambda self, cr, uid, context: 'new',
|
||||
}
|
||||
|
||||
class lunch_preference(osv.Model):
|
||||
_name = 'lunch.preference'
|
||||
_description= "user preferences"
|
||||
|
||||
def onclick_preference(self,cr,uid,ids,context=None):
|
||||
print cr
|
||||
print uid
|
||||
print ids
|
||||
print context
|
||||
print self.pool.get('lunch.preference').browse(cr,uid,ids,context)[0]['product_name']
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
'date' : fields.date('Date', required=True,readonly=True),
|
||||
'color': fields.integer('Color'),
|
||||
'user_id' : fields.many2one('res.users','User Name',required=True,readonly=True),
|
||||
'product' : fields.many2one('lunch.product','Product',required=True),
|
||||
'product_name' : fields.char('Product name',size=64),
|
||||
'note' : fields.text('Note',size=256,required=False),
|
||||
'price' : fields.float('Price',digits=(16,2)),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'color': 1,
|
||||
}
|
||||
|
||||
class lunch_product(osv.Model):
|
||||
""" lunch product """
|
||||
_name = 'lunch.product'
|
||||
_description = 'lunch product'
|
||||
_columns = {
|
||||
'name' : fields.char('Product',required=True, size=64),
|
||||
'category_id': fields.many2one('lunch.product.category', 'Category'),
|
||||
'description': fields.text('Description', size=256, required=False),
|
||||
'price': fields.float('Price', digits=(16,2)),
|
||||
'active': fields.boolean('Active'), #If this product isn't offered anymore, the active boolean is set to false. This will allow to keep trace of previous orders and cashmoves.
|
||||
'supplier' : fields.many2one('res.partner','Supplier',required=True, domain=[('supplier_lunch','=',True)]),
|
||||
}
|
||||
|
||||
class lunch_product_category(osv.Model):
|
||||
""" lunch product category """
|
||||
_name = 'lunch.product.category'
|
||||
_description = 'lunch product category'
|
||||
_columns = {
|
||||
'name' : fields.char('Category', required=True, size=64), #such as PIZZA, SANDWICH, PASTA, CHINESE, BURGER, ...
|
||||
}
|
||||
|
||||
class lunch_cashmove(osv.Model):
|
||||
""" lunch cashmove => order or payment """
|
||||
_name = 'lunch.cashmove'
|
||||
_description = 'lunch cashmove'
|
||||
_columns = {
|
||||
'user_id' : fields.many2one('res.users','User Name',required=True),
|
||||
'date' : fields.date('Date', required=True),
|
||||
'amount' : fields.float('Amount', required=True), #depending on the kind of cashmove, the amount will be positive or negative
|
||||
'description' : fields.text('Description',size=256), #the description can be an order or a payment
|
||||
'order_id' : fields.many2one('lunch.order.line','Order',required=False,ondelete='cascade'),
|
||||
'state' : fields.selection([('order','Order'),('payment','Payment')],'Is an order or a Payment'),
|
||||
}
|
||||
_defaults = {
|
||||
'user_id': lambda self, cr, uid, context: uid,
|
||||
'date': fields.date.context_today,
|
||||
'state': lambda self, cr, uid, context: 'payment',
|
||||
}
|
||||
|
||||
class lunch_alert(osv.Model):
|
||||
""" lunch alert """
|
||||
_name = 'lunch.alert'
|
||||
_description = 'lunch alert'
|
||||
_columns = {
|
||||
'message' : fields.text('Message',size=256, required=True),
|
||||
'active' : fields.boolean('Active'),
|
||||
'day' : fields.selection([('specific','Specific day'), ('week','Every Week'), ('days','Every Day')], 'Recurrency'),
|
||||
'specific' : fields.date('Day'),
|
||||
'monday' : fields.boolean('Monday'),
|
||||
'tuesday' : fields.boolean('Tuesday'),
|
||||
'wednesday' : fields.boolean('Wednesday'),
|
||||
'thursday' : fields.boolean('Thursday'),
|
||||
'friday' : fields.boolean('Friday'),
|
||||
'saturday' : fields.boolean('Saturday'),
|
||||
'sunday' : fields.boolean('Sunday'),
|
||||
'active_from': fields.float('Between',required=True),
|
||||
'active_to': fields.float('And',required=True),
|
||||
}
|
||||
|
||||
class lunch_cancel(osv.Model):
|
||||
""" lunch cancel """
|
||||
_name = 'lunch.cancel'
|
||||
_description = 'cancel lunch order'
|
||||
|
||||
def cancel(self,cr,uid,ids,context=None):
|
||||
#confirm one or more order.line, update order status and create new cashmove
|
||||
cashmove_ref = self.pool.get('lunch.cashmove')
|
||||
order_lines_ref = self.pool.get('lunch.order.line')
|
||||
orders_ref = self.pool.get('lunch.order')
|
||||
order_ids = context.get('active_ids', [])
|
||||
|
||||
for order in order_lines_ref.browse(cr,uid,order_ids,context=context):
|
||||
order_lines_ref.write(cr,uid,[order.id],{'state':'cancelled'},context)
|
||||
for cash in order.cashmove:
|
||||
cashmove_ref.unlink(cr,uid,cash.id,context)
|
||||
for order in order_lines_ref.browse(cr,uid,order_ids,context=context):
|
||||
hasconfirmed = False
|
||||
hasnew = False
|
||||
for product in order.order_id.products:
|
||||
if product.state=='confirmed':
|
||||
hasconfirmed= True
|
||||
if product.state=='new':
|
||||
hasnew= True
|
||||
if hasnew == False:
|
||||
if hasconfirmed == False:
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'cancelled'},context)
|
||||
return {}
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'partially'},context)
|
||||
return {}
|
||||
|
||||
class lunch_validation(osv.Model):
|
||||
""" lunch validation """
|
||||
_name = 'lunch.validation'
|
||||
_description = 'lunch validation for order'
|
||||
|
||||
def confirm(self,cr,uid,ids,context=None):
|
||||
#confirm one or more order.line, update order status and create new cashmove
|
||||
cashmove_ref = self.pool.get('lunch.cashmove')
|
||||
order_lines_ref = self.pool.get('lunch.order.line')
|
||||
orders_ref = self.pool.get('lunch.order')
|
||||
order_ids = context.get('active_ids', [])
|
||||
|
||||
for order in order_lines_ref.browse(cr,uid,order_ids,context=context):
|
||||
if order.state!='confirmed':
|
||||
new_id = cashmove_ref.create(cr,uid,{'user_id': order.user_id.id, 'amount':0 - order.price,'description':order.product.name, 'order_id':order.id, 'state':'order', 'date':order.date})
|
||||
order_lines_ref.write(cr,uid,[order.id],{'cashmove':[('0',new_id)], 'state':'confirmed'},context)
|
||||
for order in order_lines_ref.browse(cr,uid,order_ids,context=context):
|
||||
isconfirmed = True
|
||||
for product in order.order_id.products:
|
||||
if product.state == 'new':
|
||||
isconfirmed = False
|
||||
if product.state == 'cancelled':
|
||||
isconfirmed = False
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'partially'},context)
|
||||
if isconfirmed == True:
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'confirmed'},context)
|
||||
return {}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import addons
|
||||
import tools
|
||||
import pytz
|
||||
import time
|
||||
from osv import osv, fields
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
class lunch_alert(osv.Model):
|
||||
""" lunch alert """
|
||||
_name = 'lunch.alert'
|
||||
_description = 'lunch alert'
|
||||
_columns = {
|
||||
'message' : fields.text('Message',size=256, required=True),
|
||||
'active' : fields.boolean('Active'),
|
||||
'day' : fields.selection([('specific','Specific day'), ('week','Every Week'), ('days','Every Day')], 'Recurrency'),
|
||||
'specific' : fields.date('Day'),
|
||||
'monday' : fields.boolean('Monday'),
|
||||
'tuesday' : fields.boolean('Tuesday'),
|
||||
'wednesday' : fields.boolean('Wednesday'),
|
||||
'thursday' : fields.boolean('Thursday'),
|
||||
'friday' : fields.boolean('Friday'),
|
||||
'saturday' : fields.boolean('Saturday'),
|
||||
'sunday' : fields.boolean('Sunday'),
|
||||
'active_from': fields.float('Between',required=True),
|
||||
'active_to': fields.float('And',required=True),
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import addons
|
||||
import tools
|
||||
import pytz
|
||||
import time
|
||||
from osv import osv, fields
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
class lunch_cashmove(osv.Model):
|
||||
""" lunch cashmove => order or payment """
|
||||
_name = 'lunch.cashmove'
|
||||
_description = 'lunch cashmove'
|
||||
_columns = {
|
||||
'user_id' : fields.many2one('res.users','User Name',required=True),
|
||||
'date' : fields.date('Date', required=True),
|
||||
'amount' : fields.float('Amount', required=True), #depending on the kind of cashmove, the amount will be positive or negative
|
||||
'description' : fields.text('Description',size=256), #the description can be an order or a payment
|
||||
'order_id' : fields.many2one('lunch.order.line','Order',required=False,ondelete='cascade'),
|
||||
'state' : fields.selection([('order','Order'),('payment','Payment')],'Is an order or a Payment'),
|
||||
}
|
||||
_defaults = {
|
||||
'user_id': lambda self, cr, uid, context: uid,
|
||||
'date': fields.date.context_today,
|
||||
'state': lambda self, cr, uid, context: 'payment',
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
<data noupdate="1">
|
||||
|
||||
<record id="base.user_root" model="res.users">
|
||||
<field name="groups_id" eval="[(4,ref('lunch_new.group_lunch_manager'))]"/>
|
||||
<field name="groups_id" eval="[(4,ref('lunch.group_lunch_manager'))]"/>
|
||||
</record>
|
||||
|
||||
<record model="lunch.product.category" id="categ_sandwich">
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import addons
|
||||
import tools
|
||||
import pytz
|
||||
import time
|
||||
from osv import osv, fields
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
class lunch_order_line(osv.Model): #define each product that will be in one ORDER.
|
||||
""" lunch order line """
|
||||
_name = 'lunch.order.line'
|
||||
_description = 'lunch order line'
|
||||
|
||||
def _price_get(self,cr,uid,ids,name,arg,context=None):
|
||||
orderLines = self.browse(cr,uid,ids,context=context)
|
||||
result={}
|
||||
for orderLine in orderLines:
|
||||
result[orderLine.id]=orderLine.product.price
|
||||
return result
|
||||
|
||||
def onchange_price(self,cr,uid,ids,product,context=None):
|
||||
if product:
|
||||
price = self.pool.get('lunch.product').read(cr, uid, product, ['price'])['price']
|
||||
return {'value': {'price': price}}
|
||||
return {'value': {'price': 0.0}}
|
||||
|
||||
|
||||
def confirm(self,cr,uid,ids,context=None):
|
||||
#confirm one or more order.line, update order status and create new cashmove
|
||||
cashmove_ref = self.pool.get('lunch.cashmove')
|
||||
orders_ref = self.pool.get('lunch.order')
|
||||
|
||||
for order in self.browse(cr,uid,ids,context=context):
|
||||
if order.state!='confirmed':
|
||||
new_id = cashmove_ref.create(cr,uid,{'user_id': order.user_id.id, 'amount':0 - order.price,'description':order.product.name, 'order_id':order.id, 'state':'order', 'date':order.date})
|
||||
self.write(cr,uid,[order.id],{'cashmove':[('0',new_id)], 'state':'confirmed'},context)
|
||||
for order in self.browse(cr,uid,ids,context=context):
|
||||
isconfirmed = True
|
||||
for product in order.order_id.products:
|
||||
if product.state == 'new':
|
||||
isconfirmed = False
|
||||
if product.state == 'cancelled':
|
||||
isconfirmed = False
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'partially'},context)
|
||||
if isconfirmed == True:
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'confirmed'},context)
|
||||
return {}
|
||||
|
||||
def cancel(self,cr,uid,ids,context=None):
|
||||
#confirm one or more order.line, update order status and create new cashmove
|
||||
cashmove_ref = self.pool.get('lunch.cashmove')
|
||||
orders_ref = self.pool.get('lunch.order')
|
||||
|
||||
for order in self.browse(cr,uid,ids,context=context):
|
||||
self.write(cr,uid,[order.id],{'state':'cancelled'},context)
|
||||
for cash in order.cashmove:
|
||||
cashmove_ref.unlink(cr,uid,cash.id,context)
|
||||
for order in self.browse(cr,uid,ids,context=context):
|
||||
hasconfirmed = False
|
||||
hasnew = False
|
||||
for product in order.order_id.products:
|
||||
if product.state=='confirmed':
|
||||
hasconfirmed= True
|
||||
if product.state=='new':
|
||||
hasnew= True
|
||||
if hasnew == False:
|
||||
if hasconfirmed == False:
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'cancelled'},context)
|
||||
return {}
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'partially'},context)
|
||||
return {}
|
||||
|
||||
_columns = {
|
||||
'date' : fields.related('order_id','date',type='date', string="Date", readonly=True,store=True),
|
||||
'supplier' : fields.related('product','supplier',type='many2one',relation='res.partner',string="Supplier",readonly=True,store=True),
|
||||
'user_id' : fields.related('order_id', 'user_id', type='many2one', relation='res.users', string='User', readonly=True, store=True),
|
||||
'product' : fields.many2one('lunch.product','Product',required=True), #one offer can have more than one product and one product can be in more than one offer.
|
||||
'note' : fields.text('Note',size=256,required=False),
|
||||
'order_id' : fields.many2one('lunch.order','Order',ondelete='cascade'),
|
||||
'price' : fields.function(_price_get, string="Price",store=True),
|
||||
'state': fields.selection([('new', 'New'),('confirmed','Confirmed'), ('cancelled','Cancelled')], \
|
||||
'Status', readonly=True, select=True),
|
||||
'cashmove': fields.one2many('lunch.cashmove','order_id','Cash Move',ondelete='cascade'),
|
||||
|
||||
}
|
||||
_defaults = {
|
||||
'state': lambda self, cr, uid, context: 'new',
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import addons
|
||||
import tools
|
||||
import pytz
|
||||
import time
|
||||
from osv import osv, fields
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
class lunch_preference(osv.Model):
|
||||
_name = 'lunch.preference'
|
||||
_description= "user preferences"
|
||||
|
||||
def onclick_preference(self,cr,uid,ids,context=None):
|
||||
print cr
|
||||
print uid
|
||||
print ids
|
||||
print context
|
||||
print self.pool.get('lunch.preference').browse(cr,uid,ids,context)[0]['product_name']
|
||||
return True
|
||||
|
||||
_columns = {
|
||||
'date' : fields.date('Date', required=True,readonly=True),
|
||||
'color': fields.integer('Color'),
|
||||
'user_id' : fields.many2one('res.users','User Name',required=True,readonly=True),
|
||||
'product' : fields.many2one('lunch.product','Product',required=True),
|
||||
'product_name' : fields.char('Product name',size=64),
|
||||
'note' : fields.text('Note',size=256,required=False),
|
||||
'price' : fields.float('Price',digits=(16,2)),
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'color': 1,
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import addons
|
||||
import tools
|
||||
import pytz
|
||||
import time
|
||||
from osv import osv, fields
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
class lunch_product(osv.Model):
|
||||
""" lunch product """
|
||||
_name = 'lunch.product'
|
||||
_description = 'lunch product'
|
||||
_columns = {
|
||||
'name' : fields.char('Product',required=True, size=64),
|
||||
'category_id': fields.many2one('lunch.product.category', 'Category'),
|
||||
'description': fields.text('Description', size=256, required=False),
|
||||
'price': fields.float('Price', digits=(16,2)),
|
||||
'active': fields.boolean('Active'), #If this product isn't offered anymore, the active boolean is set to false. This will allow to keep trace of previous orders and cashmoves.
|
||||
'supplier' : fields.many2one('res.partner','Supplier',required=True, domain=[('supplier_lunch','=',True)]),
|
||||
}
|
||||
|
||||
class lunch_product_category(osv.Model):
|
||||
""" lunch product category """
|
||||
_name = 'lunch.product.category'
|
||||
_description = 'lunch product category'
|
||||
_columns = {
|
||||
'name' : fields.char('Category', required=True, size=64), #such as PIZZA, SANDWICH, PASTA, CHINESE, BURGER, ...
|
||||
}
|
|
@ -300,7 +300,7 @@
|
|||
<field name="date"/>
|
||||
</group>
|
||||
</group>
|
||||
<img src="/lunch_new/static/src/img/warning.png" width="30" height="30" class="oe_left oe_avatar" attrs="{'invisible': [('state','!=','new')]}"/>
|
||||
<img src="/lunch/static/src/img/warning.png" width="30" height="30" class="oe_left oe_avatar" attrs="{'invisible': [('state','!=','new')]}"/>
|
||||
<div class="oe_title">
|
||||
<field name="alerts" attrs="{'invisible': [('state','!=','new')]}"/>
|
||||
</div>
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2012 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import lunch_validation
|
||||
import lunch_cancel
|
|
@ -1,32 +0,0 @@
|
|||
from osv import osv, fields
|
||||
|
||||
class lunch_cancel(osv.Model):
|
||||
""" lunch cancel """
|
||||
_name = 'lunch.cancel'
|
||||
_description = 'cancel lunch order'
|
||||
|
||||
def cancel(self,cr,uid,ids,context=None):
|
||||
#confirm one or more order.line, update order status and create new cashmove
|
||||
cashmove_ref = self.pool.get('lunch.cashmove')
|
||||
order_lines_ref = self.pool.get('lunch.order.line')
|
||||
orders_ref = self.pool.get('lunch.order')
|
||||
order_ids = context.get('active_ids', [])
|
||||
|
||||
for order in order_lines_ref.browse(cr,uid,order_ids,context=context):
|
||||
order_lines_ref.write(cr,uid,[order.id],{'state':'cancelled'},context)
|
||||
for cash in order.cashmove:
|
||||
cashmove_ref.unlink(cr,uid,cash.id,context)
|
||||
for order in order_lines_ref.browse(cr,uid,order_ids,context=context):
|
||||
hasconfirmed = False
|
||||
hasnew = False
|
||||
for product in order.order_id.products:
|
||||
if product.state=='confirmed':
|
||||
hasconfirmed= True
|
||||
if product.state=='new':
|
||||
hasnew= True
|
||||
if hasnew == False:
|
||||
if hasconfirmed == False:
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'cancelled'},context)
|
||||
return {}
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'partially'},context)
|
||||
return {}
|
|
@ -1,29 +0,0 @@
|
|||
from osv import osv, fields
|
||||
|
||||
class lunch_validation(osv.Model):
|
||||
""" lunch validation """
|
||||
_name = 'lunch.validation'
|
||||
_description = 'lunch validation for order'
|
||||
|
||||
def confirm(self,cr,uid,ids,context=None):
|
||||
#confirm one or more order.line, update order status and create new cashmove
|
||||
cashmove_ref = self.pool.get('lunch.cashmove')
|
||||
order_lines_ref = self.pool.get('lunch.order.line')
|
||||
orders_ref = self.pool.get('lunch.order')
|
||||
order_ids = context.get('active_ids', [])
|
||||
|
||||
for order in order_lines_ref.browse(cr,uid,order_ids,context=context):
|
||||
if order.state!='confirmed':
|
||||
new_id = cashmove_ref.create(cr,uid,{'user_id': order.user_id.id, 'amount':0 - order.price,'description':order.product.name, 'order_id':order.id, 'state':'order', 'date':order.date})
|
||||
order_lines_ref.write(cr,uid,[order.id],{'cashmove':[('0',new_id)], 'state':'confirmed'},context)
|
||||
for order in order_lines_ref.browse(cr,uid,order_ids,context=context):
|
||||
isconfirmed = True
|
||||
for product in order.order_id.products:
|
||||
if product.state == 'new':
|
||||
isconfirmed = False
|
||||
if product.state == 'cancelled':
|
||||
isconfirmed = False
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'partially'},context)
|
||||
if isconfirmed == True:
|
||||
orders_ref.write(cr,uid,[order.order_id.id],{'state':'confirmed'},context)
|
||||
return {}
|
Loading…
Reference in New Issue