diff options
| author | Arnaud Pineux <api@openerp.com> | 2012-10-24 15:03:15 +0200 |
|---|---|---|
| committer | Arnaud Pineux <api@openerp.com> | 2012-10-24 15:03:15 +0200 |
| commit | d73352a676a6240ffeef8e65a2e71b36e3d426d9 (patch) | |
| tree | e729d2c3af6917122ea826e6b15a43052cae8127 | |
| parent | 1978c4389137045aa8abb34edb4a0922f3856b32 (diff) | |
[MERGE]Lunch_new application
bzr revid: api@openerp.com-20121024130315-vbfrp648vt4rgj97
23 files changed, 1317 insertions, 278 deletions
diff --git a/addons/lunch/report/order.py b/addons/lunch/report/order.py index 11ca7f79dbc..08daebec482 100644 --- a/addons/lunch/report/order.py +++ b/addons/lunch/report/order.py @@ -26,7 +26,7 @@ from osv import osv class order(report_sxw.rml_parse): - def get_lines(self, user,objects): + def get_lines(self,user,objects): lines=[] for obj in objects: if user.id==obj.user_id.id: diff --git a/addons/lunch/report/order.rml b/addons/lunch/report/order.rml index b09b59bb96b..ca334a369f7 100644 --- a/addons/lunch/report/order.rml +++ b/addons/lunch/report/order.rml @@ -107,7 +107,7 @@ </td> </tr> </blockTable> - <para style="terp_header">Lunch Order</para> + <para style="terp_header">Lunch Orders</para> <blockTable colWidths="149.0,114.0,201.0,63.0" style="Table5"> <tr> <td> @@ -152,7 +152,7 @@ <para style="terp_default_9">[[ (lines.product and lines.product.name) or '' ]]</para> </td> <td> - <para style="terp_default_9">[[ lines.descript]]</para> + <para style="terp_default_9">[[ lines.note]]</para> </td> <td> <para style="terp_default_9_right">[[ lines.price ]] [[ (o.company_id and o.company_id.currency_id and o.company_id.currency_id.symbol) or '' ]]</para> diff --git a/addons/lunch/report/report_lunch_order.py b/addons/lunch/report/report_lunch_order.py index 7e2b8de9f49..f874cfbf521 100644 --- a/addons/lunch/report/report_lunch_order.py +++ b/addons/lunch/report/report_lunch_order.py @@ -22,7 +22,7 @@ import tools from osv import fields,osv -class report_lunch_order(osv.osv): +class report_lunch_order_line(osv.osv): _name = "report.lunch.order" _description = "Lunch Orders Statistics" _auto = False @@ -39,6 +39,7 @@ class report_lunch_order(osv.osv): 'price_total':fields.float('Total Price', readonly=True), } _order = 'date desc' + def init(self, cr): tools.drop_view_if_exists(cr, 'report_lunch_order') cr.execute(""" @@ -50,19 +51,14 @@ class report_lunch_order(osv.osv): to_char(lo.date, 'MM') as month, to_char(lo.date, 'YYYY-MM-DD') as day, lo.user_id, - cm.name as box_name, sum(lp.price) as price_total - from lunch_order as lo - left join lunch_cashmove as cm on (cm.id = lo.cashmove) - left join lunch_cashbox as lc on (lc.id = cm.box) left join lunch_product as lp on (lo.product = lp.id) group by - lo.date,lo.user_id,cm.name + lo.date,lo.user_id ) """) -report_lunch_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/lunch/report/report_lunch_order_view.xml b/addons/lunch/report/report_lunch_order_view.xml index e92007592ac..2758cd1653c 100644 --- a/addons/lunch/report/report_lunch_order_view.xml +++ b/addons/lunch/report/report_lunch_order_view.xml @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> <data> - <record id="view_report_lunch_order_tree" model="ir.ui.view"> <field name="name">report.lunch.order.tree</field> <field name="model">report.lunch.order</field> diff --git a/addons/lunch_new/__init__.py b/addons/lunch_new/__init__.py index 398a42669ca..b1e06385412 100644 --- a/addons/lunch_new/__init__.py +++ b/addons/lunch_new/__init__.py @@ -21,4 +21,10 @@ import lunch import partner -import wizard
\ No newline at end of file +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_new/__openerp__.py b/addons/lunch_new/__openerp__.py index 3d30f75ac97..95bdc786fb8 100644 --- a/addons/lunch_new/__openerp__.py +++ b/addons/lunch_new/__openerp__.py @@ -32,8 +32,10 @@ The base module to manage lunch. keep track for the Lunch Order, Cash Moves and Product. Apply Different Category for the product. """, - 'data': ['lunch_view.xml','partner_view.xml','wizard/lunch_validation_view.xml','wizard/lunch_cancel_view.xml'], - 'demo': [], + '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', + 'report/report_lunch_order_view.xml', + 'security/ir.model.access.csv',], + 'demo': ['lunch_demo.xml',], 'test': [], 'installable': True, 'application' : True, diff --git a/addons/lunch_new/lunch.py b/addons/lunch_new/lunch.py index 76c0ec7d6ea..e341ef42307 100644 --- a/addons/lunch_new/lunch.py +++ b/addons/lunch_new/lunch.py @@ -1,3 +1,4 @@ + # -*- encoding: utf-8 -*- ############################################################################## # @@ -24,6 +25,7 @@ import pytz import time from osv import osv, fields from datetime import datetime, timedelta +from lxml import etree class lunch_order(osv.Model): """ lunch order """ @@ -41,6 +43,27 @@ class lunch_order(osv.Model): result[order.id]=value return result + def add_preference(self,cr,uid,ids,pref_id,context=None): + pref_ref = self.pool.get("lunch.preference") + orderline_ref = self.pool.get('lunch.order.line') + order = self.browse(cr,uid,ids,context=context)[0] + pref = pref_ref.browse(cr,uid,pref_id,context=context) + prod_ref = self.pool.get('lunch.product') + if pref["user_id"].id == uid: + new_order_line = {} + new_order_line['date'] = order["date"] + new_order_line['user_id'] = uid + new_order_line['product'] = pref["product"].id + new_order_line['note'] = pref["note"] + new_order_line['order_id'] = order.id + new_order_line['price'] = pref["price"] + new_order_line['supplier'] = prod_ref.browse(cr,uid,pref["product"].id,context=context)['supplier'].id + new_id = orderline_ref.create(cr,uid,new_order_line) + order.products.append(new_id) + total = self._price_get(cr,uid,ids," "," ",context=context) + self.write(cr,uid,ids,{'total':total},context) + return True + def _alerts_get(self,cr,uid,ids,name,arg,context=None): orders = self.browse(cr,uid,ids,context=context) alert_ref = self.pool.get('lunch.alert') @@ -89,7 +112,7 @@ class lunch_order(osv.Model): min_from = int((alert.active_from-hour_from)*60) from_alert = datetime.strptime(str(hour_from)+":"+str(min_from),"%H:%M") if mynow.time()>=from_alert.time() and mynow.time()<=to_alert.time(): - alert_msg+=" * " + alert_msg+="* " alert_msg+=alert.message alert_msg+='\n' return alert_msg @@ -99,18 +122,110 @@ class lunch_order(osv.Model): if products: tot = 0.0 for prod in products: - #price = self.pool.get('lunch.product').read(cr, uid, prod, ['price'])['price'] - #tot += price - res = {'value':{'total':2.0}} - # prods = self.pool.get('lunch.order.line').read(cr,uid,products,['price'])['price'] - # res = {'value':{'total': self._price_get(cr,uid,ids,products,context),}} + orderline = {} + if isinstance(prod[1],bool): + orderline = prod[2] + tot += orderline['price'] + else: + orderline = self.pool.get('lunch.order.line').browse(cr,uid,prod[1],context=context) + tot += orderline.price + res = {'value':{'total':tot}} return res - def _default_product_get(self,cr,uid,arg,context=None): - cr.execute('''SELECT lp.name, lp.description, lp.price, lp.supplier, lp.active, lp.category_id FROM lunch_product AS lp''') + def _default_product_get(self,cr,uid,args,context=None): + cr.execute('''SELECT lol.id, lol.date, lol.user_id, lol.product, lol.note, lol.price, lol.write_date FROM lunch_order_line AS lol ORDER BY write_date''') res = cr.dictfetchall() - return res + result = [] + i=0 + pref_ref = self.pool.get('lunch.preference') + for temp in res: + if i==20: + break + if temp['user_id'] == uid: + prod = self.pool.get('lunch.product').browse(cr, uid, temp['product']) + temp['product_name'] = prod.name + temp['date'] = temp['write_date'] + new_id = pref_ref.create(cr,uid,temp) + result.append(new_id) + i+=1 + return result + + def create(self, cr, uid, values, context=None): + pref_ref = self.pool.get('lunch.preference') + pref_ids = pref_ref.search(cr,uid,[],context=context) + prod_ref = self.pool.get('lunch.product') + new_id = super(lunch_order, self).create(cr, uid, values, context=context) + already_exists = False + if len(values['products'])>0 and values['user_id']==uid: + for pref in pref_ref.browse(cr,uid,pref_ids,context=context): + if pref['product'].id == values['products'][0][2]['product']: + if pref['note'] == values['products'][0][2]['note']: + if pref['price'] == values['products'][0][2]['price']: + already_exists = True + if already_exists == False and len(values['products'])>0: + new_pref = pref_ref.create(cr,uid,{'date':values['date'], 'color':0, 'order_id':new_id, 'user_id':values['user_id'], 'product':values['products'][0][2]['product'], 'product_name':prod_ref.browse(cr,uid,values['products'][0][2]['product'])['name'], 'note':values['products'][0][2]['note'], 'price':values['products'][0][2]['price']},context=context) + return new_id + def _default_preference_get(self,cr,uid,args,context=None): + pref_ref = self.pool.get('lunch.preference') + pref_ids = pref_ref.search(cr,uid,[],order='date desc',limit=20,context=context) + result = [] + for pref in pref_ref.browse(cr,uid,pref_ids,context=context): + result.append(pref.id) + return result + + def __getattr__(self, attr): + if attr.startswith('add_preference_'): + pref_id = int(attr[15:]) + def specific_function(cr, uid, ids, context=None): + return self.add_preference(cr, uid, ids, pref_id, context=context) + return specific_function + return super(lunch_order,self).__getattr__(self,attr) + + def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): + res = super(lunch_order,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) + if view_type == 'form': + doc = etree.XML(res['arch']) + for sheet in doc: + elements = sheet.xpath("//group[@name='pref']") + for element in elements: + pref_ref = self.pool.get("lunch.preference") + pref_ids = pref_ref.search(cr,uid,[],context=context) + for pref in pref_ref.browse(cr,uid,pref_ids,context): + if pref['user_id'].id == uid: + function_name = "add_preference_" + function_name += str(pref.id) + new_element = etree.Element("button") + new_element.set('name',function_name) + new_element.set('icon','gtk-add') + new_element.set('type','object') + ##### title ##### + title = etree.Element('h3') + title.text = pref['product_name'] + ##### price ##### + price_element=etree.Element("font") + text = "Price: " + text+= str(pref['price']) + text+= "€ " + price_element.text = str(text) + ##### note ##### + note = etree.Element('i') + note.text = "Note: "+str(pref['note']) + ##### div ##### + div_element = etree.Element("group") + element.append(div_element) + div_element.append(title) + div_element.append(etree.Element("br")) + div_element.append(price_element) + div_element.append(etree.Element("br")) + div_element.append(new_element) + div_element.append(etree.Element("br")) + div_element.append(note) + div_element.append(etree.Element("br")) + div_element.append(etree.Element("br")) + res['arch'] = etree.tostring(doc) + return res + return res _columns = { 'user_id' : fields.many2one('res.users','User Name',required=True,readonly=True, states={'new':[('readonly', False)]}), @@ -120,7 +235,7 @@ class lunch_order(osv.Model): 'state': fields.selection([('new', 'New'),('confirmed','Confirmed'), ('cancelled','Cancelled'), ('partially','Parcially Confirmed')], \ 'Status', readonly=True, select=True), 'alerts': fields.function(_alerts_get, string="Alerts", type='text'), - 'preferences': fields.one2many("lunch.product",'order_id',readonly=True), + 'preferences': fields.many2many("lunch.preference",'lunch_preference_rel','preferences','order_id','Preferences'), } _defaults = { @@ -128,150 +243,6 @@ class lunch_order(osv.Model): 'date': fields.date.context_today, 'state': lambda self, cr, uid, context: 'new', 'alerts': _default_alerts_get, - 'preferences': _default_product_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), - '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',required=True,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_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)]), - 'order_id' : fields.many2one('lunch.order','Order'), - } - -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 description' - _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', + 'preferences': _default_preference_get, } - -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), - #'active_from' : fields.selection([('0','00h00'),('1','00h30'),('2','01h00'),('3','01h30'),('4','02h00'),('5','02h30'),('6','03h00'),('7','03h30'),('8','04h00'),('9','04h30'),('10','05h00'),('11','05h30'),('12','06h00'),('13','06h30'),('14','07h00'),('15','07h30'),('16','08h00'),('17','08h30'),('18','09h00'),('19','09h30'),('20','10h00'),('21','10h30'),('22','11h00'),('23','11h30'),('24','12h00'),('25','12h30'),('26','13h00'),('27','13h30'),('28','14h00'),('29','14h30'),('30','15h00'),('31','15h30'),('32','16h00'),('33','16h30'),('34','17h00'),('35','17h30'),('36','18h00'),('37','18h30'),('38','19h00'),('39','19h30'),('40','20h00'),('41','20h30'),('42','21h00'),('43','21h30'),('44','22h00'),('45','22h30'),('46','23h00'),('47','23h30')],'Between',required=True), #defines from when (hours) the alert will be displayed - #'active_to' : fields.selection([('0','00h00'),('1','00h30'),('2','01h00'),('3','01h30'),('4','02h00'),('5','02h30'),('6','03h00'),('7','03h30'),('8','04h00'),('9','04h30'),('10','05h00'),('11','05h30'),('12','06h00'),('13','06h30'),('14','07h00'),('15','07h30'),('16','08h00'),('17','08h30'),('18','09h00'),('19','09h30'),('20','10h00'),('21','10h30'),('22','11h00'),('23','11h30'),('24','12h00'),('25','12h30'),('26','13h00'),('27','13h30'),('28','14h00'),('29','14h30'),('30','15h00'),('31','15h30'),('32','16h00'),('33','16h30'),('34','17h00'),('35','17h30'),('36','18h00'),('37','18h30'),('38','19h00'),('39','19h30'),('40','20h00'),('41','20h30'),('42','21h00'),('43','21h30'),('44','22h00'),('45','22h30'),('46','23h00'),('47','23h30')],'and',required=True), # to when (hours) the alert will be disabled - } - - diff --git a/addons/lunch_new/lunch_alert.py b/addons/lunch_new/lunch_alert.py new file mode 100644 index 00000000000..be1920f3971 --- /dev/null +++ b/addons/lunch_new/lunch_alert.py @@ -0,0 +1,46 @@ +# -*- 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), + }
\ No newline at end of file diff --git a/addons/lunch_new/lunch_cashmove.py b/addons/lunch_new/lunch_cashmove.py new file mode 100644 index 00000000000..9651067e795 --- /dev/null +++ b/addons/lunch_new/lunch_cashmove.py @@ -0,0 +1,45 @@ +# -*- 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', + } + diff --git a/addons/lunch_new/lunch_demo.xml b/addons/lunch_new/lunch_demo.xml new file mode 100644 index 00000000000..ff20b7e9cbf --- /dev/null +++ b/addons/lunch_new/lunch_demo.xml @@ -0,0 +1,217 @@ +<?xml version="1.0"?> +<openerp> + <data noupdate="1"> + + <record id="base.user_root" model="res.users"> + <field name="groups_id" eval="[(4,ref('lunch_new.group_lunch_manager'))]"/> + </record> + + <record model="lunch.product.category" id="categ_sandwich"> + <field name="name">Sandwich</field> + </record> + <record model="lunch.product.category" id="categ_pizza"> + <field name="name">Pizza</field> + </record> + <record model="lunch.product.category" id="categ_pasta"> + <field name="name">Pasta</field> + </record> + + <record model="res.partner" id="partner_coin_gourmand"> + <field name="name">Coin gourmand</field> + <field name="supplier_lunch">True</field> + </record> + + <record model="res.partner" id="partner_pizza_inn"> + <field name="name">Pizza Inn</field> + <field name="supplier_lunch">True</field> + </record> + + <record model="lunch.product" id="product_club"> + <field name="name">Club</field> + <field name="category_id" eval="str(ref('categ_sandwich'))"/> + <field name="price">3.30</field> + <field name="active">True</field> + <field name="supplier" eval="str(ref('partner_coin_gourmand'))"/> + <field name="descrîption">Jambon, Fromage, Salade, Tomates, comcombres, oeufs</field> + </record> + + <record model="lunch.product" id="product_campagnard"> + <field name="name">Le Campagnard</field> + <field name="category_id" eval="str(ref('categ_sandwich'))"/> + <field name="price">3.30</field> + <field name="active">True</field> + <field name="supplier" eval="str(ref('partner_coin_gourmand'))"/> + <field name="descrîption">Brie, Miel, Cerneaux de noix</field> + </record> + + <record model="lunch.product" id="product_pate_creme"> + <field name="name">Le Pâté Crème</field> + <field name="category_id" eval="str(ref('categ_sandwich'))"/> + <field name="price">2.50</field> + <field name="active">True</field> + <field name="supplier" eval="str(ref('partner_coin_gourmand'))"/> + <field name="descrîption"></field> + </record> + + <record model="lunch.product" id="product_gouda"> + <field name="name">Fromage Gouda</field> + <field name="category_id" eval="str(ref('categ_sandwich'))"/> + <field name="price">2.50</field> + <field name="active">True</field> + <field name="supplier" eval="str(ref('partner_coin_gourmand'))"/> + <field name="descrîption"></field> + </record> + + <record model="lunch.product" id="product_poulet_curry"> + <field name="name">Poulet Curry</field> + <field name="category_id" eval="str(ref('categ_sandwich'))"/> + <field name="price">2.60</field> + <field name="active">True</field> + <field name="supplier" eval="str(ref('partner_coin_gourmand'))"/> + <field name="descrîption"></field> + </record> + + <record model="lunch.product" id="product_margherita"> + <field name="name">Pizza Margherita</field> + <field name="category_id" eval="str(ref('categ_pizza'))"/> + <field name="price">6.90</field> + <field name="active">True</field> + <field name="supplier" eval="str(ref('partner_pizza_inn'))"/> + <field name="descrîption">Tomates, Mozzarella</field> + </record> + + <record model="lunch.product" id="product_italiana"> + <field name="name">Pizza Italiana</field> + <field name="category_id" eval="str(ref('categ_pizza'))"/> + <field name="price">7.40</field> + <field name="active">True</field> + <field name="supplier" eval="str(ref('partner_pizza_inn'))"/> + <field name="descrîption">Tomates fraiches, Basilic, Mozzarella</field> + </record> + + <record model="lunch.product" id="product_Bolognese"> + <field name="name">Pâtes Bolognese</field> + <field name="category_id" eval="str(ref('categ_pasta'))"/> + <field name="price">7.70</field> + <field name="active">True</field> + <field name="supplier" eval="str(ref('partner_pizza_inn'))"/> + <field name="descrîption"></field> + </record> + + <record model="lunch.product" id="product_Napoli"> + <field name="name">Pâtes Napoli</field> + <field name="category_id" eval="str(ref('categ_pasta'))"/> + <field name="price">7.70</field> + <field name="active">True</field> + <field name="supplier" eval="str(ref('partner_pizza_inn'))"/> + <field name="descrîption">Tomates, Basilic</field> + </record> + + <record model="lunch.order" id="order_1"> + <field name="user_id" ref="base.user_root"/> + <field name="date" eval="time.strftime('2012-10-23')"/> + <field name="products" eval="[]"/> + <field name="state">new</field> + </record> + + <record model="lunch.order" id="order_2"> + <field name="user_id" ref="base.user_root"/> + <field name="date" eval="time.strftime('2012-10-22')"/> + <field name="products" eval="[]"/> + <field name="state">confirmed</field> + </record> + + <record model="lunch.order" id="order_3"> + <field name="user_id" ref="base.user_root"/> + <field name="date" eval="time.strftime('2012-10-24')"/> + <field name="products" eval="[]"/> + <field name="state">cancelled</field> + </record> + + <record model="lunch.order.line" id="order_line_1"> + <field name="user_id" ref="base.user_root"/> + <field name="product" ref="product_Bolognese"/> + <field name="date" eval="time.strftime('2012-10-23')"/> + <field name="state">new</field> + <field name="supplier" ref="partner_pizza_inn"/> + <field name="note">+Emmental</field> + <field name="order_id" ref="order_1"/> + </record> + + <record model="lunch.order.line" id="order_line_2"> + <field name="user_id" ref="base.user_root"/> + <field name="product" ref="product_italiana"/> + <field name="date" eval="time.strftime('2012-10-22')"/> + <field name="state">confirmed</field> + <field name="supplier" ref="partner_pizza_inn"/> + <field name="note">+Champignons</field> + <field name="order_id" ref="order_2"/> + </record> + + <record model="lunch.order.line" id="order_line_3"> + <field name="user_id" ref="base.user_root"/> + <field name="product" ref="product_gouda"/> + <field name="date" eval="time.strftime('2012-10-24')"/> + <field name="state">cancelled</field> + <field name="supplier" ref="partner_coin_gourmand"/> + <field name="note">+Salade +Tomates +Comcombres</field> + <field name="order_id" ref="order_3"/> + </record> + + <record model="lunch.preference" id="preference_1"> + <field name="user_id" ref="base.user_root"/> + <field name="product" ref="product_gouda"/> + <field name="date" eval="time.strftime('2012-10-24')"/> + <field name="color">0</field> + <field name="product_name">Fromage Gouda</field> + <field name="price">2.50</field> + <field name="note">+Salade +Tomates +Comcombres</field> + </record> + + <record model="lunch.preference" id="preference_2"> + <field name="user_id" ref="base.user_root"/> + <field name="product" ref="product_italiana"/> + <field name="date" eval="time.strftime('2012-10-22')"/> + <field name="color">0</field> + <field name="product_name">Pizza Italiana</field> + <field name="price">7.40</field> + <field name="note">+Champignons</field> + </record> + + <record model="lunch.preference" id="preference_3"> + <field name="user_id" ref="base.user_root"/> + <field name="product" ref="product_Bolognese"/> + <field name="date" eval="time.strftime('2012-10-23')"/> + <field name="color">0</field> + <field name="product_name">Pâtes Bolognese</field> + <field name="price">7.70</field> + <field name="note">+Emmental</field> + </record> + + <record model="lunch.cashmove" id="cashmove_1"> + <field name="user_id" ref="base.user_root"/> + <field name="date" eval="time.strftime('2012-10-23')"/> + <field name="description">Pizza Italiana</field> + <field name="amount">-7.40</field> + <field name="order_id" ref="order_2"/> + <field name="state">order</field> + </record> + + <record model="lunch.cashmove" id="cashmove_2"> + <field name="user_id" ref="base.user_root"/> + <field name="date" eval="time.strftime('2012-10-24')"/> + <field name="description">Payment: 5 lunch tickets (6€)</field> + <field name="amount">30</field> + <field name="state">payment</field> + </record> + + <record model="lunch.alert" id="alert_1"> + <field name="message">Lunch must be ordered before 10h30 am</field> + <field name="day">days</field> + <field name="active">t</field> + <field name="active_from">0</field> + <field name="active_to">0</field> + </record> + + </data> +</openerp> diff --git a/addons/lunch_new/lunch_order_line.py b/addons/lunch_new/lunch_order_line.py new file mode 100644 index 00000000000..58ca3d7cdae --- /dev/null +++ b/addons/lunch_new/lunch_order_line.py @@ -0,0 +1,108 @@ +# -*- 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', + } + diff --git a/addons/lunch_new/lunch_preference.py b/addons/lunch_new/lunch_preference.py new file mode 100644 index 00000000000..825fc76abce --- /dev/null +++ b/addons/lunch_new/lunch_preference.py @@ -0,0 +1,52 @@ +# -*- 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, + }
\ No newline at end of file diff --git a/addons/lunch_new/lunch_product.py b/addons/lunch_new/lunch_product.py new file mode 100644 index 00000000000..77589cc969c --- /dev/null +++ b/addons/lunch_new/lunch_product.py @@ -0,0 +1,47 @@ +# -*- 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, ... + }
\ No newline at end of file diff --git a/addons/lunch_new/lunch_report.xml b/addons/lunch_new/lunch_report.xml new file mode 100644 index 00000000000..942caadeed3 --- /dev/null +++ b/addons/lunch_new/lunch_report.xml @@ -0,0 +1,13 @@ +<?xml version="1.0"?> +<openerp> + <data> + <report + id="report_lunch_order" + string="Lunch Order" + model="lunch.order.line" + name="lunch.order.line" + rml="lunch/report/order.rml" + auto="False" + /> + </data> +</openerp> diff --git a/addons/lunch_new/report/__init__.py b/addons/lunch_new/report/__init__.py new file mode 100644 index 00000000000..4a56869bf83 --- /dev/null +++ b/addons/lunch_new/report/__init__.py @@ -0,0 +1,25 @@ +# -*- 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 order +import report_lunch_order +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/lunch_new/report/order.py b/addons/lunch_new/report/order.py new file mode 100644 index 00000000000..abd5b2726a3 --- /dev/null +++ b/addons/lunch_new/report/order.py @@ -0,0 +1,78 @@ +# -*- 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 time +from report import report_sxw +from osv import osv + + +class order(report_sxw.rml_parse): + + def get_lines(self, user,objects): + lines=[] + for obj in objects: + if user.id==obj.user_id.id: + lines.append(obj) + return lines + + def get_total(self, user,objects): + lines=[] + for obj in objects: + if user.id==obj.user_id.id: + lines.append(obj) + total=0.0 + for line in lines: + total+=line.price + self.net_total+=total + return total + + def get_nettotal(self): + return self.net_total + + def get_users(self, objects): + users=[] + for obj in objects: + if obj.user_id not in users: + users.append(obj.user_id) + return users + + def get_note(self,objects): + notes=[] + for obj in objects: + notes.append(obj.note) + return notes + + def __init__(self, cr, uid, name, context): + super(order, self).__init__(cr, uid, name, context) + self.net_total=0.0 + self.localcontext.update({ + 'time': time, + 'get_lines': self.get_lines, + 'get_users': self.get_users, + 'get_total': self.get_total, + 'get_nettotal': self.get_nettotal, + 'get_note': self.get_note, + }) + +report_sxw.report_sxw('report.lunch.order.line', 'lunch.order.line', + 'addons/lunch/report/order.rml',parser=order, header='external') +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/lunch_new/report/order.rml b/addons/lunch_new/report/order.rml new file mode 100644 index 00000000000..b09b59bb96b --- /dev/null +++ b/addons/lunch_new/report/order.rml @@ -0,0 +1,184 @@ +<?xml version="1.0"?> +<document filename="Lunch Order.pdf"> + <template title="Lunch Order" author="OpenERP S.A.(sales@openerp.com)" allowSplitting="20"> + <pageTemplate id="first"> + <frame id="first" x1="34.0" y1="42.0" width="527" height="758"/> + </pageTemplate> + </template> + <stylesheet> + <blockTableStyle id="Standard_Outline"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + </blockTableStyle> + <blockTableStyle id="Table1"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + </blockTableStyle> + <blockTableStyle id="Table5"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="0,-1" stop="0,-1"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="1,-1" stop="1,-1"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="2,-1" stop="2,-1"/> + <lineStyle kind="LINEBELOW" colorName="#000000" start="3,-1" stop="3,-1"/> + </blockTableStyle> + <blockTableStyle id="Table6"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEBELOW" colorName="#b3b3b3" start="0,-1" stop="0,-1"/> + </blockTableStyle> + <blockTableStyle id="Table7"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="0,-1" stop="0,-1"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="1,-1" stop="1,-1"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="2,-1" stop="2,-1"/> + <lineStyle kind="LINEBELOW" colorName="#e6e6e6" start="3,-1" stop="3,-1"/> + </blockTableStyle> + <blockTableStyle id="Table2"> + <blockAlignment value="LEFT"/> + <blockValign value="TOP"/> + <lineStyle kind="LINEABOVE" colorName="#000000" start="1,0" stop="1,0"/> + <lineStyle kind="LINEABOVE" colorName="#000000" start="2,0" stop="2,0"/> + </blockTableStyle> + <initialize> + <paraStyle name="all" alignment="justify"/> + </initialize> + <paraStyle name="Standard" fontName="Helvetica"/> + <paraStyle name="Text body" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> + <paraStyle name="Heading" fontName="Helvetica" fontSize="14.0" leading="17" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="List" fontName="Helvetica" spaceBefore="0.0" spaceAfter="6.0"/> + <paraStyle name="Header" fontName="Helvetica"/> + <paraStyle name="Footer" fontName="Helvetica"/> + <paraStyle name="Table Contents" fontName="Helvetica"/> + <paraStyle name="Table Heading" fontName="Helvetica" alignment="CENTER"/> + <paraStyle name="Caption" fontName="Helvetica" fontSize="12.0" leading="15" spaceBefore="6.0" spaceAfter="6.0"/> + <paraStyle name="Footnote" rightIndent="0.0" leftIndent="14.0" fontName="Helvetica" fontSize="10.0" leading="13"/> + <paraStyle name="Index" fontName="Helvetica"/> + <paraStyle name="Heading 1" fontName="Helvetica-Bold" fontSize="115%" leading="NaN" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="terp_header" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="LEFT" spaceBefore="12.0" spaceAfter="6.0"/> + <paraStyle name="terp_default_8" fontName="Helvetica" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_9" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_tbl_detail_header" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_tbl_detail_header_right" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_tbl_detail_header_center" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_9_right" fontName="Helvetica" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_9_right_bold" fontName="Helvetica-Bold" fontSize="9.0" leading="11" alignment="RIGHT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_header_center" fontName="Helvetica-Bold" fontSize="15.0" leading="19" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_9_center" fontName="Helvetica" fontSize="9.0" leading="11" alignment="CENTER" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_2" fontName="Helvetica" fontSize="2.0" leading="3" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <paraStyle name="terp_default_9_left9" rightIndent="0.0" leftIndent="9.0" fontName="Helvetica" fontSize="9.0" leading="11" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/> + <images/> + </stylesheet> + <story> + <pto> + <pto_header> + <blockTable colWidths="149.0,114.0,201.0,63.0" style="Table5"> + <tr> + <td> + <para style="terp_tbl_detail_header">Name/Date</para> + </td> + <td> + <para style="terp_tbl_detail_header">Order</para> + </td> + <td> + <para style="terp_tbl_detail_header">Description</para> + </td> + <td> + <para style="terp_tbl_detail_header_right">Unit Price</para> + </td> + </tr> + </blockTable> + </pto_header> + <para style="terp_default_8"> + <font color="white"> </font> + </para> + <blockTable colWidths="293.0,235.0" style="Table1"> + <tr> + <td> + <para style="terp_default_8"> + <font color="white"> </font> + </para> + </td> + <td> + <para style="terp_default_8">[[ user.name ]] </para> + <para style="terp_default_8">[[ user.login ]]</para> + <para style="terp_default_8">[[ user.email ]]</para> + </td> + </tr> + </blockTable> + <para style="terp_header">Lunch Order</para> + <blockTable colWidths="149.0,114.0,201.0,63.0" style="Table5"> + <tr> + <td> + <para style="terp_tbl_detail_header">Name/Date</para> + </td> + <td> + <para style="terp_tbl_detail_header">Order</para> + </td> + <td> + <para style="terp_tbl_detail_header">Description</para> + </td> + <td> + <para style="terp_tbl_detail_header_right">Unit Price</para> + </td> + </tr> + </blockTable> + <section> + <para style="terp_default_2">[[repeatIn(get_users(objects),'o')]]</para> + <blockTable colWidths="263.0,201.0,63.0" style="Table6"> + <tr> + <td> + <para style="terp_tbl_detail_header">[[ o.name ]]</para> + </td> + <td> + <para style="terp_default_8"> + <font color="white"> </font> + </para> + </td> + <td> + <para style="terp_default_9_right_bold"><u>[[ formatLang(get_total(o,objects)) ]] [[ (o.company_id and o.company_id.currency_id and o.company_id.currency_id.symbol) or '' ]]</u></para> + </td> + </tr> + </blockTable> + <section> + <para style="terp_default_2">[[ repeatIn(get_lines(o,objects),'lines') ]]</para> + <blockTable colWidths="151.0,113.0,216.0,49.0" style="Table7"> + <tr> + <td> + <para style="terp_default_9_left9">[[ formatLang(lines.date,date='True') ]]</para> + </td> + <td> + <para style="terp_default_9">[[ (lines.product and lines.product.name) or '' ]]</para> + </td> + <td> + <para style="terp_default_9">[[ lines.descript]]</para> + </td> + <td> + <para style="terp_default_9_right">[[ lines.price ]] [[ (o.company_id and o.company_id.currency_id and o.company_id.currency_id.symbol) or '' ]]</para> + </td> + </tr> + </blockTable> + </section> + </section> + <blockTable colWidths="409.0,50.0,70.0" style="Table2"> + <tr> + <td> + <para style="terp_default_8"> + <font color="white"> </font> + </para> + </td> + <td> + <para style="terp_tbl_detail_header">Total :</para> + </td> + <td> + <para style="terp_default_9_right_bold">[[ formatLang(get_nettotal()) ]] [[ (o.company_id and o.company_id.currency_id and o.company_id.currency_id.symbol) or '' ]]</para> + </td> + </tr> + </blockTable> + <para style="terp_default_2"> + <font color="white"> </font> + </para> + </pto> + </story> +</document> diff --git a/addons/lunch_new/report/report_lunch_order.py b/addons/lunch_new/report/report_lunch_order.py new file mode 100644 index 00000000000..43da1844ab7 --- /dev/null +++ b/addons/lunch_new/report/report_lunch_order.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 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 tools +from osv import fields,osv + +class report_lunch_order(osv.osv): + _name = "report.lunch.order.line" + _description = "Lunch Orders Statistics" + _auto = False + _rec_name = 'date' + _columns = { + 'date': fields.date('Date Order', readonly=True, select=True), + 'year': fields.char('Year', size=4, readonly=True), + 'month':fields.selection([('01','January'), ('02','February'), ('03','March'), ('04','April'), + ('05','May'), ('06','June'), ('07','July'), ('08','August'), ('09','September'), + ('10','October'), ('11','November'), ('12','December')], 'Month',readonly=True), + 'day': fields.char('Day', size=128, readonly=True), + 'user_id': fields.many2one('res.users', 'User Name'), + 'price_total':fields.float('Total Price', readonly=True), + 'note' : fields.text('Note',size=256,readonly=True), + } + _order = 'date desc' + def init(self, cr): + tools.drop_view_if_exists(cr, 'report_lunch_order_line') + cr.execute(""" + create or replace view report_lunch_order_line as ( + select + min(lo.id) as id, + lo.date as date, + to_char(lo.date, 'YYYY') as year, + to_char(lo.date, 'MM') as month, + to_char(lo.date, 'YYYY-MM-DD') as day, + lo.user_id, + lo.note as note, + sum(lp.price) as price_total + + from + lunch_order_line as lo + left join lunch_product as lp on (lo.product = lp.id) + group by + lo.date,lo.user_id,lo.note + ) + """) +report_lunch_order() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/lunch_new/report/report_lunch_order_view.xml b/addons/lunch_new/report/report_lunch_order_view.xml new file mode 100644 index 00000000000..b916cab79f9 --- /dev/null +++ b/addons/lunch_new/report/report_lunch_order_view.xml @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <record id="view_report_lunch_order_tree" model="ir.ui.view"> + <field name="name">report.lunch.order.tree</field> + <field name="model">report.lunch.order.line</field> + <field name="arch" type="xml"> + <tree string="Sales Analysis"> + <field name="date" invisible="1"/> + <field name="year" invisible="1"/> + <field name="day" invisible="1"/> + <field name="month" invisible="1"/> + <field name="user_id" /> + <field name="note" /> + <field name="price_total"/> + </tree> + </field> + </record> + + <record id="view_report_lunch_order_search" model="ir.ui.view"> + <field name="name">report.lunch.order.search</field> + <field name="model">report.lunch.order.line</field> + <field name="arch" type="xml"> + <search string="Lunch Order Analysis"> + <field name="date"/> + <group expand="0" string="Group By..."> + <filter string="User" name="User" icon="terp-personal" context="{'group_by':'user_id'}"/> + <filter string="Box" icon="terp-dolar" context="{'group_by':'box_name'}"/> + <filter string="Day" icon="terp-go-today" context="{'group_by':'day'}"/> + <filter string="Month" icon="terp-go-month" context="{'group_by':'month'}"/> + <filter string="Year" icon="terp-go-year" context="{'group_by':'year'}"/> + </group> + </search> + </field> + </record> + + <record id="action_report_lunch_order_all" model="ir.actions.act_window"> + <field name="name">Lunch Order Analysis</field> + <field name="res_model">report.lunch.order.line</field> + <field name="view_type">form</field> + <field name="view_mode">tree</field> + <field name="search_view_id" ref="view_report_lunch_order_search"/> + <field name="context">{'search_default_month':1,'search_default_User':1}</field> + </record> + + </data> +</openerp> diff --git a/addons/lunch_new/security/groups.xml b/addons/lunch_new/security/groups.xml new file mode 100644 index 00000000000..df8b675425d --- /dev/null +++ b/addons/lunch_new/security/groups.xml @@ -0,0 +1,137 @@ +<?xml version="1.0" ?> +<openerp> + <data> + <record id="group_lunch_manager" model="res.groups"> + <field name="name">Lunch / Manager</field> + </record> + <record id="group_lunch_user" model="res.groups"> + <field name="name">Lunch / User</field> + </record> + <record id="ir_model_access_lunchorders0" model="ir.model.access"> + <field name="model_id" ref="model_lunch_order"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch orders</field> + <field eval="1" name="perm_unlink"/> + <field eval="1" name="perm_write"/> + <field eval="1" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / Manager')]"/> + </record> + <record id="ir_model_access_lunchorders1" model="ir.model.access"> + <field name="model_id" ref="model_lunch_order"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch orders</field> + <field eval="0" name="perm_unlink"/> + <field eval="1" name="perm_write"/> + <field eval="1" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / User')]"/> + </record> + <record id="ir_model_access_lunchorder_lines0" model="ir.model.access"> + <field name="model_id" ref="model_lunch_order_line"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch order lines</field> + <field eval="1" name="perm_unlink"/> + <field eval="1" name="perm_write"/> + <field eval="1" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / Manager')]"/> + </record> + <record id="ir_model_access_lunchorder_lines1" model="ir.model.access"> + <field name="model_id" ref="model_lunch_order_line"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch order lines</field> + <field eval="1" name="perm_unlink"/> + <field eval="1" name="perm_write"/> + <field eval="1" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / User')]"/> + </record> + <record id="ir_model_access_lunchcashmoves0" model="ir.model.access"> + <field name="model_id" ref="model_lunch_cashmove"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch cashmoves</field> + <field eval="1" name="perm_unlink"/> + <field eval="1" name="perm_write"/> + <field eval="1" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / Manager')]"/> + </record> + <record id="ir_model_access_lunchcashmoves1" model="ir.model.access"> + <field name="model_id" ref="model_lunch_cashmove"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch cashmoves</field> + <field eval="0" name="perm_unlink"/> + <field eval="0" name="perm_write"/> + <field eval="0" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / User')]"/> + </record> + <record id="ir_model_access_lunchproducts0" model="ir.model.access"> + <field name="model_id" ref="model_lunch_product"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch products</field> + <field eval="1" name="perm_unlink"/> + <field eval="1" name="perm_write"/> + <field eval="1" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / Manager')]"/> + </record> + <record id="ir_model_access_lunchproducts1" model="ir.model.access"> + <field name="model_id" ref="model_lunch_product"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch products</field> + <field eval="0" name="perm_unlink"/> + <field eval="0" name="perm_write"/> + <field eval="0" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / User')]"/> + </record> + <record id="ir_model_access_lunchproductcategories0" model="ir.model.access"> + <field name="model_id" ref="model_lunch_product_category"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch products</field> + <field eval="1" name="perm_unlink"/> + <field eval="1" name="perm_write"/> + <field eval="1" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / Manager')]"/> + </record> + <record id="ir_model_access_lunchproductcategories1" model="ir.model.access"> + <field name="model_id" ref="model_lunch_product_category"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch products</field> + <field eval="0" name="perm_unlink"/> + <field eval="0" name="perm_write"/> + <field eval="0" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / User')]"/> + </record> + <record id="ir_model_access_lunchalerts0" model="ir.model.access"> + <field name="model_id" ref="model_lunch_alert"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch alerts</field> + <field eval="1" name="perm_unlink"/> + <field eval="1" name="perm_write"/> + <field eval="1" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / Manager')]"/> + </record> + <record id="ir_model_access_lunchalerts1" model="ir.model.access"> + <field name="model_id" ref="model_lunch_alert"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch alerts</field> + <field eval="0" name="perm_unlink"/> + <field eval="0" name="perm_write"/> + <field eval="0" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / User')]"/> + </record> + <record id="ir_model_access_lunchpreferences0" model="ir.model.access"> + <field name="model_id" ref="model_lunch_preference"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch preferences</field> + <field eval="1" name="perm_unlink"/> + <field eval="1" name="perm_write"/> + <field eval="1" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / Manager')]"/> + </record> + <record id="ir_model_access_lunchpreferences1" model="ir.model.access"> + <field name="model_id" ref="model_lunch_preference"/> + <field eval="1" name="perm_read"/> + <field name="name">lunch preferences</field> + <field eval="1" name="perm_unlink"/> + <field eval="1" name="perm_write"/> + <field eval="1" name="perm_create"/> + <field model="res.groups" name="group_id" search="[('full_name', '=', u'lunch / User')]"/> + </record> + </data> +</openerp> diff --git a/addons/lunch_new/security/ir.model.access.csv b/addons/lunch_new/security/ir.model.access.csv new file mode 100644 index 00000000000..23a43a5bd93 --- /dev/null +++ b/addons/lunch_new/security/ir.model.access.csv @@ -0,0 +1,15 @@ +id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink +order_user,"Order user",model_lunch_order,group_lunch_manager,1,1,1,1 +order_line_user,"Order Line user",model_lunch_order_line,group_lunch_manager,1,1,1,1 +cashmove_user,"Cashmove user",model_lunch_cashmove,group_lunch_manager,1,1,1,1 +product_user,"Product user",model_lunch_product,group_lunch_manager,1,1,1,1 +product_category_user,"Product category user",model_lunch_product_category,group_lunch_manager,1,1,1,1 +alert_user,"Alert user",model_lunch_alert,group_lunch_manager,1,1,1,1 +preference_user,"Preference user",model_lunch_preference,group_lunch_manager,1,1,1,1 +order_user,"Order user",model_lunch_order,group_lunch_user,1,1,1,0 +order_line_user,"Order Line user",model_lunch_order_line,group_lunch_user,1,1,1,1 +cashmove_user,"Cashmove user",model_lunch_cashmove,group_lunch_user,1,0,0,0 +product_user,"Product user",model_lunch_product,group_lunch_user,1,0,0,0 +product_category_user,"Product category user",model_lunch_product_category,group_lunch_user,1,0,0,0 +alert_user,"Alert user",model_lunch_alert,group_lunch_user,1,0,0,0 +preference_user,"Preference user",model_lunch_preference,group_lunch_user,1,1,1,1
\ No newline at end of file diff --git a/addons/lunch_new/lunch_view.xml b/addons/lunch_new/view/lunch_view.xml index 5ef29b55378..0480d7186f6 100644 --- a/addons/lunch_new/lunch_view.xml +++ b/addons/lunch_new/view/lunch_view.xml @@ -4,9 +4,9 @@ <!--Menu and Title--> <menuitem id='menu_lunch' name='Lunch' /> <menuitem name="Lunch Menu" parent="menu_lunch" id="menu_lunch_title" sequence="50" /> - <menuitem name="Administrate Orders" parent="menu_lunch" id="menu_lunch_admin" sequence="51" /> - <menuitem name="Administrate Cash Moves" parent="menu_lunch" id="menu_lunch_cash" sequence="52" /> - <menuitem name="Configuration" parent="menu_lunch" id="menu_lunch_config" sequence="53" /> + <menuitem name="Administrate Orders" parent="menu_lunch" id="menu_lunch_admin" sequence="51" groups="group_lunch_manager"/> + <menuitem name="Administrate Cash Moves" parent="menu_lunch" id="menu_lunch_cash" sequence="52" groups="group_lunch_manager"/> + <menuitem name="Configuration" parent="menu_lunch" id="menu_lunch_config" sequence="53" groups="group_lunch_manager"/> <!--View Search to group by Supplier and time--> <record model="ir.ui.view" id="supplier_group_by_month_search_view"> @@ -20,7 +20,6 @@ <filter name="comfirmed" string="Confirmed" domain="[('state','=','confirmed')]"/> <filter name="cancelled" string="Cancelled" domain="[('state','=','cancelled')]"/> <filter name="group_by_date" string="By Date" context="{'group_by':'date'}"/> - <!-- <filter name="thisMonth" string="This Month" domain="[('date','>=',time.strftime('%%m-01-%%Y')),('date','<=',time.strftime('%%m-31-%%Y'))]"/> --> </search> </field> </record> @@ -79,6 +78,13 @@ <record model="ir.actions.act_window" id="action_lunch_order_form"> <field name="name">Your Orders</field> <field name="res_model">lunch.order</field> + <field name="view_mode">form</field> + </record> + <menuitem name="Your Orders" parent="menu_lunch_title" id="menu_lunch_order_form" action="action_lunch_order_form" sequence="1"/> + + <record model="ir.actions.act_window" id="action_lunch_order_tree"> + <field name="name">Your Orders</field> + <field name="res_model">lunch.order</field> <field name="view_mode">tree,form</field> <field name="search_view_id" ref="view_search_my_order"/> <field name="context">{"search_default_is_mine":1}</field> @@ -91,7 +97,7 @@ </p> </field> </record> - <menuitem name="Your Orders" parent="menu_lunch_title" id="menu_lunch_order_form" action="action_lunch_order_form" /> + <menuitem name="Previous Orders" parent="menu_lunch_title" id="menu_lunch_order_tree" action="action_lunch_order_tree" sequence="2"/> <!--Action for Lunch cashmoves--> <record model="ir.actions.act_window" id="action_lunch_cashmove_form"> @@ -106,7 +112,7 @@ </p> </field> </record> - <menuitem name="Your Lunch Account" parent="menu_lunch_title" id="menu_lunch_cashmove_form" action="action_lunch_cashmove_form" /> + <menuitem name="Your Lunch Account" parent="menu_lunch_title" id="menu_lunch_cashmove_form" action="action_lunch_cashmove_form" sequence="3"/> <!--Action for Administrate Orders group by supplier--> <record model="ir.actions.act_window" id="action_lunch_order_by_supplier_form"> @@ -180,7 +186,7 @@ <record model="ir.actions.act_window" id="action_lunch_products"> <field name="name">Products</field> <field name="res_model">lunch.product</field> - <field name="view_mode">tree,form,kanban</field> + <field name="view_mode">tree,form</field> <field name="help" type="html"> <p class="oe_view_nocontent_create"> Click to create a product for lunch. @@ -206,6 +212,24 @@ </p> </field> </record> + + <record model="ir.ui.view" id="product_category_form_view"> + <field name="name">Product category Form</field> + <field name="model">lunch.product.category</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Products Form" version="7.0"> + <header> + </header> + <sheet> + <group> + <field name='name' string="Product Category: "/> + </group> + </sheet> + </form> + </field> + </record> + <menuitem name="Product Categories" parent="menu_lunch_config" id="menu_lunch_product_categories" action="action_lunch_product_categories" /> <!--Action for Alert--> @@ -238,8 +262,8 @@ <field name='note'/> <field name='state'/> <field name='price' sum="Total"/> - <button name="confirm" string="Confirm" type="object" icon="gtk-apply"/> - <button name="cancel" string="Cancel" type="object" icon="gtk-cancel"/> + <button name="confirm" string="Confirm" type="object" icon="gtk-apply" attrs="{'invisible': [('state','=','confirmed')]}"/> + <button name="cancel" string="Cancel" type="object" icon="gtk-cancel" attrs="{'invisible': [('state','=','cancelled')]}"/> </tree> </field> </record> @@ -252,7 +276,7 @@ <tree string="Orders Tree"> <field name="date"/> <field name="products"/> - <field name="state" invisible='1'/> + <field name="state" /> <field name="total" sum="Total"/> <field name="preferences" invisible="1"/> </tree> @@ -264,60 +288,39 @@ <field name="model">lunch.order</field> <field name="arch" type="xml"> <form string="Orders Form" version="7.0"> + <header> + <field name="state" widget="statusbar" statusbar_visible="new,confirmed"/> + </header> <sheet> - <field name="state" invisible='1'/> - <group col="2"> - <field name="user_id"/> - </group> - <group col="2"> - <field name="date"/> - </group> - <group colspan="4" col="2"> - <img src="/lunch_new/static/src/img/warning.png" width="30" height="30" attrs="{'invisible': [('state','!=','new')]}"/> - <field name="alerts" nolabel="1" attrs="{'invisible': [('state','!=','new')]}"/> - </group> - <group colspan="2" col="2"> - </group> - <separator string="Products" colspan="4"/> - <field name="preferences" colspan="4" nolabel="1"> - <kanban default_group_by="category_id"> - <templates> - <t t-name="kanban-box"> - <div class="oe_kanban_color_0 oe_kanban_card oe_kanban_global_click oe_kanban_draghandle"> - <div class="oe_kanban_vignette oe_semantic_html_override"> - <div class="oe_kanban_details"> - <h3 class="oe_partner_heading"> - <a type="open"> - <u><field name="name"/><br/></u> - </a> - </h3> - <h4> - <a type="open"> - Price: - <field name="price"/> - € - <br/> - </a> - </h4> - Supplier: <field name="supplier"/><br/> - <font size="2" color="gray"><field name="description"/></font> - </div> - </div> - </div> - </t> - </templates> - </kanban> - </field> - <separator string="Your Order" colspan="4"/> - <field name="products" colspan="4" nolabel="1" on_change="onchange_price(products)"> - <tree string="List" editable="bottom"> - <field name="product" colspan="2" on_change="onchange_price(product)"/> - <field name="note" /> - <field name="state"/> - <field name="price"/> - </tree> - </field> - <field name="total"/> + <group> + <group> + <field name="user_id"/> + </group> + <group> + <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')]}"/> + <div class="oe_title"> + <field name="alerts" attrs="{'invisible': [('state','!=','new')]}"/> + </div> + <separator name="pref" string="Quick Select a Product"/> + <group name="pref"> + </group> + <separator string="Select Products"/> + <field name="products" colspan="4" nolabel="1" on_change="onchange_price(products)"> + <tree string="List" editable="bottom"> + <field name="product" colspan="2" on_change="onchange_price(product)"/> + <field name="note" /> + <field name='supplier'/> + <field name="state" invisible="1"/> + <field name="price"/> + </tree> + </field> + <group class="oe_subtotal_footer oe_right"> + <field name="total"/> + </group> + <br/><br/> </sheet> </form> </field> @@ -345,7 +348,10 @@ <field name="model">lunch.product</field> <field name="type">form</field> <field name="arch" type="xml"> - <form string="Products Form"> + <form string="Products Form" version="7.0"> + <header> + </header> + <sheet> <group colspan="2" col="2"> <field name='name'/> <field name='category_id'/> @@ -355,45 +361,14 @@ </group> <group colspan="2" col="2"> </group> + <group> <field name='description'/> + </group> + </sheet> </form> </field> </record> - <record model="ir.ui.view" id="products_kanban_view"> - <field name="name">Products Kanban</field> - <field name="model">lunch.product</field> - <field name="arch" type="xml"> - <kanban default_group_by="category_id"> - <templates> - <t t-name="kanban-box"> - <div class="oe_kanban_color_0 oe_kanban_card oe_kanban_global_click oe_kanban_draghandle"> - <div class="oe_kanban_vignette oe_semantic_html_override"> - <div class="oe_kanban_details"> - <h3 class="oe_partner_heading"> - <a type="open"> - <u><field name="name"/><br/></u> - </a> - </h3> - <h4> - <a type="open"> - Price: - <field name="price"/> - € - <br/> - </a> - </h4> - Supplier: <field name="supplier"/><br/> - <font size="2" color="gray"><field name="description"/></font> - </div> - </div> - </div> - </t> - </templates> - </kanban> - </field> - </record> - <!--view for cashmove--> <record model="ir.ui.view" id="casmove_tree_view"> <field name="name">cashmove tree</field> @@ -414,15 +389,21 @@ <field name="model">lunch.cashmove</field> <field name="type">form</field> <field name="arch" type="xml"> - <form string="cashmove form"> - <group colspan="2" col="2"> - <field name="user_id"/> - <field name="date"/> - <field name="amount"/> - </group> - <group colspan="2" col="2"> - </group> - <field name="description"/> + <form string="cashmove form" version="7.0"> + <header> + </header> + <sheet> + <group colspan="2" col="2"> + <field name="user_id"/> + <field name="date"/> + <field name="amount"/> + </group> + <group colspan="2" col="2"> + </group> + <group> + <field name="description"/> + </group> + </sheet> </form> </field> </record> @@ -443,12 +424,15 @@ </field> </record> - <record model="ir.ui.view" id="alert_form_view"> + <record model="ir.ui.view" id="alert_form_view"> <field name="name">alert tree</field> <field name="model">lunch.alert</field> <field name="type">form</field> <field name="arch" type="xml"> - <form string="alert tree"> + <form string="alert tree" version="7.0"> + <header> + </header> + <sheet> <separator string="Schedule Date" colspan="4"/> <group col="2" colspan="2"> <field name="day"/> @@ -481,6 +465,7 @@ </group> <group col="2" colspan="2"> </group> + </sheet> </form> </field> </record> diff --git a/addons/lunch_new/partner_view.xml b/addons/lunch_new/view/partner_view.xml index c5cdb8c8995..c5cdb8c8995 100644 --- a/addons/lunch_new/partner_view.xml +++ b/addons/lunch_new/view/partner_view.xml |
