Point_of_sale Task Id 578: Rename field,merge the account_bank_statement,remove the unused code
bzr revid: sbh@tinyerp.com-20100423092032-pcksh6rn4oj4rnxr
This commit is contained in:
@@ -25,7 +25,7 @@ import stock
|
||||
import wizard
|
||||
import report
|
||||
import pos_account_bank_statement
|
||||
import account_bank_statement
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ Main features :
|
||||
""",
|
||||
'author': 'Tiny',
|
||||
'depends': ['sale', 'delivery'],
|
||||
# 'depends': ['sale', 'purchase', 'account', 'account_tax_include','board','mrp','board_manufacturing','delivery','profile_manufacturing','account','multi_company'],
|
||||
'init_xml': [],
|
||||
|
||||
'update_xml': [
|
||||
@@ -73,7 +72,6 @@ Main features :
|
||||
'statement_view.xml',
|
||||
'statement_report.xml',
|
||||
'statement_data.xml',
|
||||
'statement_wizard.xml',
|
||||
],
|
||||
'demo_xml': ['pos_demo.xml','singer_statement_demo.xml','multi_company_stock_data.xml'],
|
||||
'installable': True,
|
||||
|
||||
@@ -1,249 +0,0 @@
|
||||
# encoding: utf-8
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2008 PC Solutions (<http://pcsol.be>). 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
import time
|
||||
from mx import DateTime
|
||||
from decimal import Decimal
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
class account_journal(osv.osv):
|
||||
|
||||
_inherit = 'account.journal'
|
||||
_columns = {
|
||||
'auto_cash': fields.boolean('Automatic Opening', help="This field authorize the automatic creation of the cashbox"),
|
||||
'special_journal':fields.boolean('Special Journal', help="Will put all the orders in waiting status till being accepted"),
|
||||
'check_dtls': fields.boolean('Check Details', help="This field authorize Validation of Cashbox without checking ending details"),
|
||||
'statement_sequence_id': fields.many2one('ir.sequence', 'Statement Sequence', \
|
||||
help="The sequence used for statement numbers in this journal."),
|
||||
}
|
||||
_defaults = {
|
||||
'check_dtls': lambda *a:True,
|
||||
'auto_cash': lambda *a:True,
|
||||
}
|
||||
account_journal()
|
||||
|
||||
|
||||
class singer_statement(osv.osv):
|
||||
|
||||
""" Singer Statements """
|
||||
|
||||
_name = 'singer.statement'
|
||||
_description = 'Statements'
|
||||
|
||||
def _sub_total(self, cr, uid, ids, name, arg, context=None):
|
||||
|
||||
""" Calculates Sub total"
|
||||
@param name: Names of fields.
|
||||
@param arg: User defined arguments
|
||||
@return: Dictionary of values.
|
||||
"""
|
||||
res = {}
|
||||
for obj in self.browse(cr, uid, ids):
|
||||
res[obj.id] = obj.pieces * obj.number
|
||||
return res
|
||||
|
||||
def on_change_sub(self, cr, uid, ids, pieces, number,*a):
|
||||
|
||||
""" Calculates Sub total on change of number
|
||||
@param pieces: Names of fields.
|
||||
@param number:
|
||||
"""
|
||||
sub=pieces*number
|
||||
return {'value':{'subtotal': sub or 0.0}}
|
||||
|
||||
_columns = {
|
||||
'pieces': fields.float('Values', digits=(16,2)),
|
||||
'number': fields.integer('Number'),
|
||||
'subtotal': fields.function(_sub_total, method=True, string='Sub Total', type='float',digits=(16,2)),
|
||||
'starting_id': fields.many2one('account.bank.statement',ondelete='cascade'),
|
||||
'ending_id': fields.many2one('account.bank.statement',ondelete='cascade'),
|
||||
}
|
||||
|
||||
singer_statement()
|
||||
|
||||
class account_bank_statement(osv.osv):
|
||||
|
||||
_inherit = 'account.bank.statement'
|
||||
|
||||
def _get_starting_balance(self, cr, uid, ids, name, arg, context=None):
|
||||
|
||||
""" Find starting balance "
|
||||
@param name: Names of fields.
|
||||
@param arg: User defined arguments
|
||||
@return: Dictionary of values.
|
||||
"""
|
||||
res ={}
|
||||
for statement in self.browse(cr, uid, ids):
|
||||
amount_total=0.0
|
||||
for line in statement.starting_details_ids:
|
||||
amount_total+= line.pieces * line.number
|
||||
res[statement.id]=amount_total
|
||||
return res
|
||||
|
||||
def _get_sum_entry_encoding(self, cr, uid, ids, name, arg, context=None):
|
||||
|
||||
""" Find encoding total of statements "
|
||||
@param name: Names of fields.
|
||||
@param arg: User defined arguments
|
||||
@return: Dictionary of values.
|
||||
"""
|
||||
res2={}
|
||||
for statement in self.browse(cr, uid, ids):
|
||||
encoding_total=0.0
|
||||
for line in statement.line_ids:
|
||||
encoding_total+= line.amount
|
||||
res2[statement.id]=encoding_total
|
||||
return res2
|
||||
|
||||
def _default_journal_id(self, cr, uid, context={}):
|
||||
|
||||
""" To get default journal for the object"
|
||||
@param name: Names of fields.
|
||||
@return: journal
|
||||
"""
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
|
||||
journal = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash'), ('auto_cash','=',False), ('company_id', '=', company_id)])
|
||||
if journal:
|
||||
return journal[0]
|
||||
else:
|
||||
return False
|
||||
|
||||
_columns = {
|
||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
|
||||
'balance_start': fields.function(_get_starting_balance, method=True, string='Starting Balance', type='float',digits=(16,2)),
|
||||
'state': fields.selection([('draft', 'Draft'),('confirm', 'Confirm'),('open','Open')],
|
||||
'State', required=True, states={'confirm': [('readonly', True)]}, readonly="1"),
|
||||
'total_entry_encoding':fields.function(_get_sum_entry_encoding, method=True, string="Total of Entry encoding"),
|
||||
'date':fields.datetime("Opening Date"),
|
||||
'closing_date':fields.datetime("Closing Date"),
|
||||
'starting_details_ids': fields.one2many('singer.statement', 'starting_id', string='Starting Details'),
|
||||
'ending_details_ids': fields.one2many('singer.statement', 'ending_id', string='Ending Details'),
|
||||
'name': fields.char('Name', size=64, required=True, readonly=True),
|
||||
|
||||
}
|
||||
_defaults = {
|
||||
'state': lambda *a: 'draft',
|
||||
'name': lambda *a: '/',
|
||||
'date': lambda *a:time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'journal_id': _default_journal_id,
|
||||
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
|
||||
company_id = vals and vals.get('company_id',False)
|
||||
if company_id:
|
||||
open_jrnl = self.search(cr, uid, [('company_id', '=', vals['company_id']), ('journal_id', '=', vals['journal_id']), ('state', '=', 'open')])
|
||||
if open_jrnl:
|
||||
raise osv.except_osv('Error', u'Une caisse de type espèce est déjà ouverte')
|
||||
if 'starting_details_ids' in vals:
|
||||
vals['starting_details_ids'] = starting_details_ids = map(list, vals['starting_details_ids'])
|
||||
for i in starting_details_ids:
|
||||
if i and i[0] and i[1]:
|
||||
i[0], i[1] = 0, 0
|
||||
res = super(account_bank_statement, self).create(cr, uid, vals, context=context)
|
||||
return res
|
||||
|
||||
def onchange_journal_id(self, cursor, user, statement_id, journal_id, context=None):
|
||||
|
||||
""" Changes balance start and starting details if journal_id changes"
|
||||
@param statement_id: Changed statement_id
|
||||
@param journal_id: Changed journal_id
|
||||
@return: Dictionary of changed values
|
||||
"""
|
||||
id_s=[]
|
||||
if not journal_id:
|
||||
return {'value': {'balance_start': 0.0}}
|
||||
balance_start=0.0
|
||||
cash_obj = self.pool.get('singer.statement')
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
cursor.execute("Select a.id from account_bank_statement a where journal_id=%d and user_id=%d order by a.id desc limit 1"%(journal_id,user))
|
||||
res2=cursor.fetchone()
|
||||
res2=res2 and res2[0] or None
|
||||
if res2:
|
||||
statmt_id=statement_obj.browse(cursor,user,res2)
|
||||
check_det=statmt_id.journal_id.check_dtls
|
||||
if not check_det:
|
||||
balance_start=statmt_id.balance_end_real or 0.0
|
||||
return {'value': {'balance_start': balance_start}}
|
||||
cursor.execute("Select a.id from account_bank_statement a, singer_statement s where journal_id=%d and user_id=%d order by a.id desc limit 1"%(journal_id,user))
|
||||
res1=cursor.fetchone()
|
||||
res1=res1 and res1[0] or None
|
||||
if res1:
|
||||
cursor.execute("Select sum(ss.pieces*ss.number),ss.ending_id from singer_statement ss, account_bank_statement s where ss.ending_id=s.id and s.journal_id=%d and s.user_id=%d and s.id=%d group by ss.ending_id,s.id order by s.id desc"%(journal_id,user, res1))
|
||||
res = cursor.fetchone()
|
||||
balance_start = res and res[0] or 0.0
|
||||
cash_end=res and res[1] or None
|
||||
id_s=statement_obj.browse(cursor,user,cash_end).ending_details_ids
|
||||
new=[]
|
||||
if id_s:
|
||||
for s in id_s:
|
||||
new.append(s.id)
|
||||
return {'value': {'balance_start': balance_start, 'starting_details_ids':new}}
|
||||
|
||||
def button_open(self, cr, uid, ids, context=None):
|
||||
|
||||
""" Changes statement state to Running.
|
||||
@return: True
|
||||
"""
|
||||
obj_inv = self.browse(cr, uid, ids)[0]
|
||||
s_id=obj_inv.journal_id
|
||||
if s_id.statement_sequence_id:
|
||||
s_id=s_id.id
|
||||
number = self.pool.get('ir.sequence').get_id(cr, uid, s_id)
|
||||
else:
|
||||
number = self.pool.get('ir.sequence').get(cr, uid,
|
||||
'account.bank.statement')
|
||||
|
||||
self.write(cr, uid, ids, {'date':time.strftime("%Y-%m-%d %H:%M:%S"), 'state':'open', 'name':number})
|
||||
return True
|
||||
|
||||
def button_confirm(self, cr, uid, ids, context=None):
|
||||
|
||||
""" Check the starting and ending detail of statement
|
||||
@return: True
|
||||
"""
|
||||
val = 0.0
|
||||
val2 = 0.0
|
||||
val_statement_line = 0.0
|
||||
diff = self.pool.get('res.users').browse(cr,uid,uid).company_id.max_diff or 0.0
|
||||
for statement in self.browse(cr, uid, ids):
|
||||
bal = statement.balance_end
|
||||
bal_st=statement.balance_start
|
||||
for st in statement.line_ids:
|
||||
val_statement_line += st.amount
|
||||
for stat in statement.starting_details_ids:
|
||||
val2 += stat.subtotal
|
||||
for stat in statement.ending_details_ids:
|
||||
val += stat.subtotal
|
||||
if statement.journal_id.check_dtls:
|
||||
if Decimal(str(val)).quantize(Decimal('.001')) != (Decimal(str(val_statement_line)) + Decimal(str(val2))).quantize(Decimal('.001')):
|
||||
raise osv.except_osv(_('Invalid action !'), _(' You can not confirm your cashbox, Please enter ending details, missing value matches to "%s"')%(abs(Decimal(str(val))-(Decimal(str(val_statement_line))+Decimal(str(val2))))))
|
||||
|
||||
self.write(cr, uid, statement.id, {'balance_end_real':Decimal(str(val_statement_line))+Decimal(str(val2)),'closing_date':time.strftime("%Y-%m-%d %H:%M:%S"),'state':'draft'})
|
||||
return super(account_bank_statement, self).button_confirm(cr, uid, ids, context=None)
|
||||
|
||||
account_bank_statement()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
|
||||
</record>
|
||||
<record id="ter_partner" model="res.partner">
|
||||
<field name="name">Tiny Integrator</field>
|
||||
<field name="name">OpenERP Integrator</field>
|
||||
</record>
|
||||
|
||||
<record id="ter_company" model="res.company">
|
||||
<field name="name">Tiny Integrator</field>
|
||||
<field name="name">OpenERP Integrator</field>
|
||||
<field name="partner_id" ref="base.main_partner"/>
|
||||
<field name="parent_id" ref="base.main_company"/>
|
||||
<field name="rml_header1">Free Business Solutions</field>
|
||||
|
||||
@@ -227,12 +227,6 @@ class pos_order(osv.osv):
|
||||
res[order.id] = val
|
||||
return res
|
||||
|
||||
# def payment_get(self, cr, uid, ids, context=None):
|
||||
# """ Calculates Total Returned from the order
|
||||
# @return: Dictionary of values """
|
||||
# cr.execute("select id from pos_payment where order_id =ANY(%s)",(ids,))
|
||||
# return [i[0] for i in cr.fetchall()]
|
||||
|
||||
def _sale_journal_get(self, cr, uid, context):
|
||||
|
||||
""" To get sale journal for this order"
|
||||
@@ -253,7 +247,6 @@ class pos_order(osv.osv):
|
||||
|
||||
company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
|
||||
res = self.pool.get('sale.shop').search(cr, uid, [])
|
||||
# res = self.pool.get('sale.shop').search(cr, uid, [('company_id', '=', company.id)])
|
||||
if res:
|
||||
return res[0]
|
||||
else:
|
||||
@@ -345,19 +338,9 @@ class pos_order(osv.osv):
|
||||
'first_name': fields.char('First Name', size=64),
|
||||
'state_2': fields.function(_get_v,type='selection',selection=[('to_verify', 'To Verify'), ('accepted', 'Accepted'),
|
||||
('refused', 'Refused')], string='State', readonly=True, method=True, store=True),
|
||||
|
||||
# 'last_name': fields.char('Last Name', size=64),
|
||||
# 'street': fields.char('Street', size=64),
|
||||
# 'zip2': fields.char('Zip', size=64),
|
||||
# 'city': fields.char('City', size=64),
|
||||
# 'mobile': fields.char('Mobile', size=64),
|
||||
# 'email': fields.char('Email', size=64),
|
||||
'note': fields.text('Internal Notes'),
|
||||
'nb_print': fields.integer('Number of Print', readonly=True),
|
||||
'sale_journal': fields.many2one('account.journal', 'Journal', required=True, states={'draft': [('readonly', False)]}, readonly=True, ),
|
||||
# 'account_receivable': fields.many2one('account.account',
|
||||
# 'Default Receivable', required=True, states={'draft': [('readonly', False)]},
|
||||
# readonly=True, ),
|
||||
'invoice_wanted': fields.boolean('Create Invoice'),
|
||||
'note_2': fields.char('Customer Note',size=64),
|
||||
'type_rec': fields.char('Type of Receipt',size=64),
|
||||
@@ -543,7 +526,6 @@ class pos_order(osv.osv):
|
||||
cr.execute("select s.id from stock_location s, stock_warehouse w where w.lot_stock_id=s.id and w.id= %d "%(order.shop_id.warehouse_id.id))
|
||||
res=cr.fetchone()
|
||||
location_id=res and res[0] or None
|
||||
# location_id = order and order.shop_id and order.shop_id.warehouse_id and order.shop_id.warehouse_id.lot_stock_id.id or None
|
||||
stock_dest_id = int(val.split(',')[1])
|
||||
if line.qty < 0:
|
||||
location_id, stock_dest_id = stock_dest_id, location_id
|
||||
@@ -1002,9 +984,7 @@ class pos_order(osv.osv):
|
||||
'statement_id': False,
|
||||
'account_id':order_account
|
||||
})
|
||||
# account_move_obj.button_validate(cr, uid, [move_id, payment_move_id], context=context)
|
||||
self.write(cr,uid,order.id,{'state':'done'})
|
||||
# account_move_line_obj.reconcile(cr, uid, to_reconcile, type='manual', context=context)
|
||||
return True
|
||||
|
||||
def cancel_picking(self, cr, uid, ids, context=None):
|
||||
@@ -1045,7 +1025,6 @@ class pos_order(osv.osv):
|
||||
for order in self.browse(cr, uid, ids, context=context):
|
||||
if not order.journal_entry:
|
||||
self.create_account_move(cr, uid, ids, context={})
|
||||
#self.write(cr, uid, ids, {'state': 'done'})
|
||||
return True
|
||||
|
||||
def compute_state(self, cr, uid, id):
|
||||
@@ -1119,7 +1098,6 @@ class pos_order_line(osv.osv):
|
||||
price = self.price_by_product(cr, uid, ids, line.order_id.pricelist_id.id, line.product_id.id, line.qty, line.order_id.partner_id.id)
|
||||
if line.discount!=0.0:
|
||||
res[line.id] = line.price_unit * line.qty * (1 - (line.discount or 0.0) / 100.0)
|
||||
# res[line.id] = price * line.qty * (1 - (line.discount or 0.0) / 100.0)
|
||||
else:
|
||||
res[line.id]=line.price_unit*line.qty
|
||||
return res
|
||||
@@ -1192,9 +1170,7 @@ class pos_order_line(osv.osv):
|
||||
'company_id':fields.many2one('res.company', 'Company', required=True),
|
||||
'notice': fields.char('Discount Notice', size=128, required=True),
|
||||
'serial_number': fields.char('Serial Number', size=128),
|
||||
# 'contract_number': fields.char('Contract Number', size=512),
|
||||
'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)], required=True, change_default=True),
|
||||
# 'price_unit': fields.float('Unit Price'),
|
||||
'price_unit': fields.function(_get_amount, method=True, string='Unit Price', store=True),
|
||||
'price_ded': fields.float('Discount(Amount)'),
|
||||
'qty': fields.float('Quantity'),
|
||||
@@ -1496,10 +1472,9 @@ class report_sales_by_margin_pos_month(osv.osv):
|
||||
_description = "Sales by margin monthly"
|
||||
_auto = False
|
||||
_columns = {
|
||||
# 'pos_name': fields.char('POS Order', size=64, readonly=True),
|
||||
|
||||
'product_name':fields.char('Product Name', size=64, readonly=True),
|
||||
'date_order': fields.date('Order Date',required=True, select=True),
|
||||
#'amount': fields.float('Total', readonly=True, select=True),
|
||||
'user_id': fields.many2one('res.users', 'User', readonly=True, select=True),
|
||||
'qty': fields.float('Qty', readonly=True, select=True),
|
||||
'net_margin_per_qty':fields.float('Net margin per Qty', readonly=True, select=True),
|
||||
|
||||
@@ -25,15 +25,221 @@ import time
|
||||
import netsvc
|
||||
|
||||
|
||||
class account_journal(osv.osv):
|
||||
|
||||
_inherit = 'account.journal'
|
||||
_columns = {
|
||||
'auto_cash': fields.boolean('Automatic Opening', help="This field authorize the automatic creation of the cashbox"),
|
||||
'special_journal':fields.boolean('Special Journal', help="Will put all the orders in waiting status till being accepted"),
|
||||
'check_dtls': fields.boolean('Check Details', help="This field authorize Validation of Cashbox without checking ending details"),
|
||||
'statement_sequence_id': fields.many2one('ir.sequence', 'Statement Sequence', \
|
||||
help="The sequence used for statement numbers in this journal."),
|
||||
}
|
||||
_defaults = {
|
||||
'check_dtls': lambda *a:True,
|
||||
'auto_cash': lambda *a:True,
|
||||
}
|
||||
account_journal()
|
||||
|
||||
class singer_statement(osv.osv):
|
||||
|
||||
""" Singer Statements """
|
||||
|
||||
_name = 'singer.statement'
|
||||
_description = 'Statements'
|
||||
|
||||
def _sub_total(self, cr, uid, ids, name, arg, context=None):
|
||||
|
||||
""" Calculates Sub total"
|
||||
@param name: Names of fields.
|
||||
@param arg: User defined arguments
|
||||
@return: Dictionary of values.
|
||||
"""
|
||||
res = {}
|
||||
for obj in self.browse(cr, uid, ids):
|
||||
res[obj.id] = obj.pieces * obj.number
|
||||
return res
|
||||
|
||||
def on_change_sub(self, cr, uid, ids, pieces, number,*a):
|
||||
|
||||
""" Calculates Sub total on change of number
|
||||
@param pieces: Names of fields.
|
||||
@param number:
|
||||
"""
|
||||
sub=pieces*number
|
||||
return {'value':{'subtotal': sub or 0.0}}
|
||||
|
||||
_columns = {
|
||||
'pieces': fields.float('Values', digits=(16,2)),
|
||||
'number': fields.integer('Number'),
|
||||
'subtotal': fields.function(_sub_total, method=True, string='Sub Total', type='float',digits=(16,2)),
|
||||
'starting_id': fields.many2one('account.bank.statement',ondelete='cascade'),
|
||||
'ending_id': fields.many2one('account.bank.statement',ondelete='cascade'),
|
||||
}
|
||||
|
||||
singer_statement()
|
||||
|
||||
class account_bank_statement(osv.osv):
|
||||
|
||||
_inherit = 'account.bank.statement'
|
||||
def _get_starting_balance(self, cr, uid, ids, name, arg, context=None):
|
||||
|
||||
""" Find starting balance "
|
||||
@param name: Names of fields.
|
||||
@param arg: User defined arguments
|
||||
@return: Dictionary of values.
|
||||
"""
|
||||
res ={}
|
||||
for statement in self.browse(cr, uid, ids):
|
||||
amount_total=0.0
|
||||
for line in statement.starting_details_ids:
|
||||
amount_total+= line.pieces * line.number
|
||||
res[statement.id]=amount_total
|
||||
return res
|
||||
|
||||
def _get_sum_entry_encoding(self, cr, uid, ids, name, arg, context=None):
|
||||
|
||||
""" Find encoding total of statements "
|
||||
@param name: Names of fields.
|
||||
@param arg: User defined arguments
|
||||
@return: Dictionary of values.
|
||||
"""
|
||||
res2={}
|
||||
for statement in self.browse(cr, uid, ids):
|
||||
encoding_total=0.0
|
||||
for line in statement.line_ids:
|
||||
encoding_total+= line.amount
|
||||
res2[statement.id]=encoding_total
|
||||
return res2
|
||||
|
||||
def _default_journal_id(self, cr, uid, context={}):
|
||||
|
||||
""" To get default journal for the object"
|
||||
@param name: Names of fields.
|
||||
@return: journal
|
||||
"""
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
|
||||
journal = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'cash'), ('auto_cash','=',False), ('company_id', '=', company_id)])
|
||||
if journal:
|
||||
return journal[0]
|
||||
else:
|
||||
return False
|
||||
|
||||
_columns = {
|
||||
'company_id':fields.many2one('res.company', 'Company', required=True),
|
||||
'company_id':fields.many2one('res.company', 'Company', required=True),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal', required=True),
|
||||
'balance_start': fields.function(_get_starting_balance, method=True, string='Starting Balance', type='float',digits=(16,2)),
|
||||
'state': fields.selection([('draft', 'Draft'),('confirm', 'Confirm'),('open','Open')],
|
||||
'State', required=True, states={'confirm': [('readonly', True)]}, readonly="1"),
|
||||
'total_entry_encoding':fields.function(_get_sum_entry_encoding, method=True, string="Total of Entry encoding"),
|
||||
'date':fields.datetime("Opening Date"),
|
||||
'closing_date':fields.datetime("Closing Date"),
|
||||
'starting_details_ids': fields.one2many('singer.statement', 'starting_id', string='Starting Details'),
|
||||
'ending_details_ids': fields.one2many('singer.statement', 'ending_id', string='Ending Details'),
|
||||
'name': fields.char('Name', size=64, required=True, readonly=True),
|
||||
|
||||
}
|
||||
_defaults = {
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
||||
'state': lambda *a: 'draft',
|
||||
'name': lambda *a: '/',
|
||||
'date': lambda *a:time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'journal_id': _default_journal_id,
|
||||
}
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
|
||||
company_id = vals and vals.get('company_id',False)
|
||||
if company_id:
|
||||
open_jrnl = self.search(cr, uid, [('company_id', '=', vals['company_id']), ('journal_id', '=', vals['journal_id']), ('state', '=', 'open')])
|
||||
if open_jrnl:
|
||||
raise osv.except_osv('Error', u'Une caisse de type espèce est déjà ouverte')
|
||||
if 'starting_details_ids' in vals:
|
||||
vals['starting_details_ids'] = starting_details_ids = map(list, vals['starting_details_ids'])
|
||||
for i in starting_details_ids:
|
||||
if i and i[0] and i[1]:
|
||||
i[0], i[1] = 0, 0
|
||||
res = super(account_bank_statement, self).create(cr, uid, vals, context=context)
|
||||
return res
|
||||
|
||||
def onchange_journal_id(self, cursor, user, statement_id, journal_id, context=None):
|
||||
|
||||
""" Changes balance start and starting details if journal_id changes"
|
||||
@param statement_id: Changed statement_id
|
||||
@param journal_id: Changed journal_id
|
||||
@return: Dictionary of changed values
|
||||
"""
|
||||
id_s=[]
|
||||
if not journal_id:
|
||||
return {'value': {'balance_start': 0.0}}
|
||||
balance_start=0.0
|
||||
cash_obj = self.pool.get('singer.statement')
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
cursor.execute("Select a.id from account_bank_statement a where journal_id=%d and user_id=%d order by a.id desc limit 1"%(journal_id,user))
|
||||
res2=cursor.fetchone()
|
||||
res2=res2 and res2[0] or None
|
||||
if res2:
|
||||
statmt_id=statement_obj.browse(cursor,user,res2)
|
||||
check_det=statmt_id.journal_id.check_dtls
|
||||
if not check_det:
|
||||
balance_start=statmt_id.balance_end_real or 0.0
|
||||
return {'value': {'balance_start': balance_start}}
|
||||
cursor.execute("Select a.id from account_bank_statement a, singer_statement s where journal_id=%d and user_id=%d order by a.id desc limit 1"%(journal_id,user))
|
||||
res1=cursor.fetchone()
|
||||
res1=res1 and res1[0] or None
|
||||
if res1:
|
||||
cursor.execute("Select sum(ss.pieces*ss.number),ss.ending_id from singer_statement ss, account_bank_statement s where ss.ending_id=s.id and s.journal_id=%d and s.user_id=%d and s.id=%d group by ss.ending_id,s.id order by s.id desc"%(journal_id,user, res1))
|
||||
res = cursor.fetchone()
|
||||
balance_start = res and res[0] or 0.0
|
||||
cash_end=res and res[1] or None
|
||||
id_s=statement_obj.browse(cursor,user,cash_end).ending_details_ids
|
||||
new=[]
|
||||
if id_s:
|
||||
for s in id_s:
|
||||
new.append(s.id)
|
||||
return {'value': {'balance_start': balance_start, 'starting_details_ids':new}}
|
||||
|
||||
def button_open(self, cr, uid, ids, context=None):
|
||||
|
||||
""" Changes statement state to Running.
|
||||
@return: True
|
||||
"""
|
||||
obj_inv = self.browse(cr, uid, ids)[0]
|
||||
s_id=obj_inv.journal_id
|
||||
if s_id.statement_sequence_id:
|
||||
s_id=s_id.id
|
||||
number = self.pool.get('ir.sequence').get_id(cr, uid, s_id)
|
||||
else:
|
||||
number = self.pool.get('ir.sequence').get(cr, uid,
|
||||
'account.bank.statement')
|
||||
|
||||
self.write(cr, uid, ids, {'date':time.strftime("%Y-%m-%d %H:%M:%S"), 'state':'open', 'name':number})
|
||||
return True
|
||||
|
||||
def button_confirm(self, cr, uid, ids, context=None):
|
||||
|
||||
""" Check the starting and ending detail of statement
|
||||
@return: True
|
||||
"""
|
||||
val = 0.0
|
||||
val2 = 0.0
|
||||
val_statement_line = 0.0
|
||||
diff = self.pool.get('res.users').browse(cr,uid,uid).company_id.max_diff or 0.0
|
||||
for statement in self.browse(cr, uid, ids):
|
||||
bal = statement.balance_end
|
||||
bal_st=statement.balance_start
|
||||
for st in statement.line_ids:
|
||||
val_statement_line += st.amount
|
||||
for stat in statement.starting_details_ids:
|
||||
val2 += stat.subtotal
|
||||
for stat in statement.ending_details_ids:
|
||||
val += stat.subtotal
|
||||
if statement.journal_id.check_dtls:
|
||||
if Decimal(str(val)).quantize(Decimal('.001')) != (Decimal(str(val_statement_line)) + Decimal(str(val2))).quantize(Decimal('.001')):
|
||||
raise osv.except_osv(_('Invalid action !'), _(' You can not confirm your cashbox, Please enter ending details, missing value matches to "%s"')%(abs(Decimal(str(val))-(Decimal(str(val_statement_line))+Decimal(str(val2))))))
|
||||
|
||||
self.write(cr, uid, statement.id, {'balance_end_real':Decimal(str(val_statement_line))+Decimal(str(val2)),'closing_date':time.strftime("%Y-%m-%d %H:%M:%S"),'state':'draft'})
|
||||
return super(account_bank_statement, self).button_confirm(cr, uid, ids, context=None)
|
||||
|
||||
account_bank_statement()
|
||||
|
||||
class account_bank_statement_line(osv.osv):
|
||||
|
||||
@@ -7,8 +7,5 @@
|
||||
menu="False"
|
||||
name="pos.return.picking"
|
||||
string="Return Goods"/>
|
||||
|
||||
<wizard string="Add products" model="pos.order"
|
||||
name="pos.add_product" id="pos_add_product" menu="False"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -1,61 +1,6 @@
|
||||
<?xml version="1.0" ?>
|
||||
<openerp>
|
||||
<data>
|
||||
<!-- <record id="res_partner_tinyshop0" model="res.partner">
|
||||
<field eval="0" name="customer"/>
|
||||
<field eval="0" name="supplier"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field eval=""""Tiny Shop 1"""" name="name"/>
|
||||
</record>
|
||||
<record id="res_partner_address_fabien0" model="res.partner.address">
|
||||
<field eval=""""Fabien"""" name="name"/>
|
||||
<field eval=""""92000"""" name="zip"/>
|
||||
<field eval=""""M."""" name="title"/>
|
||||
<field name="partner_id" ref="stock.res_partner_tinyshop0"/>
|
||||
<field name="country_id" ref="base.fr"/>
|
||||
<field eval=""""Avenue de Paris"""" name="street"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field eval=""""default"""" name="type"/>
|
||||
</record>
|
||||
<record id="res_company_shop0" model="res.company">
|
||||
<field eval="5.0" name="security_lead"/>
|
||||
<field name="currency_id" ref="base.EUR"/>
|
||||
<field eval="1.0" name="po_lead"/>
|
||||
<field name="partner_id" ref="res_partner_tinyshop0"/>
|
||||
<field eval="1.0" name="manufacturing_lead"/>
|
||||
<field name="parent_id" ref="base.main_company"/>
|
||||
<field eval="80.0" name="schedule_range"/>
|
||||
<field eval=""""Shop 1"""" name="name"/>
|
||||
|
||||
</record>
|
||||
<record id="res_partner_tinyshop1" model="res.partner">
|
||||
<field eval="1" name="customer"/>
|
||||
<field eval="0" name="supplier"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field eval=""""Tiny Shop 2"""" name="name"/>
|
||||
</record>
|
||||
<record id="res_partner_address_eric0" model="res.partner.address">
|
||||
<field eval=""""Eric"""" name="name"/>
|
||||
<field eval=""""1500"""" name="zip"/>
|
||||
<field eval=""""M."""" name="title"/>
|
||||
<field name="partner_id" ref="res_partner_tinyshop1"/>
|
||||
<field name="country_id" ref="base.fr"/>
|
||||
<field eval=""""Avenue de la Resistance"""" name="street"/>
|
||||
<field eval="1" name="active"/>
|
||||
<field eval=""""default"""" name="type"/>
|
||||
<field name="partner_id" ref="res_partner_tinyshop1"/>
|
||||
<field eval="1" name="active"/>
|
||||
</record>-->
|
||||
<!-- <record id="res_company_tinyshop0" model="res.company">-->
|
||||
<!-- <field name="currency_id" ref="base.EUR"/>-->
|
||||
<!-- <field eval="1.0" name="po_lead"/>-->
|
||||
<!-- <field name="partner_id" ref="res_partner_tinyshop1"/>-->
|
||||
<!-- <field eval="1.0" name="manufacturing_lead"/>-->
|
||||
<!-- <field name="parent_id" ref="base.main_company"/>-->
|
||||
<!-- <field eval="80.0" name="schedule_range"/>-->
|
||||
<!-- <field eval=""""Shop 2"""" name="name"/>-->
|
||||
<!-- </record>-->
|
||||
|
||||
|
||||
<record id="res_users_shopuser0" model="res.users">
|
||||
<field model="ir.actions.actions" name="menu_id" search="[('name','=','Menu')]"/>
|
||||
@@ -575,11 +520,6 @@
|
||||
id="stock.next_id_61"
|
||||
name="Reporting"
|
||||
parent="stock.menu_stock_root" groups="base.group_user"/>
|
||||
<!-- <menuitem-->
|
||||
<!-- id="stock.next_id_62"-->
|
||||
<!-- name="Traceability"-->
|
||||
<!-- parent="stock.next_id_61" groups="base.group_user"/>-->
|
||||
<!-- <menuitem id="stock.menu_traceability_low" name="Low Level" parent="stock.menu_traceability" groups="base.group_user"/>-->
|
||||
<menuitem action="stock.action_picking_tree" id="stock.menu_action_picking_tree" parent="stock.menu_stock_root" sequence="19" groups="res_groups_posuser0"/>
|
||||
<menuitem id="mrp.menu_mrp_reordering" name="Automatic Procurements" parent="stock.menu_stock_root" sequence="4" groups="base.group_user"/>
|
||||
<menuitem parent="stock.next_id_61" action="stock.action_stock_line_date" id="stock.menu_report_stock_line_date" groups="base.group_user"/>
|
||||
|
||||
@@ -434,7 +434,11 @@
|
||||
string="Close Register"
|
||||
action="action_pos_close_statement"
|
||||
id="menu_close_statement" sequence="2" />
|
||||
|
||||
|
||||
<menuitem icon="STOCK_PRINT"
|
||||
action="action_report_all_closed_cashbox_of_the_day"
|
||||
id="menu_all_closed_cashbox_of_the_day"
|
||||
parent="menu_point_report_register"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user