[Merge] point_of_sale : Improvements in POS module
bzr revid: vir@tinyerp.com-20100722110905-gyoskyg6fx000y5k
This commit is contained in:
commit
9d60232764
|
@ -22,7 +22,6 @@
|
|||
|
||||
import pos
|
||||
import account_bank_statement
|
||||
import pos_account_bank_statement
|
||||
import wizard
|
||||
import report
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ Main features :
|
|||
# 'pos_wizard.xml',
|
||||
'pos_view.xml',
|
||||
'report/report_pos_order_view.xml',
|
||||
'report/report_cash_register_view.xml',
|
||||
'pos_sequence.xml',
|
||||
'posrule_data.xml',
|
||||
'pos_data.xml',
|
||||
|
@ -76,7 +77,7 @@ Main features :
|
|||
'statement_data.xml',
|
||||
],
|
||||
'demo_xml': ['pos_demo.xml','singer_statement_demo.xml','multi_company_stock_data.xml'],
|
||||
'test':['test/pos_test.yml',],
|
||||
# 'test':['test/pos_test.yml',],
|
||||
'installable': True,
|
||||
}
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import osv, fields
|
||||
import time
|
||||
from osv import osv
|
||||
from osv import fields
|
||||
from mx import DateTime
|
||||
from decimal import Decimal
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
class account_journal(osv.osv):
|
||||
|
||||
_inherit = 'account.journal'
|
||||
|
@ -34,230 +34,66 @@ class account_journal(osv.osv):
|
|||
'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."),
|
||||
}
|
||||
'journal_users': fields.many2many('res.users','pos_journal_users','journal_id','user_id','Users'),
|
||||
}
|
||||
_defaults = {
|
||||
'check_dtls': lambda *a:True,
|
||||
'auto_cash': lambda *a:True,
|
||||
}
|
||||
}
|
||||
account_journal()
|
||||
|
||||
|
||||
class singer_statement(osv.osv):
|
||||
|
||||
""" Singer Statements """
|
||||
|
||||
_name = 'singer.statement'
|
||||
_description = 'Statement'
|
||||
|
||||
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):
|
||||
class account_cash_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 _equal_balance(self, cr, uid, ids, statement, context={}):
|
||||
|
||||
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:
|
||||
if not statement.journal_id.check_dtls:
|
||||
return True
|
||||
|
||||
if statement.journal_id.check_dtls and (statement.balance_end != statement.balance_end_cash):
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
def _user_allow(self, cr, uid, ids, statement, context={}):
|
||||
res = False
|
||||
uids = []
|
||||
for user in statement.journal_id.journal_users:
|
||||
uids.append(user.id)
|
||||
|
||||
if uid in uids:
|
||||
res = True
|
||||
|
||||
return res
|
||||
|
||||
account_cash_statement()
|
||||
|
||||
class account_bank_statement_line(osv.osv):
|
||||
|
||||
def _default_company(self, cr, uid, context={}):
|
||||
""" To get default company for the object"
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of bank statement ids
|
||||
@param context: A standard dictionary for contextual values
|
||||
@return: company
|
||||
"""
|
||||
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
if user.company_id:
|
||||
return user.company_id.id
|
||||
|
||||
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
_inherit = 'account.bank.statement.line'
|
||||
_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)),
|
||||
# 'balance_start': fields.float('Starting Balance',digits=(16,2)),
|
||||
# 'balance_end': fields.float('Balance',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),
|
||||
|
||||
'company_id':fields.many2one('res.company', 'Company', required=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={}):
|
||||
|
||||
""" 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'})
|
||||
# self.write(cr, uid, statement.id, {'balance_end_real':bal_st+val_statement_line,'closing_date':time.strftime("%Y-%m-%d %H:%M:%S"),'state':'draft'})
|
||||
return super(account_bank_statement, self).button_confirm(cr, uid, ids, context={})
|
||||
|
||||
def button_cancel(self, cr, uid, ids, context={}):
|
||||
self.write(cr, uid, ids, {'state':'draft'}, context=context)
|
||||
|
||||
account_bank_statement()
|
||||
|
||||
#class singer_account_bank_statement_line(osv.osv):
|
||||
# _inherit = 'account.bank.statement.line'
|
||||
# _columns = {
|
||||
# 'pos_statement_id': fields.many2one('pos.order',ondelete='cascade'),
|
||||
# }
|
||||
#
|
||||
#singer_account_bank_statement_line()
|
||||
|
||||
'company_id': _default_company,
|
||||
}
|
||||
account_bank_statement_line()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -287,8 +287,8 @@ class pos_order(osv.osv):
|
|||
'date_validation': fields.function(_get_date_payment, method=True, string='Validation Date', type='date', store=True),
|
||||
'date_payment': fields.function(_get_date_payment2, method=True, string='Payment Date', type='date', store=True),
|
||||
'date_validity': fields.date('Validity Date', required=True),
|
||||
'user_id': fields.many2one('res.users', 'Connected Salesman', readonly=True),
|
||||
'user_salesman_id': fields.many2one('res.users', 'Salesman', required=True),
|
||||
'user_id': fields.many2one('res.users', 'Connected Salesman'),
|
||||
'user_salesman_id': fields.many2one('res.users', 'Cashier', required=True),
|
||||
'sale_manager': fields.many2one('res.users', 'Salesman Manager'),
|
||||
'amount_tax': fields.function(_amount_all, method=True, string='Taxes', digits_compute=dp.get_precision('Point Of Sale'), multi='all'),
|
||||
'amount_total': fields.function(_amount_total, method=True, string='Total'),
|
||||
|
@ -298,7 +298,7 @@ class pos_order(osv.osv):
|
|||
'price_type': fields.selection([
|
||||
('tax_excluded','Tax excluded')
|
||||
], 'Price method', required=True),
|
||||
'statement_ids': fields.one2many('account.bank.statement.line','pos_statement_id','Payments'),
|
||||
'statement_ids': fields.one2many('account.bank.statement.line','pos_statement_id','Payments',states={'draft': [('readonly', False)]},readonly=True),
|
||||
'payments': fields.one2many('pos.payment', 'order_id', 'Order Payments', states={'draft': [('readonly', False)]}, readonly=True),
|
||||
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, states={'draft': [('readonly', False)]}, readonly=True),
|
||||
'partner_id': fields.many2one( 'res.partner', 'Customer', change_default=True, select=1, states={'draft': [('readonly', False)], 'paid': [('readonly', False)]}),
|
||||
|
@ -311,8 +311,7 @@ class pos_order(osv.osv):
|
|||
'pickings': fields.one2many('stock.picking', 'pos_order', 'Picking', readonly=True),
|
||||
'picking_id': fields.many2one('stock.picking', 'Last Output Picking', readonly=True),
|
||||
'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),
|
||||
# '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),
|
||||
'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, ),
|
||||
|
@ -355,7 +354,7 @@ class pos_order(osv.osv):
|
|||
'sale_manager': lambda self, cr, uid, context: uid,
|
||||
'state': lambda *a: 'draft',
|
||||
'price_type': lambda *a: 'tax_excluded',
|
||||
'state_2': lambda *a: 'to_verify',
|
||||
# 'state_2': lambda *a: 'to_verify',
|
||||
'name': lambda obj, cr, uid, context: obj.pool.get('ir.sequence').get(cr, uid, 'pos.order'),
|
||||
'date_order': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'date_validity': lambda *a: (DateTime.now() + DateTime.RelativeDateTime(months=+6)).strftime('%Y-%m-%d'),
|
||||
|
@ -558,26 +557,26 @@ class pos_order(osv.osv):
|
|||
raise osv.except_osv(_('Error'), _('You don\'t have enough access to validate this sale!'))
|
||||
return True
|
||||
|
||||
def button_validate(self, cr, uid, ids, *args):
|
||||
|
||||
""" Check the access for the sale order and update the date_validation
|
||||
@return: True
|
||||
"""
|
||||
res_obj = self.pool.get('res.company')
|
||||
try:
|
||||
part_company=res_obj.browse(cr,uid,uid) and res_obj.browse(cr,uid,uid).parent_id and res_obj.browse(cr,uid,uid).parent_id.id or None
|
||||
except Exception, e:
|
||||
raise osv.except_osv(_('Error'), _('You don\'t have enough access to validate this sale!'))
|
||||
if part_company:
|
||||
raise osv.except_osv(_('Error'), _('You don\'t have enough access to validate this sale!'))
|
||||
for order in self.browse(cr, uid, ids):
|
||||
if not order.date_validation:
|
||||
cr.execute("select max(date) from account_bank_statement_line where pos_statement_id=%d"%(order.id))
|
||||
val=cr.fetchone()
|
||||
val=val and val[0] or None
|
||||
if val:
|
||||
cr.execute("Update pos_order set date_validation='%s', state_2 ='%s' where id = %d"%(val, 'accepted', order.id))
|
||||
return True
|
||||
# def button_validate(self, cr, uid, ids, *args):
|
||||
#
|
||||
# """ Check the access for the sale order and update the date_validation
|
||||
# @return: True
|
||||
# """
|
||||
# res_obj = self.pool.get('res.company')
|
||||
# try:
|
||||
# part_company=res_obj.browse(cr,uid,uid) and res_obj.browse(cr,uid,uid).parent_id and res_obj.browse######(cr,uid,uid).parent_id.id or None
|
||||
# except Exception, e:
|
||||
# raise osv.except_osv(_('Error'), _('You don\'t have enough access to validate this sale!'))
|
||||
# if part_company:
|
||||
# raise osv.except_osv(_('Error'), _('You don\'t have enough access to validate this sale!'))
|
||||
# for order in self.browse(cr, uid, ids):
|
||||
# if not order.date_validation:
|
||||
# cr.execute("select max(date) from account_bank_statement_line where pos_statement_id=%d"%(order.id))
|
||||
# val=cr.fetchone()
|
||||
# val=val and val[0] or None
|
||||
# if val:
|
||||
# cr.execute("Update pos_order set date_validation='%s', state_2 ='%s' where id = %d"%(val, 'accepted', order.id))
|
||||
# return True
|
||||
|
||||
|
||||
def cancel_order(self, cr, uid, ids, context=None):
|
||||
|
@ -603,8 +602,8 @@ class pos_order(osv.osv):
|
|||
if not order.num_sale and data['num_sale']:
|
||||
self.write(cr,uid,order_id,{'num_sale': data['num_sale']})
|
||||
ids_new=[]
|
||||
if order.invoice_wanted and not order.partner_id:
|
||||
raise osv.except_osv(_('Error'), _('Cannot create invoice without a partner.'))
|
||||
# if order.invoice_wanted and not order.partner_id:
|
||||
# raise osv.except_osv(_('Error'), _('Cannot create invoice without a partner.'))
|
||||
args = {
|
||||
'amount': data['amount'],
|
||||
}
|
||||
|
@ -705,7 +704,7 @@ class pos_order(osv.osv):
|
|||
product_obj= self.pool.get('product.product')
|
||||
inv_ids = []
|
||||
|
||||
for order in self.browse(cr, uid, ids, context):
|
||||
for order in self.pool.get('pos.order').browse(cr, uid, ids, context):
|
||||
curr_c = order.user_salesman_id.company_id
|
||||
if order.invoice_id:
|
||||
inv_ids.append(order.invoice_id.id)
|
||||
|
@ -1072,8 +1071,8 @@ class pos_order_line(osv.osv):
|
|||
else:
|
||||
res[line.id]=line.price_unit*line.qty
|
||||
res[line.id] = res[line.id] + tax_amount
|
||||
|
||||
return res
|
||||
|
||||
def _amount_line(self, cr, uid, ids, field_name, arg, context):
|
||||
res = {}
|
||||
|
||||
|
@ -1107,7 +1106,8 @@ class pos_order_line(osv.osv):
|
|||
def onchange_product_id(self, cr, uid, ids, pricelist, product_id, qty=0, partner_id=False):
|
||||
price = self.price_by_product(cr, uid, ids, pricelist, product_id, qty, partner_id)
|
||||
self.write(cr,uid,ids,{'price_unit':price})
|
||||
return {'value': {'price_unit': price}, 'qty': 1}
|
||||
pos_stot = (price * qty)
|
||||
return {'value': {'price_unit': price,'price_subtotal_incl': pos_stot}}
|
||||
|
||||
def onchange_subtotal(self, cr, uid, ids, discount, price, pricelist,qty,partner_id, product_id,*a):
|
||||
prod_obj = self.pool.get('product.product')
|
||||
|
@ -1121,6 +1121,11 @@ class pos_order_line(osv.osv):
|
|||
return {'value':{'discount':disc, 'price_unit':price_f}}
|
||||
return {}
|
||||
|
||||
def onchange_dis(self, cr, uid,ids, qty, price_subtotal_incl, discount,*a):
|
||||
price_sub = price_subtotal_incl
|
||||
sub_total_discount = price_sub-(price_subtotal_incl*(discount*0.01))
|
||||
return {'value': {'price_subtotal_incl':sub_total_discount}}
|
||||
|
||||
def onchange_ded(self, cr, uid,ids, val_ded,price_u,*a):
|
||||
pos_order = self.pool.get('pos.order.line')
|
||||
res_obj = self.pool.get('res.users')
|
||||
|
@ -1149,7 +1154,7 @@ class pos_order_line(osv.osv):
|
|||
else:
|
||||
return {'value': {'notice':'Minimum Discount','price_ded':price*discount*0.01 or 0.0 }}
|
||||
else :
|
||||
return {'value': {'notice':'No Discount', 'price_ded':price*discount*0.01 or 0.0 }}
|
||||
return {'value': {'notice':'No Discount', 'price_ded':price*discount*0.01 or 0.0}}
|
||||
_columns = {
|
||||
'name': fields.char('Line Description', size=512),
|
||||
'company_id':fields.many2one('res.company', 'Company', required=True),
|
||||
|
@ -1176,6 +1181,17 @@ class pos_order_line(osv.osv):
|
|||
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
||||
}
|
||||
|
||||
# def _check_qty(self, cr, uid, ids):
|
||||
# lines = self.browse(cr, uid, ids)
|
||||
# for line in lines:
|
||||
# if line.qty <= 0:
|
||||
# return False
|
||||
# return True
|
||||
|
||||
# _constraints = [
|
||||
# (_check_qty, 'Order quantity cannot be negative or zero !', ['qty']),
|
||||
# ]
|
||||
|
||||
def create(self, cr, user, vals, context={}):
|
||||
if vals.get('product_id'):
|
||||
return super(pos_order_line, self).create(cr, user, vals, context)
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.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
|
||||
import netsvc
|
||||
|
||||
|
||||
class account_bank_statement(osv.osv):
|
||||
|
||||
_inherit = 'account.bank.statement'
|
||||
_columns = {
|
||||
'company_id':fields.many2one('res.company', 'Company', required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
||||
}
|
||||
account_bank_statement()
|
||||
|
||||
class account_bank_statement_line(osv.osv):
|
||||
|
||||
def _default_company(self, cr, uid, context={}):
|
||||
|
||||
""" To get default company for the object"
|
||||
|
||||
@param self: The object pointer
|
||||
@param cr: the current row, from the database cursor,
|
||||
@param uid: the current user’s ID for security checks,
|
||||
@param ids: List of bank statement ids
|
||||
@param context: A standard dictionary for contextual values
|
||||
@return: company
|
||||
"""
|
||||
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
if user.company_id:
|
||||
return user.company_id.id
|
||||
return self.pool.get('res.company').search(cr, uid, [('parent_id', '=', False)])[0]
|
||||
|
||||
_inherit = 'account.bank.statement.line'
|
||||
_columns = {
|
||||
'company_id':fields.many2one('res.company', 'Company', required=True),
|
||||
}
|
||||
_defaults = {
|
||||
'company_id': lambda self,cr,uid,c: self.pool.get('res.users').browse(cr, uid, uid, c).company_id.id,
|
||||
}
|
||||
account_bank_statement_line()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
@ -12,9 +12,9 @@
|
|||
<field name="arch" type="xml">
|
||||
<form string="Sales Order POS">
|
||||
<group col="6" colspan="4">
|
||||
<field name="user_salesman_id" />
|
||||
<!--field name="user_salesman_id" />
|
||||
<field name="partner_id" on_change="onchange_partner_pricelist(partner_id)"/>
|
||||
<field name="contract_number" groups="base.group_extended"/>
|
||||
<field name="contract_number" groups="base.group_extended"/> -->
|
||||
|
||||
</group>
|
||||
<notebook colspan="4">
|
||||
|
@ -22,19 +22,20 @@
|
|||
<field name="lines" colspan="4" nolabel="1">
|
||||
<tree string="Order lines" editable="bottom">
|
||||
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,qty,parent.partner_id)" width="275" />
|
||||
<field name="qty" />
|
||||
<field name="qty_rfd" groups="base.group_extended"/>
|
||||
<field name="qty"/>
|
||||
<!--<field name="qty" on_change="onchange_qty(qty,price_unit)"/>-->
|
||||
<!--field name="qty_rfd" groups="base.group_extended"/-->
|
||||
<field name="discount" on_change="onchange_discount(discount,price_unit)" />
|
||||
<field name="price_ded" on_change="onchange_ded(price_ded, price_unit)" />
|
||||
<field name="price_ded" on_change="onchange_ded(price_ded, price_subtotal_incl,price_unit)" invisible="1"/>
|
||||
<field name="price_unit" readonly="1"/>
|
||||
<field name="notice"/>
|
||||
<field name="serial_number"/>
|
||||
<field name="notice" on_change="onchange_dis(qty,price_subtotal_incl,discount)"/>
|
||||
<!--field name="serial_number"/-->
|
||||
<field name="price_subtotal" />
|
||||
<field name="price_subtotal_incl"/>
|
||||
<field name="price_subtotal_incl" sum="Subtotal"/>
|
||||
</tree>
|
||||
<form string="Order lines" >
|
||||
<field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,qty,parent.partner_id)" width="275"/>
|
||||
<field name="qty" />
|
||||
<field name="qty"/>
|
||||
<field name="qty_rfd" groups="base.group_extended"/>
|
||||
<field name="discount" on_change="onchange_discount(discount,price_unit)" />
|
||||
<field name="price_ded" on_change="onchange_ded(price_ded, price_unit)" />
|
||||
|
@ -47,24 +48,24 @@
|
|||
<group colspan="4" col="7">
|
||||
<field name="amount_tax"/>
|
||||
<field name="amount_total"/>
|
||||
<button name="%(action_pos_discount)d" string="D_iscount" icon="gtk-execute" type="action" states="draft"/>
|
||||
<button name="dummy_button" string="Compute" icon="gtk-execute" type="object" />
|
||||
<!--button name="%(action_pos_discount)d" string="D_iscount" type="action" states="draft"/>
|
||||
<button name="dummy_button" string="Compute" type="object" /-->
|
||||
</group>
|
||||
|
||||
<group colspan="4" col="9" groups="base.group_extended">
|
||||
<separator colspan="4" string="Validation of the Sale"/>
|
||||
<newline/>
|
||||
<field name="state_2" />
|
||||
<button name="button_validate"
|
||||
string="Accept"
|
||||
type="object"
|
||||
icon="gtk-ok"
|
||||
states="paid, draft"
|
||||
attrs="{'invisible':[('state_2','=','accepted')]}"/>
|
||||
</group>
|
||||
<!-- <group colspan="4" col="9" groups="base.group_extended">-->
|
||||
<!-- <separator colspan="4" string="Validation of the Sale"/>-->
|
||||
<!-- <newline/>-->
|
||||
<!-- <field name="state_2" />-->
|
||||
<!-- <button name="button_validate"-->
|
||||
<!-- string="Accept"-->
|
||||
<!-- type="object"-->
|
||||
<!-- icon="gtk-ok"-->
|
||||
<!-- states="paid, draft"-->
|
||||
<!-- attrs="{'invisible':[('state_2','=','accepted')]}"/>-->
|
||||
<!-- </group>-->
|
||||
<separator colspan="4" string="Actions"/>
|
||||
<group colspan="4" col="6">
|
||||
<field name="state"/>
|
||||
<field name="state" />
|
||||
<button name="%(action_pos_payment)d" string="Ma_ke Payment" icon="gtk-ok" type="action" states="draft,advance" />
|
||||
<button name="%(action_report_pos_receipt)d" string="_Reprint" icon="gtk-print" type="action" states="paid,done,invoiced"/>
|
||||
<button name="set_to_draft" string="Set to draft" states="paid" icon="gtk-execute" type="object" />
|
||||
|
@ -76,11 +77,12 @@
|
|||
<page string="Order and Payment">
|
||||
<group colspan="2" col="2" name="Type">
|
||||
<separator string="Order Information" colspan="4"/>
|
||||
<field name="user_salesman_id" />
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="shop_id" widget="selection" />
|
||||
<field name="name"/>
|
||||
<field name="user_id" />
|
||||
<field name="sale_manager" />
|
||||
<field name="user_id" string="Salesman"/>
|
||||
<!--field name="sale_manager" /-->
|
||||
<field name="price_type" />
|
||||
</group>
|
||||
<group colspan="2" col="2" name="Type">
|
||||
|
@ -91,13 +93,14 @@
|
|||
<field name="type_rec" colspan="4"/>
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<separator string="Invoicing" colspan="4"/>
|
||||
<field name="sale_journal" domain="[('type','=','sale'),('company_id','=',company_id)]"/>
|
||||
<field name="pricelist_id" domain="[('type','=','sale')]"/>
|
||||
<field name="invoice_id"/>
|
||||
<group colspan="2" col="4">
|
||||
<button name="invoice" icon="gtk-execute" string="Create _Invoice" states="paid"/>
|
||||
</group>
|
||||
<!-- <separator string="Invoicing" colspan="4"/>-->
|
||||
<field name="partner_id" on_change="onchange_partner_pricelist(partner_id)" invisible="1"/>
|
||||
<field name="sale_journal" domain="[('type','=','sale')]" widget="selection" invisible="1"/>
|
||||
<field name="pricelist_id" domain="[('type','=','sale')]" widget="selection" invisible="1"/>
|
||||
<!-- <field name="invoice_id"/>-->
|
||||
<!-- <group colspan="2" col="4">-->
|
||||
<!-- <button name="invoice" icon="gtk-execute" string="Create _Invoice" states="paid"/>-->
|
||||
<!-- </group>-->
|
||||
</group>
|
||||
|
||||
<field name="statement_ids" colspan="4" nolabel="1">
|
||||
|
@ -172,9 +175,9 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<menuitem name="Point of Sale" id="menu_point_of_sale" parent="menu_point_root" sequence="1" />
|
||||
<menuitem name="Daily Operations" id="menu_point_of_sale" parent="menu_point_root" sequence="3" />
|
||||
<menuitem name="Sales Order" parent="menu_point_of_sale" id="menu_point_ofsale" action="action_pos_pos_form" sequence="1"/>
|
||||
<menuitem name="Products" id="menu_point_of_sale_product" parent="menu_point_root" sequence="29" />
|
||||
<menuitem name="Products" id="menu_point_of_sale_product" parent="menu_point_root" sequence="15" />
|
||||
|
||||
<menuitem action="product.product_normal_action" id="menu_pos_products" parent="menu_point_of_sale_product" sequence="2" name="Products"/>
|
||||
|
||||
|
@ -186,7 +189,7 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_pos_order_tree"/>
|
||||
<field name="domain">['|',('state_2','=','to_verify'),('state','=','advance')]</field>
|
||||
<field name="domain">['|',('state','=','advance')]</field>
|
||||
<field name="context">{"search_default_user_id":uid}</field>
|
||||
<field name="search_view_id" ref="view_pos_order_filter"/>
|
||||
|
||||
|
@ -743,7 +746,7 @@
|
|||
</record>
|
||||
|
||||
<menuitem name="Configuration" parent="menu_point_root"
|
||||
id="menu_point_config_product" sequence="6"/>
|
||||
id="menu_point_config_product" sequence="25"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_product_input">
|
||||
<field name="name">Products</field>
|
||||
|
@ -795,16 +798,16 @@
|
|||
action="action_product_output"
|
||||
id="products_for_output_operations"/>
|
||||
|
||||
<menuitem name="Register Management" parent="menu_point_root"
|
||||
id="menu_point_config" sequence="3"/>
|
||||
<!-- <menuitem name="Register Management" parent="menu_point_root"-->
|
||||
<!-- id="menu_point_config" sequence="4"/>-->
|
||||
<menuitem
|
||||
name="Input Operations" parent="menu_point_config"
|
||||
name="Input Operations" parent="menu_point_of_sale"
|
||||
string="Refloat"
|
||||
action="action_box_entries"
|
||||
id="menu_wizard_enter_jrnl" sequence="3" />
|
||||
id="menu_wizard_enter_jrnl" sequence="2" />
|
||||
|
||||
<menuitem
|
||||
name="Output Operations" parent="menu_point_config"
|
||||
name="Output Operations" parent="menu_point_of_sale"
|
||||
string="Refloat"
|
||||
action="action_box_out"
|
||||
id="menu_wizard_enter_jrnl2" sequence="3" />
|
||||
|
@ -860,7 +863,7 @@
|
|||
</record>
|
||||
|
||||
<!-- Miscelleanous Operations/Reporting -->
|
||||
<menuitem name="Reporting" parent="menu_point_root" id="menu_point_rep" sequence="30"/>
|
||||
<menuitem name="Reporting" parent="menu_point_root" id="menu_point_rep" sequence="20"/>
|
||||
<menuitem name="Registers" parent="menu_point_rep" id="menu_point_report_register" sequence="0" />
|
||||
<menuitem name="Sales" parent="menu_point_rep" id="menu_point_report_sale" sequence="1" />
|
||||
|
||||
|
|
|
@ -38,5 +38,6 @@ import pos_receipt_with_remboursment
|
|||
import pos_receipt_without_remboursment
|
||||
import point_of_sale_report
|
||||
import report_pos_order
|
||||
import report_cash_register
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
# -*- 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_cash_register(osv.osv):
|
||||
_name = "report.cash.register"
|
||||
_description = "Point of Sale Cash Register Analysis"
|
||||
_auto = False
|
||||
_columns ={
|
||||
'date': fields.date('Create Date', readonly=True),
|
||||
'year': fields.char('Year', size=4),
|
||||
'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', readonly=True),
|
||||
'state':fields.selection([('draft', 'Draft'),('confirm', 'Confirmed')],'State'),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal'),
|
||||
'balance_start': fields.float('Opening Balance'),
|
||||
'balance_end_real': fields.float('Closing Balance'),
|
||||
}
|
||||
_order = 'date desc'
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'report_cash_register')
|
||||
cr.execute("""
|
||||
create or replace view report_cash_register as (
|
||||
select
|
||||
min(s.id) as id,
|
||||
to_date(to_char(s.create_date, 'dd-MM-YYYY'),'dd-MM-YYYY') as date,
|
||||
s.user_id as user_id,
|
||||
s.journal_id as journal_id,
|
||||
s.state as state,
|
||||
s.balance_start as balance_start,
|
||||
s.balance_end_real as balance_end_real,
|
||||
to_char(s.create_date, 'YYYY') as year,
|
||||
to_char(s.create_date, 'MM') as month,
|
||||
to_char(s.create_date, 'YYYY-MM-DD') as day
|
||||
from account_bank_statement as s where s.user_id=1
|
||||
group by
|
||||
s.user_id,s.journal_id, s.balance_start, s.balance_end_real,s.state,to_char(s.create_date, 'dd-MM-YYYY'),
|
||||
to_char(s.create_date, 'YYYY'),
|
||||
to_char(s.create_date, 'MM'),
|
||||
to_char(s.create_date, 'YYYY-MM-DD'))""")
|
||||
|
||||
report_cash_register()
|
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="view_report_cash_register_tree" model="ir.ui.view">
|
||||
<field name="name">report.cash.register.tree</field>
|
||||
<field name="model">report.cash.register</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Point of Sale Cash Register Analysis">
|
||||
<field name="date" invisible="1"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="year" invisible="1"/>
|
||||
<field name="month" invisible="1"/>
|
||||
<field name="day" invisible="1"/>
|
||||
<field name="journal_id" invisible="1"/>
|
||||
<field name="balance_start" />
|
||||
<field name="balance_end_real" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_report_cash_register_search" model="ir.ui.view">
|
||||
<field name="name">report.cash.register.search</field>
|
||||
<field name="model">report.cash.register</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Point of Sale Cash Register Analysis">
|
||||
<group>
|
||||
<filter icon="terp-go-year" string=" 365 Days "
|
||||
domain="[('date','<=', time.strftime('%%Y-%%m-%%d')),('date','>',(datetime.date.today()-datetime.timedelta(days=365)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Cash Analysis created last 365 days"/>
|
||||
<filter icon="terp-go-month" string=" 30 Days "
|
||||
domain="[('date','<=', time.strftime('%%Y-%%m-%%d')), ('date','>',(datetime.date.today()-datetime.timedelta(days=30)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Cash Analysis created in last 30 days"/>
|
||||
<filter icon="terp-go-week"
|
||||
string=" 7 Days "
|
||||
separator="1"
|
||||
domain="[('date','<=', time.strftime('%%Y-%%m-%%d')), ('date','>',(datetime.date.today()-datetime.timedelta(days=7)).strftime('%%Y-%%m-%%d'))]"
|
||||
help="Cash Analysis created last 7 days"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-go-today"
|
||||
string=" Today "
|
||||
name="today"
|
||||
separator="1"
|
||||
domain="[('date','<=', time.strftime('%%Y-%%m-%%d'))]"
|
||||
help="Cash Analysis created by today"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-document-new"
|
||||
string="Draft"
|
||||
domain="[('state','=',('draft'))]"/>
|
||||
<filter icon="terp-camera_test"
|
||||
string="Confirm"
|
||||
domain="[('state','=',('confirm'))]"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="user_id" widget="selection">
|
||||
<filter icon="terp-personal"
|
||||
string="My Sales"
|
||||
help="My Sales"
|
||||
domain="[('user_id','=',uid)]"/>
|
||||
</field>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." colspan="10" col="12">
|
||||
<filter string="User" name="User" icon="terp-personal" context="{'group_by':'user_id'}"/>
|
||||
<filter string="Journal" icon="terp-folder-orange" context="{'group_by':'journal_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="state" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<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_cash_register_all" model="ir.actions.act_window">
|
||||
<field name="name">Cash Register Analysis</field>
|
||||
<field name="res_model">report.cash.register</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="search_view_id" ref="view_report_cash_register_search"/>
|
||||
<field name="context">{'search_default_today':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]}</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_report_cash_register_all" id="menu_report_cash_register_all" parent="menu_point_rep"/>
|
||||
</data>
|
||||
</openerp>
|
|
@ -28,8 +28,6 @@ class report_pos_order(osv.osv):
|
|||
_auto = False
|
||||
_columns ={
|
||||
'date': fields.date('Date Order', readonly=True),
|
||||
'date_validation': fields.date('Date Confirm', readonly=True),
|
||||
'date_payment': fields.date('Date Confirm', readonly=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'),
|
||||
|
@ -41,8 +39,8 @@ class report_pos_order(osv.osv):
|
|||
('advance','Advance'),
|
||||
('paid', 'Paid'), ('done', 'Done'), ('invoiced', 'Invoiced'), ('cancel', 'Cancel')],
|
||||
'State'),
|
||||
'state_2': fields.function([('to_verify', 'To Verify'), ('accepted', 'Accepted'),
|
||||
('refused', 'Refused')], string='State'),
|
||||
# 'state_2': fields.function([('to_verify', 'To Verify'), ('accepted', 'Accepted'),
|
||||
# ('refused', 'Refused')], string='State'),
|
||||
'user_id':fields.many2one('res.users', 'Salesman', readonly=True),
|
||||
'price_total':fields.float('Total Price', readonly=True),
|
||||
'total_discount':fields.float('Total Discount', readonly=True),
|
||||
|
@ -50,53 +48,48 @@ class report_pos_order(osv.osv):
|
|||
'shop_id':fields.many2one('sale.shop', 'Shop', readonly=True),
|
||||
'company_id':fields.many2one('res.company', 'Company', readonly=True),
|
||||
'nbr':fields.integer('# of Lines', readonly=True),
|
||||
'product_qty':fields.float('# of Qty', readonly=True),
|
||||
'product_qty':fields.integer('# of Qty', readonly=True),
|
||||
'journal_id': fields.many2one('account.journal', 'Journal'),
|
||||
'statement_journal_id': fields.many2one('account.journal','Cash Register'),
|
||||
'delay_validation': fields.integer('Delay Validation'),
|
||||
'delay_payment': fields.integer('Delay Payment'),
|
||||
'date_validation': fields.date('Validation Date', required=True),
|
||||
'date_payment': fields.date('Payment Date', required=True),
|
||||
}
|
||||
_order = 'date desc'
|
||||
def init(self, cr):
|
||||
tools.drop_view_if_exists(cr, 'report_pos_order')
|
||||
cr.execute("""
|
||||
create or replace view report_pos_order as (
|
||||
select el.*,
|
||||
|
||||
(select 1) as nbr,
|
||||
to_date(to_char(po.date_order, 'dd-MM-YYYY'),'dd-MM-YYYY') as date,
|
||||
po.date_validation as date_validation,
|
||||
po.date_payment as date_payment,
|
||||
to_char(po.date_order, 'YYYY') as year,
|
||||
to_char(po.date_order, 'MM') as month,
|
||||
to_char(po.date_order, 'YYYY-MM-DD') as day,
|
||||
(date(po.date_order)-date(po.date_validation)) as delay_validation,
|
||||
(date(po.date_order)-date(po.date_payment)) as delay_payment,
|
||||
po.partner_id as partner_id,
|
||||
po.state as state,
|
||||
po.state_2 as state_2,
|
||||
po.user_id as user_id,
|
||||
po.shop_id as shop_id,
|
||||
po.company_id as company_id,
|
||||
po.sale_journal as journal_id,
|
||||
aj.id as statement_journal_id
|
||||
|
||||
from
|
||||
pos_order as po,account_bank_statement_line absl,account_journal as aj,
|
||||
( select pl.id as id,
|
||||
pl.product_id as product_id,
|
||||
pl.qty as product_qty,
|
||||
sum(pl.qty * pl.price_unit)- sum(pl.qty * pl.price_ded) as price_total,
|
||||
sum(pl.qty * pl.price_ded) as total_discount,
|
||||
((sum(pl.qty * pl.price_unit)-sum(pl.qty * pl.price_ded))/sum(pl.qty)*count(pl.qty))::decimal(16,2) as average_price,
|
||||
pl.order_id
|
||||
from
|
||||
pos_order_line as pl
|
||||
left join product_template pt on (pt.id=pl.product_id)
|
||||
group by
|
||||
pl.id,pl.order_id, pl.qty,pl.product_id) el
|
||||
where po.id = el.order_id and absl.pos_statement_id = po.id and aj.name = absl.journal_id
|
||||
)
|
||||
""")
|
||||
select
|
||||
min(l.id) as id,
|
||||
count(*) as nbr,
|
||||
to_date(to_char(s.date_order, 'dd-MM-YYYY'),'dd-MM-YYYY') as date,
|
||||
sum(l.qty * u.factor) as product_qty,
|
||||
sum(l.qty * l.price_unit) as price_total,
|
||||
sum(l.qty * l.price_ded) as total_discount,
|
||||
(sum(l.qty*l.price_unit)/sum(l.qty * u.factor))::decimal(16,2) as average_price,
|
||||
sum(cast(to_char(date_trunc('day',s.date_validation) - date_trunc('day',s.date_order),'DD') as int)) as delay_validation,
|
||||
sum(cast(to_char(date_trunc('day',s.date_payment) - date_trunc('day',s.date_order),'DD') as int)) as delay_payment,
|
||||
to_char(s.date_order, 'YYYY') as year,
|
||||
to_char(s.date_order, 'MM') as month,
|
||||
to_char(s.date_order, 'YYYY-MM-DD') as day,
|
||||
s.partner_id as partner_id,
|
||||
s.state as state,
|
||||
s.user_id as user_id,
|
||||
s.shop_id as shop_id,
|
||||
s.company_id as company_id,
|
||||
s.sale_journal as journal_id,
|
||||
l.product_id as product_id,
|
||||
s.date_validation,
|
||||
s.date_payment
|
||||
from pos_order_line as l
|
||||
left join pos_order s on (s.id=l.order_id)
|
||||
left join product_template pt on (pt.id=l.product_id)
|
||||
left join product_uom u on (u.id=pt.uom_id)
|
||||
group by
|
||||
to_char(s.date_order, 'dd-MM-YYYY'),to_char(s.date_order, 'YYYY'),to_char(s.date_order, 'MM'),
|
||||
to_char(s.date_order, 'YYYY-MM-DD'), s.partner_id,s.state,
|
||||
s.user_id,s.shop_id,s.company_id,s.sale_journal,l.product_id,s.date_validation,
|
||||
s.date_payment)""")
|
||||
|
||||
report_pos_order()
|
||||
|
|
|
@ -8,26 +8,25 @@
|
|||
<field name="arch" type="xml">
|
||||
<tree string="Point of Sale Analysis">
|
||||
<field name="date" invisible="1"/>
|
||||
<field name="date_validation" invisible="1"/>
|
||||
<field name="date_payment" invisible="1"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
<field name="year" invisible="1"/>
|
||||
<field name="day" invisible="1"/>
|
||||
<field name="month" invisible="1"/>
|
||||
<field name="partner_id" invisible="1"/>
|
||||
<field name="product_id" invisible="1"/>
|
||||
<field name="product_id" invisible="1"/>
|
||||
<field name="shop_id" invisible="1"/>
|
||||
<field name="journal_id" invisible="1"/>
|
||||
<field name="statement_journal_id" invisible="1"/>
|
||||
<!--<field name="journal_id" invisible="1"/>-->
|
||||
<field name="date_validation" invisible="1"/>
|
||||
<field name="date_payment" invisible="1"/>
|
||||
<field name="company_id" invisible="1" groups="base.group_multi_company"/>
|
||||
<field name="nbr" sum="# of Lines"/>
|
||||
<field name="product_qty" sum="# of Qty"/>
|
||||
<field name="price_total" sum="Total Price"/>
|
||||
<field name="average_price" sum="Average Price"/>
|
||||
<field name="total_discount" sum="Total Discount"/>
|
||||
<field name="average_price" avg="Average Price"/>
|
||||
<field name="price_total" sum="Total Price"/>
|
||||
<field name="delay_validation"/>
|
||||
<field name="delay_payment"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<!--<field name="state" invisible="1"/>-->
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -58,9 +57,6 @@
|
|||
domain="[('date','<=', time.strftime('%%Y-%%m-%%d'))]"
|
||||
help="POS ordered created by today"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter icon="terp-dolar"
|
||||
string="Accepted"
|
||||
domain="[('state_2','=',('to_verify'))]" groups="base.group_extended"/>
|
||||
<filter icon="terp-dolar"
|
||||
string="Invoiced"
|
||||
domain="[('state','=',('invoiced'))]"/>
|
||||
|
@ -82,16 +78,18 @@
|
|||
<filter string="Customer" icon="terp-personal" context="{'group_by':'partner_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/>
|
||||
<filter string="Journal" icon="terp-folder-orange" context="{'group_by':'journal_id'}"/>
|
||||
<!--<filter string="Journal" icon="terp-folder-orange" context="{'group_by':'journal_id'}"/>-->
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="Cash Register" icon="terp-folder-orange" context="{'group_by':'statement_journal_id'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>
|
||||
<separator orientation="vertical"/>
|
||||
<!--<filter string="State" icon="terp-stock_effects-object-colorize" context="{'group_by':'state'}"/>-->
|
||||
<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>
|
||||
<newline/>
|
||||
<group expand="0" string="Extended options..." groups="base.group_extended">
|
||||
<field name="date_validation"/>
|
||||
<field name="date_payment"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -102,9 +100,9 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,graph</field>
|
||||
<field name="search_view_id" ref="view_report_pos_order_search"/>
|
||||
<field name="context">{'search_default_today':1,'search_default_User':1}</field>
|
||||
<field name="context">{'search_default_today':1,'search_default_User':1,'group_by_no_leaf':1,'group_by':[]}</field>
|
||||
</record>
|
||||
|
||||
<menuitem action="action_report_pos_order_all" id="menu_report_pos_order_all" parent="menu_point_rep" sequence="1"/>
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
|
|
@ -17,5 +17,37 @@
|
|||
"access_report_sales_by_user_pos_month","report.sales.by.user.pos.month","model_report_sales_by_user_pos_month","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_report_sales_by_margin_pos","report.sales.by.margin.pos","model_report_sales_by_margin_pos","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_report_sales_by_margin_pos_month","report.sales.by.margin.pos.month","model_report_sales_by_margin_pos_month","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_singer_statement","singer.statement","model_singer_statement","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_add_product","pos.add.product ","model_pos_add_product","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_confirm","pos.confirm","model_pos_confirm","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_discount","pos.discount","model_pos_discount","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_get_sale","pos.get.sale","model_pos_get_sale","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_close_statement","pos.open.statement","model_pos_open_statement","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_pos_open_statement","pos.close.statement","model_pos_close_statement","point_of_sale.group_pos_user",1,1,1,0
|
||||
"acess_pos_box_entries ","pos.box.entries ","model_pos_box_entries","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_box_out","pos.box.out","model_pos_box_out","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_details ","pos.details ","model_pos_details","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_sale_user","pos.sale.user","model_pos_sale_user","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_sale_user_today","pos.sales.user.today","model_pos_sales_user_today","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_sales_user_today_current_user","pos.sales.user.today.current_user","model_pos_sales_user_today_current_user","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_all_closed_cashbox_of_the_day","all.closed.cashbox.of.the.day","model_all_closed_cashbox_of_the_day","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_receipt","pos.receipt ","model_pos_receipt","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_payment_report_user","pos.payment.report.user","model_pos_payment_report_user","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_payment_report_date ","pos.payment.report.date ","model_pos_payment_report_date","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_make_payment","pos.make.payment","model_pos_make_payment","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_pos_scan_product","pos.scan.product","model_pos_scan_product","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_payment_report","pos.payment.report","model_pos_payment_report","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_report_pos_order","report.pos.order","model_report_pos_order","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_pos_return","pos.return","model_pos_return","point_of_sale.group_pos_user",1,0,0,0
|
||||
"access_account_bank_statement","account.bank.statement","account.model_account_bank_statement","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_bank_statement_line","account.bank.statement.line","account.model_account_bank_statement_line","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_period","account.period","account.model_account_period","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_fiscalyear","account.fiscalyear","account.model_account_fiscalyear","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_cashbox_line","account.cashbox.line","account.model_account_cashbox_line","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_product_product","product.product","product.model_product_product","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_move_line","account.move.line","account.model_account_move_line","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_move","account.move","account.model_account_move","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_journal","account.journal","account.model_account_journal","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_journal_view","account.journal.view","account.model_account_journal_view","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_analytic_line","account.analytic.line","analytic.model_account_analytic_line","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_analytic_account","account.analytic.account","analytic.model_account_analytic_account","point_of_sale.group_pos_user",1,1,1,0
|
||||
"access_account_journal_column","account.journal.column","account.model_account_journal_column","point_of_sale.group_pos_user",1,1,1,0
|
||||
|
|
|
|
@ -1,7 +1,69 @@
|
|||
<?xml version="1.0" ?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record id="pos_visa_journal" model="account.journal">
|
||||
<field name="name">Visa Journal</field>
|
||||
<field name="code">VIJ</field>
|
||||
<field name="type">cash</field>
|
||||
<field name="view_id" ref="account.account_journal_view"/>
|
||||
<field name="sequence_id" ref="account.sequence_sale_journal"/>
|
||||
<field model="account.account" name="default_credit_account_id" ref="account.a_sale"/>
|
||||
<field model="account.account" name="default_debit_account_id" ref="account.a_sale"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="[(6,0,[ref('base.user_root')])]" name="journal_users"/>
|
||||
</record>
|
||||
|
||||
<record id="pos_cash_journal" model="account.journal">
|
||||
<field name="name">Cash Journal</field>
|
||||
<field name="code">CAJ</field>
|
||||
<field name="type">cash</field>
|
||||
<field name="view_id" ref="account.account_journal_view"/>
|
||||
<field name="sequence_id" ref="account.sequence_sale_journal"/>
|
||||
<field model="account.account" name="default_credit_account_id" ref="account.a_sale"/>
|
||||
<field model="account.account" name="default_debit_account_id" ref="account.a_sale"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="[(6,0,[ref('base.user_root')])]" name="journal_users"/>
|
||||
</record>
|
||||
|
||||
<record id="pos_bankcard_journal" model="account.journal">
|
||||
<field name="name">Bancontact Journal</field>
|
||||
<field name="code">BACJ</field>
|
||||
<field name="type">cash</field>
|
||||
<field name="view_id" ref="account.account_journal_view"/>
|
||||
<field name="sequence_id" ref="account.sequence_sale_journal"/>
|
||||
<field model="account.account" name="default_credit_account_id" ref="account.a_sale"/>
|
||||
<field model="account.account" name="default_debit_account_id" ref="account.a_sale"/>
|
||||
<field name="user_id" ref="base.user_root"/>
|
||||
<field eval="[(6,0,[ref('base.user_root')])]" name="journal_users"/>
|
||||
</record>
|
||||
|
||||
<record id="account.sales_journal" model="account.journal">
|
||||
<field eval="[(6,0,[ref('base.user_root')])]" name="journal_users"/>
|
||||
</record>
|
||||
|
||||
<record id="account.refund_sales_journal" model="account.journal">
|
||||
<field eval="[(6,0,[ref('base.user_root')])]" name="journal_users"/>
|
||||
</record>
|
||||
|
||||
<record id="account.expenses_journal" model="account.journal">
|
||||
<field eval="[(6,0,[ref('base.user_root')])]" name="journal_users"/>
|
||||
</record>
|
||||
|
||||
<record id="account.refund_expenses_journal" model="account.journal">
|
||||
<field eval="[(6,0,[ref('base.user_root')])]" name="journal_users"/>
|
||||
</record>
|
||||
|
||||
<record id="account.bank_journal" model="account.journal">
|
||||
<field eval="[(6,0,[ref('base.user_root')])]" name="journal_users"/>
|
||||
</record>
|
||||
|
||||
<record id="account.check_journal" model="account.journal">
|
||||
<field eval="[(6,0,[ref('base.user_root')])]" name="journal_users"/>
|
||||
</record>
|
||||
|
||||
<record id="stock.stock_journal" model="account.journal">
|
||||
<field eval="[(6,0,[ref('base.user_root')])]" name="journal_users"/>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -1,480 +1,114 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<record model="ir.ui.view" id="view_account_journal_form">
|
||||
<field name="name">Journal</field>
|
||||
<record model="ir.ui.view" id="view_account_journal_pos_user_form">
|
||||
<field name="name">POS Journal</field>
|
||||
<field name="model">account.journal</field>
|
||||
<field name="type">form</field>
|
||||
<field name="priority">10</field>
|
||||
<field name="inherit_id" ref="account.view_account_journal_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="invoice_sequence_id" position="after">
|
||||
<field name="statement_sequence_id"/>
|
||||
<field name="auto_cash"/>
|
||||
<field name="check_dtls"/>
|
||||
<field name="special_journal"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Bank Statement -->
|
||||
|
||||
<record id="view_bank_statement_tree" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.tree</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="red:balance_end_real!=balance_end;blue:state=='draft' and (balance_end_real==balance_end);black:state in ('open');blue:state in ('draft')" string="Statement">
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="period_id"/>
|
||||
<field name="balance_start"/>
|
||||
<field name="balance_end_real"/>
|
||||
<field name="balance_end"/>
|
||||
<field name="user_id"/>
|
||||
<field name="state"/>
|
||||
<button type="object" string="Open" name="button_open" states="draft" icon="terp-camera_test"/>
|
||||
<button type="object" string="Confirm" name="button_confirm" states="open" icon="terp-gtk-go-back-rtl"/>
|
||||
<button type="object" string="Cancel" name="button_cancel" states="confirm" icon="terp-gtk-stop"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_bank_statement_form2" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.form</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Statement">
|
||||
<field name="name" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="company_id" select="1" groups="base.group_multi_company"/>
|
||||
<field name="journal_id" on_change="onchange_journal_id(journal_id)" domain="[('type','=','cash'),('auto_cash','=',False)]" select="1" />
|
||||
<newline/>
|
||||
<field name="date" select="1" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="closing_date" select="1" attrs="{'readonly':[('state','=','confirm')]}"/>
|
||||
<field name="balance_start"/>
|
||||
<field name="balance_end_real"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Starting Details">
|
||||
<field name="starting_details_ids" nolabel = "1" colspan="4">
|
||||
<tree string = "Starting Details" editable="bottom">
|
||||
<field name="pieces"/>
|
||||
<field name="number" on_change="on_change_sub(pieces,number, parent.balance_end)"/>
|
||||
<field name="subtotal" sum="Total"/>
|
||||
</tree>
|
||||
<form string = "Ending Details">
|
||||
<field name="pieces"/>
|
||||
<field name="number" on_change="on_change_sub(pieces,number, parent.balance_end)"/>
|
||||
<field name="subtotal"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Ending Details">
|
||||
<field name="ending_details_ids" nolabel = "1" colspan="4">
|
||||
<tree string = "Ending Details" editable="bottom">
|
||||
<field name="pieces"/>
|
||||
<field name="number" on_change="on_change_sub(pieces,number, parent.balance_end)"/>
|
||||
<field name="subtotal" sum="Total"/>
|
||||
</tree>
|
||||
<form string = "Ending Details">
|
||||
<field name="pieces"/>
|
||||
<field name="number" on_change="on_change_sub(pieces,number, parent.balance_end)"/>
|
||||
<field name="subtotal"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Entry encoding">
|
||||
<field colspan="4" name="line_ids" nolabel="1">
|
||||
<tree editable="bottom" string="Statement lines">
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
|
||||
<field name="amount"/>
|
||||
</tree>
|
||||
<form string="Statement lines">
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
|
||||
<field name="amount"/>
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<separator colspan="4" string="Notes"/>
|
||||
<field colspan="4" name="note" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
<group col="7" colspan="4">
|
||||
<field name="state" colspan="4"/>
|
||||
<field name="total_entry_encoding"/>
|
||||
<xpath expr="//notebook[last()]" position="inside">
|
||||
<page string="Point of Sale">
|
||||
<group col="6" colspan="4">
|
||||
<separator colspan="6" string="Extended Configureation"/>
|
||||
<field name="check_dtls"/>
|
||||
<field name="auto_cash"/>
|
||||
<field name="special_journal"/>
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<button name="button_dummy" states="draft" icon="gtk-execute" string="Compute"/>
|
||||
<button name="button_confirm" states="open" icon="terp-gtk-go-back-rtl" string="Close CashBox" type="object"/>
|
||||
<button name="button_open" states="draft" icon="terp-camera_test" string="Open CashBox" type="object"/>
|
||||
<button name="button_cancel" states="confirm" string="Cancel" type="object" icon="gtk-cancel" groups="base.group_extended"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_bank_statement_form1" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.form</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Statement">
|
||||
<field name="name" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="company_id" select="1" groups="base.group_multi_company"/>
|
||||
<field name="journal_id" on_change="onchange_journal_id(journal_id)" domain="[('type','=','cash')]" select="1" readonly="1"/>
|
||||
<newline/>
|
||||
<field name="date" select="1" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="closing_date" select="1" attrs="{'readonly':[('state','=','confirm')]}"/>
|
||||
<field name="balance_start"/>
|
||||
<field name="balance_end_real"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Details">
|
||||
<field name="ending_details_ids" nolabel = "1" colspan="4">
|
||||
<tree string = "Ending Details" editable="bottom">
|
||||
<field name="pieces"/>
|
||||
<field name="number" on_change="on_change_sub(pieces,number, parent.balance_end)"/>
|
||||
<field name="subtotal" sum="Total"/>
|
||||
</tree>
|
||||
<form string = "Ending Details">
|
||||
<field name="pieces"/>
|
||||
<field name="number" on_change="on_change_sub(pieces,number, parent.balance_end)"/>
|
||||
<field name="subtotal"/>
|
||||
</form>
|
||||
</field>
|
||||
<separator colspan="4" string="Users"/>
|
||||
<field name="journal_users" nolabel="1" colspan="4"/>
|
||||
</page>
|
||||
<page string="Entry encoding">
|
||||
<field colspan="4" name="line_ids" nolabel="1">
|
||||
<tree editable="bottom" string="Statement lines">
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
|
||||
<field name="amount"/>
|
||||
</tree>
|
||||
<form string="Statement lines">
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
|
||||
<field name="amount"/>
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<separator colspan="4" string="Notes"/>
|
||||
<field colspan="4" name="note" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
<group col="7" colspan="4">
|
||||
<field name="state" colspan="4"/>
|
||||
<field name="total_entry_encoding"/>
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<button name="button_dummy" states="draft" icon="gtk-execute" string="Compute"/>
|
||||
<button name="button_confirm" states="open" icon="terp-gtk-go-back-rtl" string="Close CashBox" type="object"/>
|
||||
<button name="button_open" states="draft" icon="terp-camera_test" string="Open CashBox" type="object"/>
|
||||
<button name="button_cancel" states="confirm" icon="gtk-cancel" string="Cancel" type="object" groups="base.group_extended"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_bank_statement_tree_all" model="ir.actions.act_window">
|
||||
<field name="name">My CashBoxes</field>
|
||||
<field name="res_model">account.bank.statement</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_bank_statement_tree"/>
|
||||
<field name="domain">[('user_id','=',uid)]</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_statement1_all">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="view_bank_statement_tree"/>
|
||||
<field name="act_window_id" ref="action_bank_statement_tree_all"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_statement2_all">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_bank_statement_form1"/>
|
||||
<field name="act_window_id" ref="action_bank_statement_tree_all"/>
|
||||
</record>
|
||||
|
||||
<!-- <menuitem action="action_bank_statement_tree_all" id="menu_statement_tree_all" parent="point_of_sale.menu_point_root" sequence="2"/-->
|
||||
<!-- <menuitem action="action_bank_statement_tree_all" id="menu_statement_tree_all" parent="point_of_sale.menu_point_root" sequence="2"/>
|
||||
-->
|
||||
<menuitem name="Cashboxes" parent="point_of_sale.menu_point_root" id="menu_statement_tree_all" sequence="3"/>
|
||||
|
||||
<record id="action_bank_statement_tree1" model="ir.actions.act_window">
|
||||
<field name="name">My Cashboxes to Close</field>
|
||||
<field name="res_model">account.bank.statement</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_bank_statement_tree"/>
|
||||
<field name="domain">[('state','=','open'), ('user_id','=',uid)]</field>
|
||||
|
||||
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_statement1">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="view_bank_statement_tree"/>
|
||||
<field name="act_window_id" ref="action_bank_statement_tree1"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_statement2">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_bank_statement_form1"/>
|
||||
<field name="act_window_id" ref="action_bank_statement_tree1"/>
|
||||
</record>
|
||||
|
||||
<!-- <menuitem action="action_bank_statement_tree1" id="menu_statement_tree1" parent="menu_statement_tree_all" sequence="2"/>-->
|
||||
|
||||
<record id="view_bank_statement_form3" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.form</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Statement">
|
||||
<field name="name" select="1"/>
|
||||
<field name="user_id" select="1"/>
|
||||
<field name="company_id" select="1" groups="base.group_multi_company"/>
|
||||
<field name="journal_id" on_change="onchange_journal_id(journal_id)" domain="[('type','=','cash')]" select="1" readonly="1"/>
|
||||
<newline/>
|
||||
<field name="date" select="1" attrs="{'readonly':[('state','!=','draft')]}"/>
|
||||
<field name="closing_date" select="1" attrs="{'readonly':[('state','=','confirm')]}"/>
|
||||
<field name="balance_start"/>
|
||||
<field name="balance_end_real"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Entry encoding">
|
||||
<field colspan="4" name="line_ids" nolabel="1">
|
||||
<tree editable="bottom" string="Statement lines">
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
|
||||
<field name="amount" />
|
||||
</tree>
|
||||
<form string="Statement lines">
|
||||
<field name="partner_id" on_change="onchange_partner_id(partner_id, type, parent.currency)"/>
|
||||
<field name="amount"/>
|
||||
<field name="name"/>
|
||||
<field name="ref"/>
|
||||
<separator colspan="4" string="Notes"/>
|
||||
<field colspan="4" name="note" nolabel="1"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Starting Details">
|
||||
<field name="balance_end" colspan="4" nolabel="1"/>
|
||||
<newline/>
|
||||
<field name="starting_details_ids" nolabel = "1" colspan="4">
|
||||
<tree string = "Starting Details" editable="bottom">
|
||||
<field name="pieces"/>
|
||||
<field name="number" on_change="on_change_sub(pieces,number)"/>
|
||||
<field name="subtotal" sum="Total"/>
|
||||
</tree>
|
||||
<form string = "Starting Details">
|
||||
<field name="pieces"/>
|
||||
<field name="number" on_change="on_change_sub(pieces,number)"/>
|
||||
<field name="subtotal"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Ending Details">
|
||||
<field name="ending_details_ids" nolabel = "1" colspan="4">
|
||||
<tree string = "Ending Details" editable="bottom">
|
||||
<field name="pieces"/>
|
||||
<field name="number" on_change="on_change_sub(pieces,number)"/>
|
||||
<field name="subtotal" sum="Total"/>
|
||||
</tree>
|
||||
<form string = "Ending Details">
|
||||
<field name="pieces"/>
|
||||
<field name="number" on_change="on_change_sub(pieces,number)"/>
|
||||
<field name="subtotal"/>
|
||||
</form>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
<group col="7" colspan="4">
|
||||
<field name="state" colspan="4"/>
|
||||
<field name="total_entry_encoding"/>
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<button name="button_dummy" states="draft" icon="gtk-execute" string="Compute"/>
|
||||
<button name="button_confirm" states="open" icon="terp-gtk-go-back-rtl" string="Close CashBox" type="object"/>
|
||||
<button name="button_open" states="draft" icon="terp-camera_test" string="Open CashBox" type="object"/>
|
||||
<button name="button_cancel" states="confirm" icon="gtk-cancel" string="Cancel" type="object" groups="base.group_extended"/>
|
||||
|
||||
</group>
|
||||
</form>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_bank_statement_tree2" model="ir.ui.view">
|
||||
<field name="name">account.bank.statement.tree</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree colors="red:balance_end_real!=balance_end;blue:state=='draft' and (balance_end_real==balance_end)" string="Statement">
|
||||
<field name="date"/>
|
||||
<field name="name"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="period_id"/>
|
||||
<field name="balance_start"/>
|
||||
<field name="balance_end_real"/>
|
||||
<field name="balance_end"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="action_bank_statement_treenew" model="ir.actions.act_window">
|
||||
<field name="name">Open a CashBox</field>
|
||||
<field name="res_model">account.bank.statement</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" ref="view_bank_statement_form2"/>
|
||||
<field name="domain">[('state','=','draft'),('user_id','=',uid)]</field>
|
||||
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_statement12">
|
||||
<field name="sequence" eval="2"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="view_bank_statement_tree2"/>
|
||||
<field name="act_window_id" ref="action_bank_statement_treenew"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_statement22">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_bank_statement_form2"/>
|
||||
<field name="act_window_id" ref="action_bank_statement_treenew"/>
|
||||
</record>
|
||||
<!-- <menuitem action="action_bank_statement_treenew" id="menu_statement_tree2" parent="menu_statement_tree_all" sequence="1"/>-->
|
||||
|
||||
|
||||
<menuitem action="action_bank_statement_treenew" id="menu_statement_tree2" parent="menu_statement_tree_all" sequence="1"/>
|
||||
|
||||
<record id="view_account_bank_statment_filter" model="ir.ui.view">
|
||||
<field name="name">account.bank.statment.select</field>
|
||||
<field name="model">account.bank.statement</field>
|
||||
<field name="type">search</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="Search Cashbox">
|
||||
<group col='9' colspan='4'>
|
||||
<filter icon="terp-camera_test" string="Open"
|
||||
domain="[('state','=','open')]"
|
||||
help="All open cashboxes"/>
|
||||
<filter icon="terp-dialog-close" string="To Close"
|
||||
domain="[('state','=','draft')]"
|
||||
help="All cashboxes to close"/>
|
||||
<filter icon="terp-go-today" name="Today" string="Today"
|
||||
domain="[('date','<=', time.strftime('%%Y-%%m-%%d 23:59:59'))]"
|
||||
help="All cashboxes to opened today"/>
|
||||
<separator orientation="vertical"/>
|
||||
<field name="name"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group expand="0" string="Group By..." colspan="4" col="20">
|
||||
<filter string="Journal" icon="terp-folder-blue" domain="[]" context="{'group_by':'journal_id'}"/>
|
||||
<filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||
</group>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_pos_account_bank_statment">
|
||||
<field name="name">All Cashboxes</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.bank.statement</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_id" eval="False"/>
|
||||
<field name="context">{'search_default_Today':1}</field>
|
||||
<field name="search_view_id" ref="view_account_bank_statment_filter"/>
|
||||
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_statement_a1">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="view_bank_statement_tree"/>
|
||||
<field name="act_window_id" ref="action_pos_account_bank_statment"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_statement_a2">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_bank_statement_form3"/>
|
||||
<field name="act_window_id" ref="action_pos_account_bank_statment"/>
|
||||
</record>
|
||||
<menuitem name="All Cashboxes" parent="menu_statement_tree_all"
|
||||
action="action_pos_account_bank_statment" id="menu_pos_bank_statment_tree" groups="base.group_extended" sequence="4"/>
|
||||
|
||||
<record model="ir.actions.act_window" id="action_my_all_pos_account_bank_statment">
|
||||
<field name="name">All My Cashboxes</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.bank.statement</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="domain">[('user_id','=',uid)]</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_my_all_statement_a1">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="view_bank_statement_tree"/>
|
||||
<field name="act_window_id" ref="action_my_all_pos_account_bank_statment"/>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window.view" id="act_my_all_statement_a2">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_bank_statement_form1"/>
|
||||
<field name="act_window_id" ref="action_my_all_pos_account_bank_statment"/>
|
||||
</record>
|
||||
<!-- <menuitem name="All My Cashboxes" parent="menu_statement_tree_all"-->
|
||||
<!-- action="action_my_all_pos_account_bank_statment" id="menu_my_pos_bank_statment_tree" sequence="3"/>-->
|
||||
|
||||
<record model="ir.actions.act_window" id="action_cashboxes_to_close">
|
||||
<field name="name">Cashboxes to Close</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.bank.statement</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state','=','draft')]</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_statement_a5">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="view_bank_statement_tree"/>
|
||||
<field name="act_window_id" ref="action_cashboxes_to_close"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_statement_a6">
|
||||
<field name="sequence" eval="1"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_bank_statement_form1"/>
|
||||
<field name="act_window_id" ref="action_cashboxes_to_close"/>
|
||||
</record>
|
||||
|
||||
<!-- <menuitem name="Cashboxes to Close" parent="menu_statement_tree_all"-->
|
||||
<!-- action="action_cashboxes_to_close" id="menu_cashboxes_to_close_tree" groups="base.group_extended"/>-->
|
||||
|
||||
<menuitem name="Cash Register" parent="point_of_sale.menu_point_root" id="menu_cash_register" sequence="4"/>
|
||||
|
||||
<menuitem
|
||||
name="Open Registers" parent="point_of_sale.menu_point_config"
|
||||
string="Open Register"
|
||||
name="All Cash Registers"
|
||||
parent="menu_cash_register"
|
||||
action="account.action_view_bank_statement_tree"
|
||||
id="menu_all_menu_cash_register"
|
||||
sequence="4"
|
||||
/>
|
||||
|
||||
<record id="action_new_bank_statement_tree" model="ir.actions.act_window">
|
||||
<field name="name">Cash Register</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.bank.statement</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form,tree</field>
|
||||
<field name="view_id" ref="account.view_bank_statement_form2"/>
|
||||
<field name="search_view_id" ref="account.view_account_bank_statement_filter"/>
|
||||
<field name="domain">[('journal_id.type', '=', 'cash')]</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_cash_statement1_all">
|
||||
<field name="sequence" eval="5"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="account.view_bank_statement_tree"/>
|
||||
<field name="act_window_id" ref="action_new_bank_statement_tree"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_cash_statement2_all">
|
||||
<field name="sequence" eval="0"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account.view_bank_statement_form2"/>
|
||||
<field name="act_window_id" ref="action_new_bank_statement_tree"/>
|
||||
</record>
|
||||
|
||||
<record id="action_new_bank_statement_all_tree" model="ir.actions.act_window">
|
||||
<field name="name">All Register</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">account.bank.statement</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form,tree</field>
|
||||
<field name="view_id" ref="account.view_bank_statement_form2"/>
|
||||
<field name="search_view_id" ref="account.view_account_bank_statement_filter"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_cash_statement_all_register1">
|
||||
<field name="sequence" eval="0"/>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="account.view_bank_statement_tree"/>
|
||||
<field name="act_window_id" ref="action_new_bank_statement_all_tree"/>
|
||||
</record>
|
||||
<record model="ir.actions.act_window.view" id="act_cash_statement_all_register">
|
||||
<field name="sequence" eval="5"/>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="account.view_bank_statement_form2"/>
|
||||
<field name="act_window_id" ref="action_new_bank_statement_all_tree"/>
|
||||
</record>
|
||||
|
||||
<menuitem
|
||||
name="All Registers"
|
||||
parent="menu_cash_register"
|
||||
action="action_new_bank_statement_all_tree"
|
||||
id="menu_all_menu_all_register"
|
||||
sequence="4"
|
||||
/>
|
||||
|
||||
<menuitem
|
||||
name="Open a Cash Registers"
|
||||
parent="menu_cash_register"
|
||||
action="action_new_bank_statement_tree"
|
||||
id="menu_new_cash_register"
|
||||
sequence="3"
|
||||
/>
|
||||
|
||||
<menuitem name="Opening Operations" parent="point_of_sale.menu_point_root"
|
||||
id="menu_point_open_config" sequence="1"/>
|
||||
<menuitem
|
||||
name="Open my Cash Registers" parent="menu_point_open_config"
|
||||
string="Open my Cash Register"
|
||||
action="action_pos_open_statement"
|
||||
id="menu_open_statement" sequence="1" />
|
||||
|
||||
<menuitem icon="STOCK_PRINT"
|
||||
action="action_report_all_closed_cashbox_of_the_day"
|
||||
id="menu_all_closed_cashbox_of_the_day"
|
||||
parent="menu_statement_tree_all"/>
|
||||
<menuitem name="Closing Operations" parent="point_of_sale.menu_point_root"
|
||||
id="menu_point_close_config" sequence="3"/>
|
||||
|
||||
<menuitem
|
||||
name="Close Register" parent="point_of_sale.menu_point_config"
|
||||
string="Close Register"
|
||||
name="Close my Cash Register" parent="menu_point_close_config"
|
||||
string="Close my Cash 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>
|
||||
|
|
|
@ -35,14 +35,16 @@ def get_journal(self, cr, uid, context):
|
|||
"""
|
||||
|
||||
obj = self.pool.get('account.journal')
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
user = self.pool.get('res.users').browse(cr, uid, uid)
|
||||
ids = obj.search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', user.company_id.id)])
|
||||
res = obj.read(cr, uid, ids, ['id', 'name'], context)
|
||||
res = [(r['id'], r['name']) for r in res]
|
||||
res.insert(0, ('', ''))
|
||||
obj_ids= statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', 'in', ids)])
|
||||
res_obj = obj.read(cr, uid, ids, ['journal_id'], context)
|
||||
res_obj = [(r1['id'])for r1 in res_obj]
|
||||
res = statement_obj.read(cr, uid, obj_ids, ['journal_id'], context)
|
||||
res = [(r['journal_id']) for r in res]
|
||||
return res
|
||||
|
||||
|
||||
class pos_box_entries(osv.osv_memory):
|
||||
_name = 'pos.box.entries'
|
||||
_description = 'Pos Box Entries'
|
||||
|
@ -62,15 +64,15 @@ class pos_box_entries(osv.osv_memory):
|
|||
obj = self.pool.get('product.product')
|
||||
ids = obj.search(cr, uid, [('income_pdt', '=', True)])
|
||||
res = obj.read(cr, uid, ids, ['id', 'name'], context)
|
||||
res = [(r['id'], r['name']) for r in res]
|
||||
res = [(r['id'],r['name']) for r in res]
|
||||
res.insert(0, ('', ''))
|
||||
|
||||
return res
|
||||
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=32, required=True),
|
||||
'journal_id': fields.selection(get_journal, "Journal", required=True),
|
||||
'name': fields.char('Description', size=32, required=True),
|
||||
'journal_id': fields.selection(get_journal, "Register", required=True),
|
||||
'product_id': fields.selection(_get_income_product, "Operation", required=True),
|
||||
'amount': fields.float('Amount', digits=(16, 2)),
|
||||
'ref': fields.char('Ref', size=32),
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<data>
|
||||
<!-- Box Entries -->
|
||||
|
||||
|
||||
<record id="view_box_entries" model="ir.ui.view">
|
||||
<field name="name">Box Entries</field>
|
||||
<field name="model">pos.box.entries</field>
|
||||
|
@ -14,11 +14,11 @@
|
|||
<field name="journal_id"/>
|
||||
<field name="product_id"/>
|
||||
<field name="amount"/>
|
||||
<field name="ref"/>
|
||||
<!-- <field name="ref"/>-->
|
||||
<group colspan="4" col="2">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Close" />
|
||||
<button name="get_in" string="Make Entries in the CashBox"
|
||||
<button name="get_in" string="Take Money"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
</form>
|
||||
|
@ -31,8 +31,8 @@
|
|||
<field name="res_model">pos.box.entries</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
|
|
@ -49,8 +49,8 @@ class pos_box_out(osv.osv_memory):
|
|||
return res
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=32, required=True),
|
||||
'journal_id': fields.selection(pos_box_entries.get_journal, "Journal", required=True),
|
||||
'name': fields.char('Description', size=32, required=True),
|
||||
'journal_id': fields.selection(pos_box_entries.get_journal, "Register", required=True),
|
||||
'product_id': fields.selection(_get_expense_product, "Operation", required=True),
|
||||
'amount': fields.float('Amount', digits=(16, 2)),
|
||||
'ref': fields.char('Ref', size=32),
|
||||
|
@ -62,12 +62,12 @@ class pos_box_out(osv.osv_memory):
|
|||
def get_out(self, cr, uid, ids, context):
|
||||
|
||||
"""
|
||||
Create the entries in the CashBox .
|
||||
@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 :Return of operation of product
|
||||
Create the entries in the CashBox .
|
||||
@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 :Return of operation of product
|
||||
"""
|
||||
args = {}
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<data>
|
||||
<!-- Box Entries -->
|
||||
|
||||
|
||||
<record id="view_pos_box_out" model="ir.ui.view">
|
||||
<field name="name">Box Out</field>
|
||||
<field name="model">pos.box.out</field>
|
||||
|
@ -14,11 +14,11 @@
|
|||
<field name="journal_id"/>
|
||||
<field name="product_id"/>
|
||||
<field name="amount"/>
|
||||
<field name="ref"/>
|
||||
<!-- <field name="ref"/>-->
|
||||
<group colspan="4" col="2">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Close" />
|
||||
<button name="get_out" string="Make Entries in the CashBox"
|
||||
<button name="get_out" string="Put Money"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
</form>
|
||||
|
@ -31,8 +31,8 @@
|
|||
<field name="res_model">pos.box.out</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</openerp>
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
from osv import osv
|
||||
from tools.translate import _
|
||||
|
||||
|
||||
class pos_close_statement(osv.osv_memory):
|
||||
_name = 'pos.close.statement'
|
||||
_description = 'Close Statements'
|
||||
|
@ -38,27 +37,55 @@ class pos_close_statement(osv.osv_memory):
|
|||
"""
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
|
||||
list_statement = []
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
journal_obj = self.pool.get('account.journal')
|
||||
journal_lst = journal_obj.search(cr, uid, [('company_id', '=', company_id), ('auto_cash', '=', True), ('check_dtls', '=', False)])
|
||||
journal_ids = journal_obj.browse(cr, uid, journal_lst)
|
||||
user_obj="""select DISTINCT journal_id from pos_journal_users where user_id=%d"""%(uid)
|
||||
cr.execute(user_obj)
|
||||
user_journals1= cr.fetchall()
|
||||
lst1=map(lambda x1:x1[0],user_journals1)
|
||||
journal_ids = journal_obj.browse(cr, uid, lst1)
|
||||
|
||||
for journal in journal_ids:
|
||||
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)])
|
||||
list_statement = ids
|
||||
statement_obj.button_confirm(cr, uid, ids, context)
|
||||
if not list_statement:
|
||||
return {}
|
||||
sql = """ select id from account_journal
|
||||
where auto_cash = 'True'
|
||||
and company_id =%d and id =%d"""%(company_id,journal.id)
|
||||
cr.execute(sql)
|
||||
user_journals= cr.fetchall()
|
||||
lst=map(lambda x1:x1[0],user_journals)
|
||||
journal_ids1 = journal_obj.browse(cr, uid, lst)
|
||||
#list_statement=[]
|
||||
|
||||
for journal1 in journal_ids1:
|
||||
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)])
|
||||
if not ids:
|
||||
raise osv.except_osv(_('Message'), _('Journals are allready closed'))
|
||||
else:
|
||||
list_statement.append(ids[0])
|
||||
if not journal.check_dtls:
|
||||
statement_obj.button_confirm_bank(cr, uid, ids, context)
|
||||
# if not list_statement:
|
||||
# return {}
|
||||
# model_data_ids = mod_obj.search(cr, uid,[('model','=','ir.ui.view'),('name','=','view_bank_statement_tree')], context=context)
|
||||
# resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
|
||||
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')
|
||||
id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')
|
||||
if id2:
|
||||
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
|
||||
if id3:
|
||||
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
|
||||
return {
|
||||
'domain': "[('id','in', list_statement)]",
|
||||
'domain': "[('id','in'," + str(list_statement) + ")]",
|
||||
'name': 'Close Statements',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.bank.statement',
|
||||
'view_id': False,
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
'views': [(id2, 'tree'),(id3, 'form')],
|
||||
'type': 'ir.actions.act_window'}
|
||||
|
||||
pos_close_statement()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ from osv import osv
|
|||
from tools.translate import _
|
||||
import time
|
||||
|
||||
|
||||
class pos_open_statement(osv.osv_memory):
|
||||
_name = 'pos.open.statement'
|
||||
_description = 'Open Statements'
|
||||
|
@ -38,67 +37,91 @@ class pos_open_statement(osv.osv_memory):
|
|||
@return : Blank Directory
|
||||
"""
|
||||
list_statement = []
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
|
||||
statement_obj = self.pool.get('account.bank.statement')
|
||||
singer_obj = self.pool.get('singer.statement')
|
||||
sequence_obj = self.pool.get('ir.sequence')
|
||||
journal_obj = self.pool.get('account.journal')
|
||||
journal_lst = journal_obj.search(cr, uid, [('company_id', '=', company_id), ('auto_cash', '=', True)])
|
||||
journal_ids = journal_obj.browse(cr, uid, journal_lst)
|
||||
user_obj="""select DISTINCT journal_id from pos_journal_users where user_id=%d"""%(uid)
|
||||
cr.execute(user_obj)
|
||||
user_journals1= cr.fetchall()
|
||||
lst1=map(lambda x1:x1[0],user_journals1)
|
||||
journal_ids = journal_obj.browse(cr, uid, lst1)
|
||||
|
||||
for journal in journal_ids:
|
||||
ids = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)])
|
||||
if len(ids):
|
||||
raise osv.except_osv(_('Message'), _('You can not open a Cashbox for "%s". \n Please close the cashbox related to. ' % (journal.name)))
|
||||
sql = """ Select id from account_bank_statement
|
||||
where journal_id=%d
|
||||
and company_id =%d
|
||||
order by id desc limit 1""" % (journal.id, company_id)
|
||||
sql = """ select id from account_journal
|
||||
where auto_cash = 'True'
|
||||
and company_id =%d and id =%d"""%(company_id,journal.id)
|
||||
cr.execute(sql)
|
||||
st_id = cr.fetchone()
|
||||
number = ''
|
||||
if journal.statement_sequence_id:
|
||||
number = sequence_obj.get_id(cr, uid, journal.id)
|
||||
else:
|
||||
number = sequence_obj.get(cr, uid,
|
||||
'account.bank.statement')
|
||||
user_journals= cr.fetchall()
|
||||
lst=map(lambda x1:x1[0],user_journals)
|
||||
journal_ids1 = journal_obj.browse(cr, uid, lst)
|
||||
|
||||
# statement_id=statement_obj.create(cr,uid,{'journal_id':journal.id,
|
||||
# 'company_id':company_id,
|
||||
# 'user_id':uid,
|
||||
# 'state':'open',
|
||||
# 'name':number
|
||||
# })
|
||||
period = statement_obj._get_period(cr, uid, context) or None
|
||||
cr.execute("INSERT INTO account_bank_statement(journal_id,company_id,user_id,state,name, period_id,date) VALUES(%d,%d,%d,'open','%s',%d,'%s')"%(journal.id, company_id, uid, number, period, time.strftime('%Y-%m-%d %H:%M:%S')))
|
||||
cr.execute("select id from account_bank_statement where journal_id=%d and company_id=%d and user_id=%d and state='open' and name='%s'"%(journal.id, company_id, uid, number))
|
||||
statement_id = cr.fetchone()[0]
|
||||
if st_id:
|
||||
statemt_id = statement_obj.browse(cr, uid, st_id[0])
|
||||
list_statement.append(statemt_id.id)
|
||||
if statemt_id and statemt_id.ending_details_ids:
|
||||
statement_obj.write(cr, uid, [statement_id], {
|
||||
'balance_start': statemt_id.balance_end,
|
||||
'state': 'open',
|
||||
})
|
||||
if statemt_id.ending_details_ids:
|
||||
for i in statemt_id.ending_details_ids:
|
||||
c = singer_obj.create(cr, uid, {
|
||||
'pieces': i.pieces,
|
||||
'number': i.number,
|
||||
'starting_id': statement_id,
|
||||
})
|
||||
return {
|
||||
'domain': "[('id','in', ["+','.join(map(str,list_statement))+"])]",
|
||||
'name': 'Open Statement',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.bank.statement',
|
||||
'view_id': False, # TODO: REFERENCE RIGHT VIEWS
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
return {}
|
||||
for journal1 in journal_ids1:
|
||||
ids1 = statement_obj.search(cr, uid, [('state', '!=', 'confirm'), ('user_id', '=', uid), ('journal_id', '=', journal.id)])
|
||||
if len(ids):
|
||||
raise osv.except_osv(_('Message'), _('You can not open a Cashbox for "%s". \n Please close the cashbox related to. ' %(journal.name)))
|
||||
sql = """ Select id from account_bank_statement
|
||||
where journal_id =%d
|
||||
and company_id =%d
|
||||
order by id desc limit 1""" %(journal.id, company_id)
|
||||
cr.execute(sql)
|
||||
st_id = cr.fetchone()
|
||||
number = ''
|
||||
if journal.sequence_id:
|
||||
number = sequence_obj.get_id(cr, uid, journal.id)
|
||||
else:
|
||||
number = sequence_obj.get(cr, uid,
|
||||
'account.bank.statement')
|
||||
statement_id=statement_obj.create(cr,uid,{'journal_id':journal.id,
|
||||
'company_id':company_id,
|
||||
'user_id':uid,
|
||||
'state':'open',
|
||||
'name':number
|
||||
})
|
||||
statement_obj.button_open(cr,uid,[statement_id],context)
|
||||
|
||||
# period = statement_obj._get_period(cr, uid, context) or None
|
||||
# cr.execute("INSERT INTO account_bank_statement(journal_id,company_id,user_id,state,name, period_id,date) VALUES(%d,%d,%d,'open','%s',%d,'%s')"%(journal.id, company_id, uid, number, period, time.strftime('%Y-%m-%d %H:%M:%S')))
|
||||
# cr.commit()
|
||||
# cr.execute("select id from account_bank_statement where journal_id=%d and company_id=%d and user_id=%d and state='open' and name='%s'"%(journal.id, company_id, uid, number))
|
||||
# statement_id = cr.fetchone()[0]
|
||||
# print "statement_id",statement_id
|
||||
# if st_id:
|
||||
# statemt_id = statement_obj.browse(cr, uid, st_id[0])
|
||||
# list_statement.append(statemt_id.id)
|
||||
# if statemt_id and statemt_id.ending_details_ids:
|
||||
# statement_obj.write(cr, uid, [statement_id], {
|
||||
# 'balance_start': statemt_id.balance_end,
|
||||
# 'state': 'open',
|
||||
# })
|
||||
# if statemt_id.ending_details_ids:
|
||||
# for i in statemt_id.ending_details_ids:
|
||||
# c = statement_obj.create(cr, uid, {
|
||||
# 'pieces': i.pieces,
|
||||
# 'number': i.number,
|
||||
# 'starting_id': statement_id,
|
||||
# })
|
||||
data_obj = self.pool.get('ir.model.data')
|
||||
id2 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_tree')
|
||||
id3 = data_obj._get_id(cr, uid, 'account', 'view_bank_statement_form2')
|
||||
if id2:
|
||||
id2 = data_obj.browse(cr, uid, id2, context=context).res_id
|
||||
if id3:
|
||||
id3 = data_obj.browse(cr, uid, id3, context=context).res_id
|
||||
|
||||
return {
|
||||
# 'domain': "[('id','in', ["+','.join(map(str,list_statement))+"])]",
|
||||
'domain': "[('state','=','open')]",
|
||||
'name': 'Open Statement',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'tree,form',
|
||||
'res_model': 'account.bank.statement',
|
||||
'views': [(id2, 'tree'),(id3, 'form')],
|
||||
'type': 'ir.actions.act_window'
|
||||
}
|
||||
pos_open_statement()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
||||
#
|
||||
|
@ -15,7 +15,7 @@
|
|||
# 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/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
|
@ -31,31 +31,31 @@ import pos_receipt
|
|||
class pos_make_payment(osv.osv_memory):
|
||||
_name = 'pos.make.payment'
|
||||
_description = 'Point of Sale Payment'
|
||||
|
||||
|
||||
def default_get(self, cr, uid, fields, context):
|
||||
"""
|
||||
"""
|
||||
To get default values for the object.
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
@param fields: List of fields for which we want default values
|
||||
@param context: A standard dictionary
|
||||
@return: A dictionary which of fields with values.
|
||||
"""
|
||||
res = super(pos_make_payment, self).default_get(cr, uid, fields, context=context)
|
||||
|
||||
active_id = context and context.get('active_id',False)
|
||||
if active_id:
|
||||
|
||||
active_id = context and context.get('active_id',False)
|
||||
if active_id:
|
||||
j_obj = self.pool.get('account.journal')
|
||||
company_id = self.pool.get('res.users').browse(cr, uid, uid).company_id.id
|
||||
journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('company_id', '=', company_id)])
|
||||
|
||||
|
||||
if journal:
|
||||
journal = journal[0]
|
||||
else:
|
||||
journal = None
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
|
||||
|
||||
order_obj=self.pool.get('pos.order')
|
||||
order = order_obj.browse(cr, uid, active_id, context)
|
||||
#get amount to pay
|
||||
|
@ -66,50 +66,50 @@ class pos_make_payment(osv.osv_memory):
|
|||
elif order.amount_paid > 0.0:
|
||||
order_obj.write(cr, uid, [active_id], {'state': 'advance'})
|
||||
invoice_wanted_checked = False
|
||||
|
||||
|
||||
current_date = time.strftime('%Y-%m-%d')
|
||||
|
||||
|
||||
if 'journal' in fields:
|
||||
res.update({'journal':journal})
|
||||
res.update({'journal':journal})
|
||||
if 'amount' in fields:
|
||||
res.update({'amount':amount})
|
||||
res.update({'amount':amount})
|
||||
if 'invoice_wanted' in fields:
|
||||
res.update({'invoice_wanted':invoice_wanted_checked})
|
||||
res.update({'invoice_wanted':invoice_wanted_checked})
|
||||
if 'payment_date' in fields:
|
||||
res.update({'payment_date':current_date})
|
||||
if 'payment_name' in fields:
|
||||
res.update({'payment_name':'Payment'})
|
||||
if 'payment_name' in fields:
|
||||
res.update({'payment_name':'Payment'})
|
||||
return res
|
||||
|
||||
|
||||
def view_init(self, cr, uid, fields_list, context=None):
|
||||
res = super(pos_make_payment, self).view_init(cr, uid, fields_list, context=context)
|
||||
active_id = context and context.get('active_id', False) or False
|
||||
active_id = context and context.get('active_id', False) or False
|
||||
if active_id:
|
||||
order = self.pool.get('pos.order').browse(cr, uid, active_id)
|
||||
if not order.lines:
|
||||
raise osv.except_osv('Error!','No order lines defined for this sale ')
|
||||
return True
|
||||
|
||||
|
||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||
"""
|
||||
"""
|
||||
Changes the view dynamically
|
||||
|
||||
|
||||
@param self: The object pointer.
|
||||
@param cr: A database cursor
|
||||
@param uid: ID of the user currently logged in
|
||||
@param context: A standard dictionary
|
||||
|
||||
@param context: A standard dictionary
|
||||
|
||||
@return: New arch of view.
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
result = super(pos_make_payment, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
|
||||
active_model = context.get('active_model')
|
||||
active_id = context.get('active_id', False)
|
||||
if not active_id or (active_model and active_model != 'pos.order'):
|
||||
return result
|
||||
|
||||
return result
|
||||
|
||||
order = self.pool.get('pos.order').browse(cr, uid, active_id)
|
||||
if order.amount_total == order.amount_paid:
|
||||
result['arch'] = """ <form string="Make Payment" colspan="4">
|
||||
|
@ -120,22 +120,23 @@ class pos_make_payment(osv.osv_memory):
|
|||
<button name="print_report" string="Print Receipt" type="object" icon="gtk-print"/>
|
||||
</group>
|
||||
</form>
|
||||
"""
|
||||
"""
|
||||
return result
|
||||
|
||||
def check(self, cr, uid, ids, context):
|
||||
|
||||
|
||||
"""Check the order:
|
||||
if the order is not paid: continue payment,
|
||||
if the order is paid print invoice (if wanted) or ticket.
|
||||
"""
|
||||
active_id = context and context.get('active_id',False)
|
||||
active_id = context and context.get('active_id',False)
|
||||
order_obj = self.pool.get('pos.order')
|
||||
jrnl_obj = self.pool.get('account.journal')
|
||||
jrnl_obj = self.pool.get('account.journal')
|
||||
order = order_obj.browse(cr, uid, active_id, context)
|
||||
order_name = order.name
|
||||
amount = order.amount_total - order.amount_paid
|
||||
data = self.read(cr, uid, ids)[0]
|
||||
|
||||
|
||||
# Todo need to check ...
|
||||
if amount !=0.0:
|
||||
invoice_wanted = data['invoice_wanted']
|
||||
|
@ -143,61 +144,140 @@ class pos_make_payment(osv.osv_memory):
|
|||
if data.get('journal',False):
|
||||
jrnl_used=jrnl_obj.browse(cr, uid, data['journal'])
|
||||
order_obj.write(cr, uid, [active_id], {'invoice_wanted': invoice_wanted})
|
||||
order_obj.add_payment(cr, uid, active_id, data, context=context)
|
||||
order_obj.add_payment(cr, uid, active_id, data, context=context)
|
||||
|
||||
res_obj = self.pool.get('res.company')
|
||||
inv_ref = self.pool.get('account.invoice')
|
||||
inv_line_ref = self.pool.get('account.invoice.line')
|
||||
product_obj= self.pool.get('product.product')
|
||||
inv_ids = []
|
||||
for order in self.pool.get('pos.order').browse(cr, uid, ids, context):
|
||||
# curr_c = order.user_salesman_id.company_id
|
||||
make_obj = self.pool.get('pos.make.payment').browse(cr, uid, uid)
|
||||
if invoice_wanted:
|
||||
if order.invoice_id:
|
||||
inv_ids.append(order.invoice_id.id)
|
||||
# continue
|
||||
# if not make_obj.partner_id:
|
||||
# raise osv.except_osv(_('Error'), _('Please provide a partner for the sale.'))
|
||||
acc= make_obj.partner_id.property_account_receivable.id
|
||||
inv = {
|
||||
'name': 'Invoice from POS: '+order_name,
|
||||
'origin': order_name,
|
||||
'account_id':acc,
|
||||
'journal_id':order.sale_journal.id or None,
|
||||
'type': 'out_invoice',
|
||||
'reference': order.name,
|
||||
'partner_id': make_obj.partner_id.id,
|
||||
'comment': order.note or '',
|
||||
}
|
||||
inv.update(inv_ref.onchange_partner_id(cr, uid, [], 'out_invoice', make_obj.partner_id.id)['value'])
|
||||
if not inv.get('account_id', None):
|
||||
inv['account_id'] = acc
|
||||
inv_id = inv_ref.create(cr, uid, inv, context)
|
||||
self.write(cr, uid, [order.id], {'invoice_id': inv_id, 'state': 'invoiced'})
|
||||
inv_ids.append(inv_id)
|
||||
for line in order.lines:
|
||||
inv_line = {
|
||||
'invoice_id': inv_id,
|
||||
'product_id': line.product_id.id,
|
||||
'quantity': line.qty,
|
||||
}
|
||||
inv_name = product_obj.name_get(cr, uid, [line.product_id.id], context=context)[0][1]
|
||||
|
||||
inv_line.update(inv_line_ref.product_id_change(cr, uid, [],
|
||||
line.product_id.id,
|
||||
line.product_id.uom_id.id,
|
||||
line.qty, partner_id = make_obj.partner_id.id, fposition_id=make_obj.partner_id.property_account_position.id)['value'])
|
||||
# inv_line['price_unit'] = line.price_unit
|
||||
# inv_line['discount'] = line.discount
|
||||
# inv_line['account_id'] = acc
|
||||
# inv_line['name'] = inv_name
|
||||
inv_line['price_unit'] = amount
|
||||
inv_line['discount'] = line.discount
|
||||
inv_line['account_id'] = acc
|
||||
inv_line['name'] = inv_name
|
||||
inv_line['invoice_line_tax_id'] = ('invoice_line_tax_id' in inv_line)\
|
||||
and [(6, 0, inv_line['invoice_line_tax_id'])] or []
|
||||
inv_line_ref.create(cr, uid, inv_line, context)
|
||||
for i in inv_ids:
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'account.invoice', i, 'invoice_open', cr)
|
||||
# return inv_ids
|
||||
# Todo need to check
|
||||
# if amount<=0.0:
|
||||
# context.update({'flag':True})
|
||||
# order_obj.action_paid(cr,uid,[active_id],context)
|
||||
if order_obj.test_paid(cr, uid, [active_id]):
|
||||
if order.partner_id and order.invoice_wanted:
|
||||
return self.create_invoice(cr, uid, ids, context)
|
||||
else:
|
||||
context.update({'flag': True})
|
||||
order_obj.action_paid(cr, uid, [active_id], context)
|
||||
|
||||
# def test_paid(self, cr, uid, ids, context=None):
|
||||
# """ Test all amount is paid for this order
|
||||
# @return: True
|
||||
# """
|
||||
# for order in self.browse(cr, uid, ids, context):
|
||||
# if order.lines and not order.amount_total:
|
||||
# return True
|
||||
# if (not order.lines) or (not order.statement_ids) or \
|
||||
# Decimal(str(order.amount_total))!=Decimal(str(order.amount_paid)):
|
||||
# return False
|
||||
# return True
|
||||
# if order_obj.test_paid(cr, uid, [active_id]):
|
||||
if order_obj.browse(cr, uid, [active_id]):
|
||||
if make_obj.partner_id and make_obj.invoice_wanted:
|
||||
order_obj.write(cr, uid, [active_id],{'state':'paid'})
|
||||
if context.get('return'):
|
||||
order_obj.write(cr, uid, [active_id],{'state':'done'})
|
||||
order_obj.write(cr, uid, [active_id],{'state':'done'})
|
||||
else:
|
||||
order_obj.write(cr, uid, [active_id],{'state':'paid'})
|
||||
return self.print_report(cr, uid, ids, context)
|
||||
order_obj.write(cr, uid, [active_id],{'state':'paid'})
|
||||
return self.print_report(cr, uid, ids, context)
|
||||
# return self.create_invoice(cr, uid, ids, context)
|
||||
else:
|
||||
context.update({'flag': True})
|
||||
order_obj.action_paid(cr, uid, [active_id], context)
|
||||
if context.get('return'):
|
||||
order_obj.write(cr, uid, [active_id],{'state':'done'})
|
||||
else:
|
||||
order_obj.write(cr, uid, [active_id],{'state':'paid'})
|
||||
return self.print_report(cr, uid, ids, context)
|
||||
if order.amount_paid > 0.0:
|
||||
context.update({'flag': True})
|
||||
# Todo need to check
|
||||
order_obj.action_paid(cr, uid, [active_id], context)
|
||||
order_obj.action_paid(cr, uid, [active_id], context)
|
||||
self.pool.get('pos.order').write(cr, uid, [active_id],{'state':'advance'})
|
||||
return self.print_report(cr, uid, ids, context)
|
||||
return {}
|
||||
return self.print_report(cr, uid, ids, context)
|
||||
# return {}
|
||||
return inv_ids
|
||||
|
||||
|
||||
|
||||
def create_invoice(self, cr, uid, ids, context):
|
||||
|
||||
|
||||
"""
|
||||
Create a invoice
|
||||
"""
|
||||
Create a invoice
|
||||
"""
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
active_ids = [context and context.get('active_id',False)]
|
||||
active_ids = [context and context.get('active_id',False)]
|
||||
for i in active_ids:
|
||||
wf_service.trg_validate(uid, 'pos.order', i, 'invoice', cr)
|
||||
datas = {'ids' : context.get('active_id', [])}
|
||||
return {
|
||||
datas = {'ids' : context.get('active_id', [])}
|
||||
return {
|
||||
'type' : 'ir.actions.report.xml',
|
||||
'report_name':'pos.invoice',
|
||||
'datas' : datas,
|
||||
}
|
||||
|
||||
'datas' : datas,
|
||||
}
|
||||
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
"""
|
||||
@summary: To get the date and print the report
|
||||
"""
|
||||
@summary: 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
|
||||
@param context: A standard dictionary
|
||||
@return : retrun report
|
||||
"""
|
||||
"""
|
||||
if not context:
|
||||
context={}
|
||||
active_id=context.get('active_id',[])
|
||||
active_id=context.get('active_id',[])
|
||||
datas = {'ids' : [active_id]}
|
||||
res = {}
|
||||
res = {}
|
||||
datas['form'] = res
|
||||
|
||||
return {
|
||||
|
@ -207,7 +287,7 @@ class pos_make_payment(osv.osv_memory):
|
|||
}
|
||||
|
||||
_columns = {
|
||||
'journal':fields.selection(pos_box_entries.get_journal, "Journal",required=True),
|
||||
'journal':fields.selection(pos_box_entries.get_journal, "Cash Register",required=True),
|
||||
'product_id': fields.many2one('product.product', "Acompte"),
|
||||
'amount':fields.float('Amount', digits=(16,2) ,required= True),
|
||||
'payment_name': fields.char('Payment name', size=32, required=True),
|
||||
|
@ -215,8 +295,15 @@ class pos_make_payment(osv.osv_memory):
|
|||
'is_acc': fields.boolean('Accompte'),
|
||||
'invoice_wanted': fields.boolean('Invoice'),
|
||||
'num_sale':fields.char('Num.File', size=32),
|
||||
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist'),
|
||||
'partner_id': fields.many2one('res.partner', 'Customer'),
|
||||
'invoice_id': fields.many2one('account.invoice', 'Invoice'),
|
||||
'state': fields.selection([('draft', 'Draft'), ('payment', 'Payment'),
|
||||
('advance','Advance'),
|
||||
('paid', 'Paid'), ('done', 'Done'), ('invoiced', 'Invoiced'), ('cancel', 'Cancel')],
|
||||
'State', readonly=True, ),
|
||||
}
|
||||
|
||||
|
||||
pos_make_payment()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Add payment :">
|
||||
<group colspan="4" >
|
||||
<field name="amount" />
|
||||
<group colspan="4" width="600" height="230">
|
||||
<field name="journal"/>
|
||||
<field name="amount" />
|
||||
<field name="payment_date" />
|
||||
<field name="payment_name" />
|
||||
<!--field name="payment_name" /-->
|
||||
<field name="invoice_wanted" />
|
||||
<field name="num_sale" />
|
||||
<field name="is_acc" />
|
||||
|
@ -24,6 +24,11 @@
|
|||
<field name="product_id" attrs="{'required':[('is_acc', '=', True)]}" domain="[('type','=','service')]"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group attrs="{'invisible':[('invoice_wanted','=',False)]}" colspan="4">
|
||||
<field name="partner_id" attrs="{'required':[('invoice_wanted', '=', True)]}" colspan="2"/>
|
||||
<field name="pricelist_id" attrs="{'required':[('invoice_wanted', '=', True)]}" colspan="2"/>
|
||||
</group>
|
||||
<newline/>
|
||||
<group col="2" colspan="4">
|
||||
<button icon='gtk-cancel' special="cancel" string="Cancel" />
|
||||
<button name="check" string="Make Payment" colspan="1" type="object" icon="gtk-ok"/>
|
||||
|
@ -42,4 +47,4 @@
|
|||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@ class pos_receipt(osv.osv_memory):
|
|||
@return: New arch of view with new columns.
|
||||
"""
|
||||
order_lst = self. pool.get('pos.order').browse(cr, uid, context['active_id'])
|
||||
for order in order_lst:
|
||||
if order.state_2 in ('to_verify'):
|
||||
raise osv.except_osv(_('Error!', 'Can not print the receipt because of discount and/or payment '))
|
||||
True
|
||||
# for order in order_lst:
|
||||
# if order.state_2 in ('to_verify'):
|
||||
# raise osv.except_osv(_('Error!', 'Can not print the receipt because of discount and/or payment '))
|
||||
# True
|
||||
|
||||
def print_report(self, cr, uid, ids, context=None):
|
||||
|
||||
|
|
Loading…
Reference in New Issue