From 0ac6c9eff24da1259e04ecf2e28e86c639b43203 Mon Sep 17 00:00:00 2001 From: Arnaud Pineux Date: Wed, 24 Oct 2012 16:20:25 +0200 Subject: [PATCH] [MERGE]Lunch_new application bzr revid: api@openerp.com-20121024142025-ihjkfieq5tj829jw --- addons/lunch/__init__.py | 6 - addons/lunch/__openerp__.py | 2 +- addons/lunch/lunch.py | 225 ++++++++++++++++++ addons/lunch/lunch_alert.py | 46 ---- addons/lunch/lunch_cashmove.py | 45 ---- addons/lunch/lunch_demo.xml | 2 +- addons/lunch/lunch_order_line.py | 108 --------- addons/lunch/lunch_preference.py | 52 ---- addons/lunch/lunch_product.py | 47 ---- .../{wizard => view}/lunch_cancel_view.xml | 0 .../lunch_validation_view.xml | 0 addons/lunch/view/lunch_view.xml | 2 +- addons/lunch/wizard/__init__.py | 23 -- addons/lunch/wizard/lunch_cancel.py | 32 --- addons/lunch/wizard/lunch_validation.py | 29 --- 15 files changed, 228 insertions(+), 391 deletions(-) delete mode 100644 addons/lunch/lunch_alert.py delete mode 100644 addons/lunch/lunch_cashmove.py delete mode 100644 addons/lunch/lunch_order_line.py delete mode 100644 addons/lunch/lunch_preference.py delete mode 100644 addons/lunch/lunch_product.py rename addons/lunch/{wizard => view}/lunch_cancel_view.xml (100%) rename addons/lunch/{wizard => view}/lunch_validation_view.xml (100%) delete mode 100644 addons/lunch/wizard/__init__.py delete mode 100644 addons/lunch/wizard/lunch_cancel.py delete mode 100644 addons/lunch/wizard/lunch_validation.py diff --git a/addons/lunch/__init__.py b/addons/lunch/__init__.py index b1e06385412..14977cd974f 100644 --- a/addons/lunch/__init__.py +++ b/addons/lunch/__init__.py @@ -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 \ No newline at end of file diff --git a/addons/lunch/__openerp__.py b/addons/lunch/__openerp__.py index 95bdc786fb8..b737b77743c 100644 --- a/addons/lunch/__openerp__.py +++ b/addons/lunch/__openerp__.py @@ -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',], diff --git a/addons/lunch/lunch.py b/addons/lunch/lunch.py index e341ef42307..b5266cbfc62 100644 --- a/addons/lunch/lunch.py +++ b/addons/lunch/lunch.py @@ -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 {} + \ No newline at end of file diff --git a/addons/lunch/lunch_alert.py b/addons/lunch/lunch_alert.py deleted file mode 100644 index be1920f3971..00000000000 --- a/addons/lunch/lunch_alert.py +++ /dev/null @@ -1,46 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). -# -# 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 . -# -############################################################################## -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), - } \ No newline at end of file diff --git a/addons/lunch/lunch_cashmove.py b/addons/lunch/lunch_cashmove.py deleted file mode 100644 index 9651067e795..00000000000 --- a/addons/lunch/lunch_cashmove.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). -# -# 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 . -# -############################################################################## -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', - } - diff --git a/addons/lunch/lunch_demo.xml b/addons/lunch/lunch_demo.xml index ff20b7e9cbf..d789002f0ad 100644 --- a/addons/lunch/lunch_demo.xml +++ b/addons/lunch/lunch_demo.xml @@ -3,7 +3,7 @@ - + diff --git a/addons/lunch/lunch_order_line.py b/addons/lunch/lunch_order_line.py deleted file mode 100644 index 58ca3d7cdae..00000000000 --- a/addons/lunch/lunch_order_line.py +++ /dev/null @@ -1,108 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). -# -# 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 . -# -############################################################################## -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', - } - diff --git a/addons/lunch/lunch_preference.py b/addons/lunch/lunch_preference.py deleted file mode 100644 index 825fc76abce..00000000000 --- a/addons/lunch/lunch_preference.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). -# -# 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 . -# -############################################################################## -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, - } \ No newline at end of file diff --git a/addons/lunch/lunch_product.py b/addons/lunch/lunch_product.py deleted file mode 100644 index 77589cc969c..00000000000 --- a/addons/lunch/lunch_product.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2009 Tiny SPRL (). -# -# 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 . -# -############################################################################## -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, ... - } \ No newline at end of file diff --git a/addons/lunch/wizard/lunch_cancel_view.xml b/addons/lunch/view/lunch_cancel_view.xml similarity index 100% rename from addons/lunch/wizard/lunch_cancel_view.xml rename to addons/lunch/view/lunch_cancel_view.xml diff --git a/addons/lunch/wizard/lunch_validation_view.xml b/addons/lunch/view/lunch_validation_view.xml similarity index 100% rename from addons/lunch/wizard/lunch_validation_view.xml rename to addons/lunch/view/lunch_validation_view.xml diff --git a/addons/lunch/view/lunch_view.xml b/addons/lunch/view/lunch_view.xml index 0480d7186f6..e05fa20913c 100644 --- a/addons/lunch/view/lunch_view.xml +++ b/addons/lunch/view/lunch_view.xml @@ -300,7 +300,7 @@ - +
diff --git a/addons/lunch/wizard/__init__.py b/addons/lunch/wizard/__init__.py deleted file mode 100644 index 5761debe4f9..00000000000 --- a/addons/lunch/wizard/__init__.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2012 Tiny SPRL (). -# -# 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 . -# -############################################################################## - -import lunch_validation -import lunch_cancel diff --git a/addons/lunch/wizard/lunch_cancel.py b/addons/lunch/wizard/lunch_cancel.py deleted file mode 100644 index ea100b9889c..00000000000 --- a/addons/lunch/wizard/lunch_cancel.py +++ /dev/null @@ -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 {} diff --git a/addons/lunch/wizard/lunch_validation.py b/addons/lunch/wizard/lunch_validation.py deleted file mode 100644 index dc18d89a5a3..00000000000 --- a/addons/lunch/wizard/lunch_validation.py +++ /dev/null @@ -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 {} \ No newline at end of file