diff --git a/addons/point_of_sale/pos_view.xml b/addons/point_of_sale/pos_view.xml
index 6649deea13b..dbbd3a6b1f8 100644
--- a/addons/point_of_sale/pos_view.xml
+++ b/addons/point_of_sale/pos_view.xml
@@ -110,6 +110,7 @@
+
diff --git a/addons/point_of_sale/wizard/pos_add_product.py b/addons/point_of_sale/wizard/pos_add_product.py
index 5d88b75d7ff..5150e10f99f 100644
--- a/addons/point_of_sale/wizard/pos_add_product.py
+++ b/addons/point_of_sale/wizard/pos_add_product.py
@@ -62,6 +62,14 @@ class add_product(osv.osv_memory):
'type': 'ir.actions.act_window',
}
def close_action(self, cr, uid, ids, context):
+ """
+ To get the product and Make the payment .
+ @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 the Make Payment
+ """
record_id = context and context.get('active_id', False)
order_obj= self.pool.get('pos.order')
diff --git a/addons/point_of_sale/wizard/pos_discount.py b/addons/point_of_sale/wizard/pos_discount.py
index 8b0f4b45fa4..0e3fc88767c 100644
--- a/addons/point_of_sale/wizard/pos_discount.py
+++ b/addons/point_of_sale/wizard/pos_discount.py
@@ -37,6 +37,14 @@ class pos_discount(osv.osv_memory):
def view_init(self, cr, uid, fields_list, context=None):
+ """
+ Creates view dynamically and adding fields at runtime.
+ @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: New arch of view with new columns.
+ """
res = super(pos_discount, self).view_init(cr, uid, fields_list, context=context)
record_id = context and context.get('active_id', False) or False
order = self.pool.get('pos.order').browse(cr, uid, record_id)
diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py
index 565ae257180..aa4d200467a 100644
--- a/addons/point_of_sale/wizard/pos_payment.py
+++ b/addons/point_of_sale/wizard/pos_payment.py
@@ -124,6 +124,7 @@ class pos_make_payment(osv.osv_memory):
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.
@@ -168,6 +169,10 @@ class pos_make_payment(osv.osv_memory):
def create_invoice(self, cr, uid, ids, context):
+
+ """
+ Create a invoice
+ """
wf_service = netsvc.LocalService("workflow")
active_ids = [context and context.get('active_id',False)]
for i in active_ids:
@@ -180,8 +185,6 @@ class pos_make_payment(osv.osv_memory):
}
def print_report(self, cr, uid, ids, context=None):
- if not context:
- context={}
"""
@summary: To get the date and print the report
@param self: The object pointer.
@@ -189,7 +192,9 @@ class pos_make_payment(osv.osv_memory):
@param uid: ID of the user currently logged in
@param context: A standard dictionary
@return : retrun report
- """
+ """
+ if not context:
+ context={}
active_id=context.get('active_id',[])
datas = {'ids' : [active_id]}
res = {}
diff --git a/addons/point_of_sale/wizard/pos_payment_report_date.py b/addons/point_of_sale/wizard/pos_payment_report_date.py
index c2e60a07045..d30ff412887 100644
--- a/addons/point_of_sale/wizard/pos_payment_report_date.py
+++ b/addons/point_of_sale/wizard/pos_payment_report_date.py
@@ -26,9 +26,6 @@ import time
class pos_payment_report_date(osv.osv_memory):
- '''
- Open ERP Model
- '''
_name = 'pos.payment.report.date'
_description = 'POS Payment Report according to date'
def print_report(self, cr, uid, ids, context=None):
diff --git a/addons/point_of_sale/wizard/pos_payment_report_user.py b/addons/point_of_sale/wizard/pos_payment_report_user.py
index c8f32ff8cb0..e58073bdcbd 100644
--- a/addons/point_of_sale/wizard/pos_payment_report_user.py
+++ b/addons/point_of_sale/wizard/pos_payment_report_user.py
@@ -25,9 +25,6 @@ from osv import fields
class pos_payment_report_user(osv.osv_memory):
- '''
- Open ERP Model
- '''
_name = 'pos.payment.report.user'
_description = 'Sales lines by Users'
def print_report(self, cr, uid, ids, context=None):
diff --git a/addons/point_of_sale/wizard/pos_receipt.py b/addons/point_of_sale/wizard/pos_receipt.py
index bf37288f55b..daf63fd6674 100644
--- a/addons/point_of_sale/wizard/pos_receipt.py
+++ b/addons/point_of_sale/wizard/pos_receipt.py
@@ -32,6 +32,14 @@ class pos_receipt(osv.osv_memory):
}
def view_init(self, cr, uid, fields_list, context=None):
+ """
+ Creates view dynamically and adding fields at runtime.
+ @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: 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'):
diff --git a/addons/point_of_sale/wizard/pos_return.py b/addons/point_of_sale/wizard/pos_return.py
index 91a063df9a9..13a31057d28 100644
--- a/addons/point_of_sale/wizard/pos_return.py
+++ b/addons/point_of_sale/wizard/pos_return.py
@@ -63,6 +63,14 @@ class pos_return(osv.osv_memory):
return res
def view_init(self, cr, uid, fields_list, context=None):
+ """
+ Creates view dynamically and adding fields at runtime.
+ @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: New arch of view with new columns.
+ """
res = super(pos_return, self).view_init(cr, uid, fields_list, context=context)
order_obj=self.pool.get('pos.order')
if not context:
@@ -77,6 +85,18 @@ class pos_return(osv.osv_memory):
return res
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
+
+ @return: New arch of view.
+
+ """
result = super(pos_return, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar,submenu)
if not context:
context={}
@@ -123,6 +143,15 @@ class pos_return(osv.osv_memory):
def create_returns(self, cr, uid, data, context):
+ """
+ @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 the add product form again for adding more product
+
+ """
return {
'name': _('Add Product'),
'view_type': 'form',
diff --git a/addons/procurement/__openerp__.py b/addons/procurement/__openerp__.py
index 8bd8d05c685..e96eb176842 100644
--- a/addons/procurement/__openerp__.py
+++ b/addons/procurement/__openerp__.py
@@ -44,7 +44,7 @@
'process/procurement_process.xml',
"company_view.xml",
],
- 'demo_xml': ['stock_orderpoint.xml'],
+# 'demo_xml': ['stock_orderpoint.xml'],
'installable': True,
'active': False,
'certificate': '',
diff --git a/addons/product/product.py b/addons/product/product.py
index 407125c841d..ce650e86c2f 100644
--- a/addons/product/product.py
+++ b/addons/product/product.py
@@ -215,7 +215,7 @@ class product_category(osv.osv):
relation='account.account',
string="Stock variation Account",
method=True,
- view_load=True,),
+ view_load=True, help="This account will be used in product when valuation type is real-time valuation ",),
}
@@ -467,7 +467,7 @@ class product_product(osv.osv):
'pricelist_id': fields.dummy(string='Pricelist',relation='product.pricelist', type='many2one'),
'valuation':fields.selection([('manual_periodic','Manual Periodic Valuation'),
('real_time','Real Time valuation'),
- ('','')],'Valuation'),
+ ('','')],'Valuation',help="Decide if the system must automatically creates account moves based on stock moves"),
}
def onchange_uom(self, cursor, user, ids, uom_id,uom_po_id):
diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index dcdbe079a8e..2a2294e2397 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -610,7 +610,8 @@ class stock_picking(osv.osv):
picking_obj = self.browse(cr, uid, [id], context)[0]
if ('name' not in default) or (picking_obj.name=='/'):
seq_obj_name = 'stock.picking.' + picking_obj.type
- default['name'] = self.pool.get('ir.sequence').get(cr, uid, seq_obj_name)
+ default['name'] = self.pool.get('ir.sequence').get(cr, uid, seq_obj_name)
+
return super(stock_picking, self).copy(cr, uid, id, default, context)
def onchange_partner_in(self, cr, uid, context, partner_id=None):
@@ -1742,8 +1743,12 @@ class stock_move(osv.osv):
"""
track_flag = False
picking_ids = []
+ lines=[]
+ sale=[]
+ purchase=[]
product_uom_obj = self.pool.get('product.uom')
price_type_obj = self.pool.get('product.price.type')
+ product_obj=self.pool.get('product.product')
move_obj = self.pool.get('account.move')
for move in self.browse(cr, uid, ids):
if move.picking_id: picking_ids.append(move.picking_id.id)
@@ -1766,87 +1771,75 @@ class stock_move(osv.osv):
acc_src = None
acc_dest = None
if move.product_id.valuation=='real_time':
+
journal_id = move.product_id.categ_id.property_stock_journal and move.product_id.categ_id.property_stock_journal.id or False
- if(move.location_id.usage=='internal' and move.location_dest_id.usage=='internal' and move.location_id.company_id.id!=move.location_dest_id.company_id.id) or ( move.location_id.usage=='internal' or move.location_dest_id.usage=='internal'):
- test = [('product.product', move.product_id.id)]
- if move.product_id.categ_id:
- test.append( ('product.category', move.product_id.categ_id.id) )
- if not acc_src:
- acc_src = move.product_id.product_tmpl_id.\
- property_stock_account_input.id
- if not acc_src:
- acc_src = move.product_id.categ_id.\
- property_stock_account_input_categ.id
- if not acc_src:
+ accounts=product_obj.get_product_accounts(cr,uid,move.product_id.id,context)
+ account_variation = move.product_id.categ_id.property_stock_variation.id
+ acc_src=accounts['stock_account_input']
+ acc_dest=accounts['stock_account_output']
+ journal_id=accounts['stock_journal']
+ if not acc_src:
raise osv.except_osv(_('Error!'),
_('There is no stock input account defined ' \
'for this product: "%s" (id: %d)') % \
(move.product_id.name,
move.product_id.id,))
- if not acc_dest:
- acc_dest = move.product_id.product_tmpl_id.\
- property_stock_account_output.id
- if not acc_dest:
- acc_dest = move.product_id.categ_id.\
- property_stock_account_output_categ.id
- if not acc_dest:
+ if not acc_dest:
raise osv.except_osv(_('Error!'),
_('There is no stock output account defined ' \
'for this product: "%s" (id: %d)') % \
(move.product_id.name,
move.product_id.id,))
- if not move.product_id.categ_id.property_stock_journal.id:
+ if not journal_id:
raise osv.except_osv(_('Error!'),
_('There is no journal defined '\
'on the product category: "%s" (id: %d)') % \
(move.product_id.categ_id.name,
move.product_id.categ_id.id,))
- journal_id = move.product_id.categ_id.property_stock_journal.id
- if acc_src != acc_dest:
- ref = move.picking_id and move.picking_id.name or False
- default_uom = move.product_id.uom_id.id
- date = time.strftime('%Y-%m-%d')
- q = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom)
- if move.product_id.cost_method == 'average' and move.price_unit:
- amount = q * move.price_unit
- # Base computation on valuation price type
- else:
- company_id = move.company_id.id
- context['currency_id'] = move.company_id.currency_id.id
- pricetype = price_type_obj.browse(cr,uid,move.company_id.property_valuation_price_type.id)
- amount_unit = move.product_id.price_get(pricetype.field, context)[move.product_id.id]
- amount = amount_unit * q or 1.0
- # amount = q * move.product_id.standard_price
-
- partner_id = False
- if move.picking_id:
- partner_id = move.picking_id.address_id and (move.picking_id.address_id.partner_id and move.picking_id.address_id.partner_id.id or False) or False
- lines = [
- (0, 0, {
- 'name': move.name,
- 'quantity': move.product_qty,
- 'product_id': move.product_id and move.product_id.id or False,
- 'credit': amount,
- 'account_id': acc_src,
- 'ref': ref,
- 'date': date,
- 'partner_id': partner_id}),
- (0, 0, {
- 'name': move.name,
- 'product_id': move.product_id and move.product_id.id or False,
- 'quantity': move.product_qty,
- 'debit': amount,
- 'account_id': acc_dest,
- 'ref': ref,
- 'date': date,
- 'partner_id': partner_id})
- ]
- move_obj.create(cr, uid, {
- 'name': move.name,
- 'journal_id': journal_id,
- 'line_id': lines,
- 'ref': ref,
- })
+ if not account_variation:
+ raise osv.except_osv(_('Error!'),
+ _('There is no variation account defined '\
+ 'on the product category: "%s" (id: %d)') % \
+ (move.product_id.categ_id.name,
+ move.product_id.categ_id.id,))
+ if acc_src != acc_dest:
+ default_uom = move.product_id.uom_id.id
+ q = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom)
+ if move.product_id.cost_method == 'average' and move.price_unit:
+ amount = q * move.price_unit
+ # Base computation on valuation price type
+ else:
+ company_id = move.company_id.id
+ context['currency_id'] = move.company_id.currency_id.id
+ pricetype = price_type_obj.browse(cr,uid,move.company_id.property_valuation_price_type.id)
+ amount_unit = move.product_id.price_get(pricetype.field, context)[move.product_id.id]
+ amount = amount_unit * q or 1.0
+ # amount = q * move.product_id.standard_price
+ partner_id = False
+ if move.picking_id:
+
+ if (move.location_id.usage=='internal' and move.location_dest_id.usage=='customer') or \
+ (move.location_id.usage=='internal' and move.location_dest_id.usage=='internal'\
+ and move.location_id.company_id.id!=move.location_dest_id.company_id.id):
+ sale.append(self.create_account_move(cr,uid,move,acc_dest ,account_variation ,amount,context))
+
+ if (move.location_id.usage =='supplier' and move.location_dest_id.usage=='internal') or\
+ (move.location_id.usage=='internal' and move.location_dest_id.usage=='internal'\
+ and move.location_id.company_id.id!=move.location_dest_id.company_id.id):
+
+ purchase.append(self.create_account_move(cr,uid,move,account_variation, acc_src ,amount,context))
+
+
+ lines.append(purchase and purchase[0] )
+ lines.append( sale and sale[0])
+
+ move_obj.create(cr, uid, {
+ 'name': move.name,
+ 'journal_id': journal_id,
+ 'type':'cont_voucher',
+ 'line_id': len(lines)==2 and lines[0] +lines[1] or lines,
+ 'ref': move.picking_id and move.picking_id.name,
+ })
tracking_lot = False
if context:
tracking_lot = context.get('tracking_lot', False)
@@ -1865,7 +1858,31 @@ class stock_move(osv.osv):
for id in ids:
wf_service.trg_trigger(uid, 'stock.move', id, cr)
return True
-
+
+ def create_account_move(self, cr, uid, move,account_id,account_variation,amount, context=None):
+
+ partner_id = move.picking_id.address_id and (move.picking_id.address_id.partner_id and move.picking_id.address_id.partner_id.id or False) or False
+ lines=[(0, 0, {
+ 'name': move.name,
+ 'quantity': move.product_qty,
+ 'product_id': move.product_id and move.product_id.id or False,
+ 'credit': amount,
+ 'account_id': account_id,
+ 'ref': move.picking_id and move.picking_id.name or False,
+ 'date': time.strftime('%Y-%m-%d') ,
+ 'partner_id': partner_id,
+ }),
+ (0, 0, {
+ 'name': move.name,
+ 'product_id': move.product_id and move.product_id.id or False,
+ 'quantity': move.product_qty,
+ 'debit': amount,
+ 'account_id': account_variation,
+ 'ref': move.picking_id and move.picking_id.name or False,
+ 'date': time.strftime('%Y-%m-%d') ,
+ 'partner_id': partner_id,
+ })]
+ return lines
def unlink(self, cr, uid, ids, context=None):
if context is None:
context = {}
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 7eab6aa8c3e..fab489fa163 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -757,7 +757,7 @@