diff --git a/addons/account/__openerp__.py b/addons/account/__openerp__.py
index 221a58e35d1..e6f356e0a44 100644
--- a/addons/account/__openerp__.py
+++ b/addons/account/__openerp__.py
@@ -100,6 +100,7 @@ module named account_voucher.
'wizard/account_reconcile_partner_process_view.xml',
'wizard/account_automatic_reconcile_view.xml',
'wizard/account_financial_report_view.xml',
+ 'wizard/pos_box.xml',
'project/wizard/project_account_analytic_line_view.xml',
'account_end_fy.xml',
'account_invoice_view.xml',
diff --git a/addons/account/account.py b/addons/account/account.py
index 75bfc891980..df446abc3bc 100644
--- a/addons/account/account.py
+++ b/addons/account/account.py
@@ -739,6 +739,10 @@ class account_journal(osv.osv):
'entry_posted': fields.boolean('Skip \'Draft\' State for Manual Entries', help='Check this box if you don\'t want new journal entries to pass through the \'draft\' state and instead goes directly to the \'posted state\' without any manual validation. \nNote that journal entries that are automatically created by the system are always skipping that state.'),
'company_id': fields.many2one('res.company', 'Company', required=True, select=1, help="Company related to this journal"),
'allow_date':fields.boolean('Check Date in Period', help= 'If set to True then do not accept the entry if the entry date is not into the period dates'),
+
+ 'profit_account_id' : fields.many2one('account.account', 'Profit Account'),
+ 'loss_account_id' : fields.many2one('account.account', 'Loss Account'),
+ 'internal_account_id' : fields.many2one('account.account', 'Internal Transfers Account', select=1),
}
_defaults = {
diff --git a/addons/account/account_cash_statement.py b/addons/account/account_cash_statement.py
index f21bd7e9a36..9cec8dfc723 100644
--- a/addons/account/account_cash_statement.py
+++ b/addons/account/account_cash_statement.py
@@ -188,6 +188,14 @@ class account_cash_statement(osv.osv):
result[line.statement_id.id] = True
return result.keys()
+ def _compute_difference(self, cr, uid, ids, fieldnames, args, context=None):
+ result = dict.fromkeys(ids, 0.0)
+
+ for obj in self.browse(cr, uid, ids, context=context):
+ result[obj.id] = obj.balance_end - obj.balance_end_cash
+
+ return result
+
_columns = {
'total_entry_encoding': fields.function(_get_sum_entry_encoding, string="Cash Transaction", help="Total cash transactions",
store = {
@@ -198,6 +206,7 @@ class account_cash_statement(osv.osv):
'balance_end_cash': fields.function(_balance_end_cash, store=False, string='Closing Balance', help="Closing balance based on cashBox"),
'details_ids' : fields.one2many('account.cashbox.line', 'bank_statement_id', string='CashBox Lines'),
'user_id': fields.many2one('res.users', 'Responsible', required=False),
+ 'difference' : fields.function(_compute_difference, method=True, string="Difference", type="float"),
}
_defaults = {
@@ -234,7 +243,8 @@ class account_cash_statement(osv.osv):
for line in vals.get('details_ids',[]):
print "line: %r" % (line,)
if line and len(line)==3 and line[2]:
- amount_total+= line[2]['pieces'] * line[2]['number_opening']
+ # FIXME: If there is no piece # does not work with GTK
+ amount_total+= line[2].get('pieces', 0) * line[2]['number_opening']
vals.update(balance_start= amount_total)
vals.update(balance_end_real=self._compute_balance_end_real(cr, uid, vals['journal_id'], context=context))
@@ -287,7 +297,7 @@ class account_cash_statement(osv.osv):
balance_start = 0.0
if journal_id:
count = self.search_count(cr, uid, [('journal_id', '=', journal_id),('state', '=', 'open')], context=None)
- if count:
+ if 0: # count:
journal = self.pool.get('account.journal').browse(cr, uid, journal_id, context=context)
raise osv.except_osv(_('Error !'), (_('The Account Journal %s is opened by an other Cash Register !') % (journal.name,)))
else:
@@ -380,6 +390,33 @@ class account_cash_statement(osv.osv):
def button_confirm_cash(self, cr, uid, ids, context=None):
super(account_cash_statement, self).button_confirm_bank(cr, uid, ids, context=context)
+ absl_proxy = self.pool.get('account.bank.statement.line')
+
+ TABLES = (('Profit', 'profit_account_id'), ('Loss', 'loss_account_id'),)
+
+ for obj in self.browse(cr, uid, ids, context=context):
+ if obj.difference == 0.0:
+ continue
+
+ for item_label, item_account in TALBES:
+ if getattr(obj.journal_id, item_account):
+ raise osv.except_osv(_('Error !'),
+ _('There is no %s Account on the Journal %s') % (item_label, obj.journal_id.name,))
+
+ is_profit = obj.difference < 0.0
+
+ account = getattr(obj.journal_id, TABLES[is_profit][1])
+
+ values = {
+ 'statement_id' : obj.id,
+ 'journal_id' : obj.journal_id.id,
+ 'account_id' : account.id,
+ 'amount' : obj.difference,
+ 'name' : 'Exceptional %s' % TABLES[is_profit][0],
+ }
+
+ absl_proxy.create(cr, uid, values, context=context)
+
return self.write(cr, uid, ids, {'closing_date': time.strftime("%Y-%m-%d %H:%M:%S")}, context=context)
def button_cancel(self, cr, uid, ids, context=None):
diff --git a/addons/account/account_view.xml b/addons/account/account_view.xml
index 5258b876ad2..273035fbc2a 100644
--- a/addons/account/account_view.xml
+++ b/addons/account/account_view.xml
@@ -505,11 +505,17 @@
-
+
+
+
+
+
+
+
@@ -2659,12 +2665,13 @@ action = pool.get('res.config').next(cr, uid, [], context)
-
+
+
-
+
-
+
@@ -2677,7 +2684,7 @@ action = pool.get('res.config').next(cr, uid, [], context)
-
+
@@ -2690,6 +2697,7 @@ action = pool.get('res.config').next(cr, uid, [], context)
+
diff --git a/addons/account/wizard/__init__.py b/addons/account/wizard/__init__.py
index a78cf12050b..87a053d558c 100644
--- a/addons/account/wizard/__init__.py
+++ b/addons/account/wizard/__init__.py
@@ -64,6 +64,8 @@ import account_report_account_balance
import account_change_currency
+import pos_box;
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/account/wizard/pos_box.py b/addons/account/wizard/pos_box.py
new file mode 100644
index 00000000000..a9e752397e0
--- /dev/null
+++ b/addons/account/wizard/pos_box.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+from osv import osv, fields
+import decimal_precision as dp
+
+class CashBox(osv.osv_memory):
+ _register = False
+ _columns = {
+ 'name' : fields.char('Reason', size=64, required=True),
+ # Attention, we don't set a domain, because there is a journal_type key
+ # in the context of the action
+ 'amount' : fields.float('Amount',
+ digits_compute = dp.get_precision('Account'),
+ required=True),
+ }
+
+ def run(self, cr, uid, ids, context=None):
+ if not context:
+ context = dict()
+
+ active_model = context.get('active_model', False) or False
+ active_ids = context.get('active_ids', []) or []
+
+ records = self.pool.get(active_model).browse(cr, uid, active_ids, context=context)
+
+ return self._run(cr, uid, ids, records, context=None)
+
+ def _run(self, cr, uid, ids, records, context=None):
+ for box in self.browse(cr, uid, ids, context=context):
+ for record in records:
+ if not record.journal_id.internal_account_id:
+ raise osv.except_osv(_('Error !'),
+ _('Please check that internal account is set to %s') % (record.journal_id.name,))
+
+ self._create_bank_statement_line(cr, uid, box, record, context=context)
+
+ return {}
+
+
+class CashBoxIn(CashBox):
+ _name = 'cash.box.in'
+
+ _columns = CashBox._columns.copy()
+ _columns.update({
+ 'ref' : fields.char('Reference', size=32),
+ })
+
+ def _create_bank_statement_line(self, cr, uid, box, record, context=None):
+ absl_proxy = self.pool.get('account.bank.statement.line')
+
+ values = {
+ 'statement_id' : record.id,
+ 'journal_id' : record.journal_id.id,
+ 'account_id' : record.journal_id.internal_account_id.id,
+ 'amount' : box.amount or 0.0,
+ 'ref' : "%s" % (box.ref or ''),
+ 'name' : box.name,
+ }
+
+ return absl_proxy.create(cr, uid, values, context=context)
+
+CashBoxIn()
+
+class CashBoxOut(CashBox):
+ _name = 'cash.box.out'
+
+ def _create_bank_statement_line(self, cr, uid, box, record, context=None):
+ absl_proxy = self.pool.get('account.bank.statement.line')
+
+ amount = box.amount or 0.0
+ values = {
+ 'statement_id' : record.id,
+ 'journal_id' : record.journal_id.id,
+ 'account_id' : record.journal_id.internal_account_id.id,
+ 'amount' : -amount if amount > 0.0 else amount,
+ 'name' : box.name,
+ }
+
+ return absl_proxy.create(cr, uid, values, context=context)
+
+CashBoxOut()
diff --git a/addons/account/wizard/pos_box.xml b/addons/account/wizard/pos_box.xml
new file mode 100644
index 00000000000..6136cca06ad
--- /dev/null
+++ b/addons/account/wizard/pos_box.xml
@@ -0,0 +1,62 @@
+
+
+
+
+ cash_box_in
+ cash.box.in
+ form
+
+
+
+
+
+
+
+
+ cash_box_out
+ cash.box.out
+ form
+
+
+
+
+
+
+
+
diff --git a/addons/point_of_sale/__openerp__.py b/addons/point_of_sale/__openerp__.py
index 24a8db4a3da..37468e42d22 100644
--- a/addons/point_of_sale/__openerp__.py
+++ b/addons/point_of_sale/__openerp__.py
@@ -51,14 +51,13 @@ Main features :
'wizard/pos_discount.xml',
'wizard/pos_open_statement.xml',
'wizard/pos_close_statement.xml',
- 'wizard/pos_box_entries.xml',
'wizard/pos_payment_report_user_view.xml',
- 'wizard/pos_box_out.xml',
'wizard/pos_sales_user.xml',
'wizard/pos_receipt_view.xml',
'wizard/pos_payment_report_user.xml',
'wizard/pos_payment_report.xml',
'wizard/pos_payment.xml',
+ 'wizard/pos_box.xml',
'point_of_sale_report.xml',
'point_of_sale_view.xml',
'report/pos_order_report_view.xml',
diff --git a/addons/point_of_sale/account_bank_statement.py b/addons/point_of_sale/account_bank_statement.py
index cc350c8a116..ab03b61ba43 100644
--- a/addons/point_of_sale/account_bank_statement.py
+++ b/addons/point_of_sale/account_bank_statement.py
@@ -27,10 +27,9 @@ class account_journal(osv.osv):
_columns = {
'journal_user': fields.boolean('PoS Payment Method', help="Check this box if this journal define a payment method that can be used in point of sales."),
- 'opening_control': fields.boolean('Opening Control'),
- 'closing_control': fields.boolean('Closing Control'),
+ 'opening_control': fields.boolean('Opening Control', help="If you want the journal should be control at opening, check this option"),
+ 'closing_control': fields.boolean('Closing Control', help="If you want the journal should be control at closing, check this option"),
- 'internal_account_id' : fields.many2one('account.account', 'Internal Transfers Account', select=1),
}
_defaults = {
'opening_control' : True,
diff --git a/addons/point_of_sale/account_statement_view.xml b/addons/point_of_sale/account_statement_view.xml
index cfe6d855454..9bc039a1852 100644
--- a/addons/point_of_sale/account_statement_view.xml
+++ b/addons/point_of_sale/account_statement_view.xml
@@ -14,7 +14,6 @@
-
diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py
index f27db1537f1..93efebbad3d 100644
--- a/addons/point_of_sale/point_of_sale.py
+++ b/addons/point_of_sale/point_of_sale.py
@@ -40,9 +40,9 @@ class pos_config(osv.osv):
_columns = {
'name' : fields.char('Name', size=32, select=1, required=True),
- 'journal_ids' : fields.many2many('account.journal', 'pos_config_journal_rel', 'pos_config_id', 'journal_id', 'Payment Methods'),
+ 'journal_ids' : fields.many2many('account.journal', 'pos_config_journal_rel', 'pos_config_id', 'journal_id', 'Payment Methods', domain="[('journal_user', '=', True )]"),
'shop_id' : fields.many2one('sale.shop', 'Shop', required=True, select=1),
- 'journal_id' : fields.many2one('account.journal', 'Journal', required=True, select=1),
+ 'journal_id' : fields.many2one('account.journal', 'Journal', required=True, select=1, domain=[('type', '=', 'sale')]),
'profit_account_id' : fields.many2one('account.account', 'Profit Account', required=True, select=1),
'loss_account_id' : fields.many2one('account.account', 'Loss Account', required=True, select=1),
@@ -350,6 +350,7 @@ class pos_order(osv.osv):
'partner_id': fields.many2one('res.partner', 'Customer', change_default=True, select=1, states={'draft': [('readonly', False)], 'paid': [('readonly', False)]}),
'session_id' : fields.many2one('pos.session', 'Session',
+ #required=True,
select=1,
domain="[('state', '=', 'opened')]",
states={'draft' : [('readonly', False)]},
@@ -654,7 +655,8 @@ class pos_order(osv.osv):
property_obj=self.pool.get('ir.property')
for order in self.browse(cr, uid, ids, context=context):
- if order.state<>'paid': continue
+ if order.state != 'paid':
+ continue
curr_c = res_obj.browse(cr, uid, uid).company_id
comp_id = res_obj.browse(cr, order.user_id.id, order.user_id.id).company_id
@@ -667,6 +669,7 @@ class pos_order(osv.osv):
# Create an entry for the sale
move_id = account_move_obj.create(cr, uid, {
+ 'ref' : order.name,
'journal_id': order.sale_journal.id,
}, context=context)
@@ -714,10 +717,9 @@ class pos_order(osv.osv):
if tax_code_id:
break
-
# Create a move for the line
account_move_line_obj.create(cr, uid, {
- 'name': line.name,
+ 'name': line.product_id.name,
'date': order.date_order[:10],
'ref': order.name,
'quantity': line.qty,
@@ -746,7 +748,7 @@ class pos_order(osv.osv):
continue
account_move_line_obj.create(cr, uid, {
- 'name': "Tax" + line.name,
+ 'name': "Tax" + line.name + " (%s)" % (tax.name),
'date': order.date_order[:10],
'ref': order.name,
'product_id':line.product_id.id,
@@ -785,7 +787,7 @@ class pos_order(osv.osv):
# counterpart
to_reconcile.append(account_move_line_obj.create(cr, uid, {
- 'name': order.name,
+ 'name': "Trade Receivables", #order.name,
'date': order.date_order[:10],
'ref': order.name,
'move_id': move_id,
@@ -799,6 +801,7 @@ class pos_order(osv.osv):
'period_id': period,
'partner_id': order.partner_id and order.partner_id.id or False
}, context=context))
+
self.write(cr, uid, order.id, {'state':'done', 'account_move': move_id}, context=context)
return True
@@ -806,8 +809,7 @@ class pos_order(osv.osv):
return self.write(cr, uid, ids, {'state': 'payment'}, context=context)
def action_paid(self, cr, uid, ids, context=None):
- context = context or {}
- self.create_picking(cr, uid, ids, context=None)
+ self.create_picking(cr, uid, ids, context=context)
self.write(cr, uid, ids, {'state': 'paid'}, context=context)
return True
diff --git a/addons/point_of_sale/point_of_sale_view.xml b/addons/point_of_sale/point_of_sale_view.xml
index edd1d65a41d..48ba4c15700 100644
--- a/addons/point_of_sale/point_of_sale_view.xml
+++ b/addons/point_of_sale/point_of_sale_view.xml
@@ -18,7 +18,7 @@