diff --git a/addons/point_of_sale/__terp__.py b/addons/point_of_sale/__terp__.py index b1838a28fc1..153584f6a26 100644 --- a/addons/point_of_sale/__terp__.py +++ b/addons/point_of_sale/__terp__.py @@ -41,7 +41,7 @@ Main features : 'init_xml': [], 'update_xml': [ - 'security/point_of_sale_security.xml', + 'security/point_of_sale_security.xml', 'security/ir.model.access.csv', 'wizard/pos_details.xml', 'wizard/pos_add_product.xml', @@ -72,7 +72,7 @@ Main features : 'statement_view.xml', 'statement_report.xml', 'statement_data.xml', - 'statement_wizard.xml', + 'statement_wizard.xml', ], 'demo_xml': ['pos_demo.xml','singer_statement_demo.xml','multi_company_stock_data.xml'], 'installable': True, diff --git a/addons/point_of_sale/pos_wizard.xml b/addons/point_of_sale/pos_wizard.xml index 2e09b5cc9df..50e3630c4d7 100644 --- a/addons/point_of_sale/pos_wizard.xml +++ b/addons/point_of_sale/pos_wizard.xml @@ -10,7 +10,6 @@ - @@ -63,12 +62,12 @@ string="Close Statements"/>--> - + string="All Cashboxes Of the day"/> diff --git a/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py b/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py index f3c21da2dcb..2490d5719cd 100644 --- a/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py +++ b/addons/point_of_sale/report/all_closed_cashbox_of_the_day.py @@ -138,6 +138,4 @@ class all_closed_cashbox_of_the_day(report_sxw.rml_parse): res = self.cr.dictfetchall() return res[0]['net_total'] or 0.0 - report_sxw.report_sxw('report.all.closed.cashbox.of.the.day', 'account.bank.statement', 'addons/point_of_sale/report/all_closed_cashbox_of_the_day.rml', parser=all_closed_cashbox_of_the_day) - diff --git a/addons/point_of_sale/report/pos_receipt.rml b/addons/point_of_sale/report/pos_receipt.rml index 1d5e70241c7..1d2e6edc9d0 100644 --- a/addons/point_of_sale/report/pos_receipt.rml +++ b/addons/point_of_sale/report/pos_receipt.rml @@ -104,9 +104,7 @@ E-mail : [[ address and address.email ]] Shop : [[ o.shop_id.name ]] Vendeur : [[ o.user_id1.name ]] - Date : [[ formatLang(o.date_order,date = True) ]] - diff --git a/addons/point_of_sale/statement_report.xml b/addons/point_of_sale/statement_report.xml index 7bdece39a77..8118d2e834d 100644 --- a/addons/point_of_sale/statement_report.xml +++ b/addons/point_of_sale/statement_report.xml @@ -22,7 +22,7 @@ rml="point_of_sale/report/account_statement.rml" /> - -======= rml="point_of_sale/report/all_closed_cashbox_of_the_day.rml" /> ->>>>>>> MERGE-SOURCE - + parent="menu_statement_tree_all"/> - - - - + - + parent="menu_point_report_register"/> diff --git a/addons/point_of_sale/wizard/__init__.py b/addons/point_of_sale/wizard/__init__.py index 1384fb8329a..82d9ea9409a 100644 --- a/addons/point_of_sale/wizard/__init__.py +++ b/addons/point_of_sale/wizard/__init__.py @@ -23,8 +23,15 @@ #import wizard_pos_payment import wizard_default_journal import wizard_scan_product + import wizard_return + + + + + #import wizard_open_statement + import pos_add_product import pos_confirm import pos_discount diff --git a/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py b/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py new file mode 100644 index 00000000000..0968c6c71d4 --- /dev/null +++ b/addons/point_of_sale/wizard/all_closed_cashbox_of_the_day.py @@ -0,0 +1,60 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +import netsvc +from osv import osv,fields +from tools.translate import _ +from mx import DateTime +import time + +class all_closed_cashbox_of_the_day(osv.osv_memory): + _name = 'all.closed.cashbox.of.the.day' + _description = 'All closed cashbox of the day' + + _columns = { + + } + + def print_report(self, cr, uid, ids, context=None): + + """ + To get the date and print the report + + @param self: The object pointer. + @param cr: A database cursor + @param uid: ID of the user currently logged in + @param context: A standard dictionary + @return : retrun report + """ + datas = {'ids' : context.get('active_ids',[])} + res = {} + datas['form'] = res + + return { + 'type' : 'ir.actions.report.xml', + 'report_name':'all.closed.cashbox.of.the.day', + 'datas' : datas, + } + +all_closed_cashbox_of_the_day() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/point_of_sale/wizard/pos_receipt.py b/addons/point_of_sale/wizard/pos_receipt.py index a812ad342a4..27cdfd19ad0 100644 --- a/addons/point_of_sale/wizard/pos_receipt.py +++ b/addons/point_of_sale/wizard/pos_receipt.py @@ -22,7 +22,6 @@ import netsvc from osv import osv,fields from tools.translate import _ - from mx import DateTime import time @@ -63,4 +62,3 @@ pos_receipt() - diff --git a/addons/point_of_sale/wizard/wizard_return.py b/addons/point_of_sale/wizard/wizard_return.py new file mode 100644 index 00000000000..591fd00b18a --- /dev/null +++ b/addons/point_of_sale/wizard/wizard_return.py @@ -0,0 +1,546 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +############################################################################## + +import wizard +import pooler +from tools.misc import UpdateableStr + +import netsvc +import time + +from tools.translate import _ +from decimal import Decimal + + +arch=UpdateableStr() +fields={} + + +def _get_journal(self, cr, uid, context): + pool = pooler.get_pool(cr.dbname) + obj = pool.get('account.journal') + c=pool.get('res.users').browse(cr,uid,uid).company_id.id + ids = obj.search(cr, uid, [('type', '=', 'cash'), ('company_id','=',c)]) + res = obj.read(cr, uid, ids, ['id', 'name'], context) + res = [(r['id'], r['name']) for r in res] + return res + + +payment_form = """ +
+ + + + + + + +""" + +payment_fields = { + 'amount': {'string': 'Amount', 'type': 'float', 'required': True}, + 'invoice_wanted': {'string': 'Invoice', 'type': 'boolean'}, + 'journal': {'string': 'Journal', + 'type': 'selection', + 'selection': _get_journal, + 'required': True, + }, + 'payment_date': {'string': 'Payment date', 'type': 'date', 'required': True}, + 'payment_name': {'string': 'Payment name', 'type': 'char', 'size': '32', 'required':True, 'default':'Payment'}, + 'num_sale': {'string': 'Num.Cof', 'type': 'char', 'size': '32'}, + } + + +def _pre_init(self, cr, uid, data, context): + def _get_journal(pool, order): + j_obj = pool.get('account.journal') + + journal_to_fetch = 'DEFAULT' + if order.amount_total < 0: + journal_to_fetch = 'GIFT' + else: + if order.amount_paid > 0: + journal_to_fetch = 'REBATE' + + pos_config_journal = pool.get('pos.config.journal') + ids = pos_config_journal.search(cr, uid, [('code', '=', journal_to_fetch)]) + objs = pos_config_journal.browse(cr, uid, ids) + journal='' + if objs: + journal = objs[0].journal_id.id + else: + existing = [payment.journal_id.id for payment in order.payments] + ids = j_obj.search(cr, uid, [('type', '=', 'cash')]) + for i in ids: + if i not in existing: + journal = i + break + if not journal: + journal = ids and ids[0] + return journal + pool = pooler.get_pool(cr.dbname) + order = pool.get('pos.order').browse(cr, uid, data['id'], context) + # get amount to pay: +# amount = Decimal(str(order.amount_total)) - Decimal(str(order.amount_paid)) + amount = order.amount_total - order.amount_paid + if amount <= 0: + pool.get('pos.order').action_paid(cr, uid, data['ids'], context) + + # get journal: + journal = _get_journal(pool, order) + + # check if an invoice is wanted: + #invoice_wanted_checked = not not order.partner_id # not not -> boolean + invoice_wanted_checked = False + + # select the current date + current_date = time.strftime('%Y-%m-%d') + + return {'journal': journal, 'amount': amount, 'invoice_wanted': invoice_wanted_checked, 'payment_date': current_date} + + +def _add_pay(self, cr, uid, data, context): + pool = pooler.get_pool(cr.dbname) + order_obj = pool.get('pos.order') + jrnl_obj = pool.get('account.journal') + result = data['form'] + invoice_wanted = data['form']['invoice_wanted'] + jrnl_used=False + if data['form'] and data['form'].get('journal',False): + jrnl_used=jrnl_obj.browse(cr,uid,data['form']['journal']) + + # add 'invoice_wanted' in 'pos.order' + order_obj.write(cr, uid, [data['id']], {'invoice_wanted': invoice_wanted}) + + order_obj.add_payment(cr, uid, data['id'], result, context=context) + return {} + + +def _check(self, cr, uid, data, context): + """Check the order: + if the order is not paid: continue payment, + if the order is paid print invoice (if wanted) or ticket. + """ + pool = pooler.get_pool(cr.dbname) + order_obj = pool.get('pos.order') + order = order_obj.browse(cr, uid, data['id'], context) + order_obj.test_order_lines(cr, uid, order, context=context) + + action = 'ask_pay' + if order.state == 'paid': + if order.partner_id: + if order.invoice_wanted: + action = 'invoice' + else: + action = 'paid' + elif order.date_payment: + action = 'receipt' + else: + action='paid' + + if order.amount_total == order.amount_paid: + order_obj.write(cr,uid,data['ids'],{'state':'done'}) + action = 'receipt' + + return action + + +def create_invoice(self, cr, uid, data, context): + wf_service = netsvc.LocalService("workflow") + for i in data['ids']: + wf_service.trg_validate(uid, 'pos.order', i, 'invoice', cr) + return {} + + + +_form = """ +
+ + + +""" +_fields = { + 'product': { + 'string': 'Product', + 'type': 'many2one', + 'relation': 'product.product', + 'required': True, + 'default': False + }, + + 'quantity': { + 'string': 'Quantity', + 'type': 'integer', + 'required': True, + 'default': 1}, + } + +def make_default(val): + def fct(obj, cr, uid): + return val + return fct + +def _get_returns(self, cr, uid, data, context): + + pool = pooler.get_pool(cr.dbname) + order_obj=pool.get('pos.order') + order=order_obj.browse(cr, uid, [data['id']])[0] + res={} + fields.clear() + arch_lst=['', '
' % _('Return lines'), '