bzr revid: fp@tinyerp.com-20100901213407-1momqe0cfsj9jfcn
This commit is contained in:
Fabien Pinckaers
2010-09-01 23:34:07 +02:00
parent be22df97d6
commit 4c3fc45707
6 changed files with 35 additions and 126 deletions
-40
View File
@@ -1271,46 +1271,6 @@ class pos_payment(osv.osv):
pos_payment()
class account_move_line(osv.osv):
_inherit = 'account.move.line'
def create(self, cr, user, vals, context=None):
pos_obj = self.pool.get('pos.order')
val_name = vals.get('name', '')
val_ref = vals.get('ref', '')
if (val_name and 'POS' in val_name) and (val_ref and 'PACK' in val_ref):
aaa = re.search(r'Stock move.\((.*)\)', vals.get('name'))
name_pos = aaa.groups()[0]
pos_id = name_pos.replace('POS ','')
if pos_id and pos_id.isdigit():
pos_curr = pos_obj.browse(cr,user,int(pos_id))
pos_curr = pos_curr and pos_curr.contract_number or ''
vals['ref'] = pos_curr or vals.get('ref')
return super(account_move_line, self).create(cr, user, vals, context)
account_move_line()
class account_move(osv.osv):
_inherit = 'account.move'
def create(self, cr, user, vals, context=None):
pos_obj = self.pool.get('pos.order')
val_name = vals.get('name', '')
val_ref = vals.get('ref', '')
if (val_name and 'POS' in val_name) and (val_ref and 'PACK' in val_ref):
aaa = re.search(r'Stock move.\((.*)\)', vals.get('name'))
name_pos = aaa.groups()[0]
pos_id = name_pos.replace('POS ','')
if pos_id and pos_id.isdigit():
pos_curr = pos_obj.browse(cr,user,int(pos_id))
pos_curr = pos_curr and pos_curr.contract_number or ''
vals['ref'] = pos_curr or vals.get('ref')
return super(account_move, self).create(cr, user, vals, context)
account_move()
class product_product(osv.osv):
_inherit = 'product.product'
_columns = {
-1
View File
@@ -51,7 +51,6 @@
new_prj = self.read(cr, uid, [new_id], ['name', 'state'])[0]
state = new_prj['state']
name = new_prj['name']
print "Project '%s' created"%name
assert state == 'open', "Project in %s state. Project created from template project must be in open state"%state
-
Reset project template to normal project
+2 -1
View File
@@ -48,12 +48,13 @@ class project_task(osv.osv):
return True
project_task()
class product_product(osv.osv):
_inherit = "product.product"
_columns = {
'project_id': fields.many2one('project.project', 'Project', ondelete='set null',)
}
product_product()
product_product()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+6 -59
View File
@@ -34,78 +34,25 @@ class procurement_order(osv.osv):
if context is None:
context = {}
for procurement in self.browse(cr, uid, ids):
sline = self.pool.get('sale.order.line')
product_obj=self.pool.get('product.product')
content = ''
sale_order = self.pool.get('sale.order')
so_ref = procurement.name.split(':')[0]
order_ids = sale_order.search(cr, uid, [('name', '=', so_ref)], context)
if order_ids:
sale_ids = sale_order.read(cr, uid, order_ids[0], ['order_line'], context=context)['order_line']
else:
so_ref = procurement.origin.split(':')[0]
sale_ids = sline.search(cr, uid, [('procurement_id', '=',procurement.id)], context)
l = None
project_id = None
analytic_account_id = False
partner_id = False
for line in sline.browse(cr, uid, sale_ids, context=context):
content += (line.notes or '')
l = line
partner_id = line.order_id.partner_id.id
if line.order_id.project_id:
analytic_account_id = line.order_id.project_id.id
partner_id = line.order_id.partner_id.id
content+="\n\n"+line.order_id.project_id.complete_name
break
# Creating a project for task.Project is created from Procurement.
project_obj = self.pool.get('project.project')
proj_name = tools.ustr(so_ref)
product_project = procurement.product_id.project_id or False
proj_exist_id = project_obj.search(cr, uid, [('name', '=', proj_name)], context=context)
if not proj_exist_id:
parent_project = False
if product_project:
parent_project = product_project.analytic_account_id.id
project_id = project_obj.create(cr, uid, {'name': proj_name, 'partner_id': partner_id, 'parent_id': parent_project})
else:
project_id = proj_exist_id[0]
self.write(cr, uid, [procurement.id], {'state': 'running'})
name_task = ('','')
planned_hours=0.0
if procurement.product_id.type == 'service':
proc_name = procurement.name
if procurement.origin == proc_name:
proc_name = procurement.product_id.name
name_task = (procurement.origin, proc_name or '')
else:
name_task = (procurement.product_id.name or procurement.origin, procurement.name or '')
planned_hours= procurement.product_id.sale_delay + procurement.product_id. produce_delay
planned_hours = procurement.product_qty
task_id = self.pool.get('project.task').create(cr, uid, {
'name': '%s:%s' % name_task,
'name': '%s:%s' % (procurement.origin or '', procurement.name),
'date_deadline': procurement.date_planned,
'planned_hours':planned_hours,
'remaining_hours': planned_hours,
'user_id': procurement.product_id.product_manager.id,
'notes': "b"+(l and l.order_id.note or ''),
'notes': procurement.note,
'procurement_id': procurement.id,
'description': content,
'description': procurement.note,
'date_deadline': procurement.date_planned,
'project_id': procurement.project_id and procurement.project_id.id or False,
'state': 'draft',
'partner_id': l and l.order_id.partner_id.id or False,
'company_id': procurement.company_id.id,
'project_id': project_id,
},context=context)
self.write(cr, uid, [procurement.id],{'task_id':task_id})
product_obj.write(cr,uid,[procurement.product_id.id],{'project_id':project_id})
return task_id
procurement_order()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+5 -5
View File
@@ -37,11 +37,11 @@
so = self.browse(cr, uid, ref("sale_order_so9"))
assert so.picking_ids,"Picking has not been generated for sale_order_so9"
-
Then I click on the "Products Received" button of Incoming Shipments
Then I confirm the picking
-
!record {model: stock.partial.picking, id: stock_partial_picking_0}:
date: '2010-07-17 17:52:09'
-
-
Then I done the picking
-
!python {model: stock.picking }: |
@@ -86,7 +86,7 @@
inv_brw = self.browse(cr,uid,ids)[0]
for inv_lines in inv_brw.invoice_line:
qty1 = inv_lines.quantity
assert ('qty1','=','qty'), "Quantities are not same"
assert qty1==qty, "Quantities are not same"
-
I open the Invoice for the SO.
-
@@ -123,10 +123,10 @@
so = sale_order_obj.browse(cr, uid, ref("sale_order_so9"))
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
assert (invoice.state) =='paid', "Invoice for SO is not in done state."
assert invoice.state =='paid', "Invoice for SO is not in done state."
-
I check that Paid has been set to true.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so9"))
assert(sale_id.invoiced == True), "Paid has not been set to true"
assert sale_id.invoiced == True, "Paid has not been set to true"
+22 -20
View File
@@ -1,12 +1,11 @@
-
In order to test the Sale module in OpenERP,
I create a Sale Order for Slider Mobile for 500 quantity having Shipping Policy 'Invoice from Picking' and Invoice on 'Shipped quantities'
in order to create an invoice based on the shipping quantity
I create a Sale Order for Slider Mobile for 200 quantity having Shipping Policy 'Invoice from Picking' and Invoice on 'Shipped quantities'
-
!record {model: sale.order, id: sale_order_so6}:
date_order: '2010-07-17'
invoice_quantity: order
name: Test_SO006
name: Test_SO006BIS
order_line:
- name: Slider Mobile
price_unit: 200
@@ -37,12 +36,12 @@
so = self.browse(cr, uid, ref("sale_order_so6"))
assert so.picking_ids,"Picking has not been generated for sale_order_so6"
-
Then I click on the "Products Received" button of Incoming Shipments
Then I click on the "Product Sent" button of Outgoing Shipments
-
!record {model: stock.partial.picking, id: stock_partial_picking_0}:
date: '2010-07-17 17:52:09'
-
Then I done the picking
I change the quantity on the picking to 199, and confirm partially 100 PCE.
-
!python {model: stock.picking }: |
import time
@@ -50,22 +49,24 @@
so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')])
if picking_id:
pick=self.browse(cr,uid,picking_id[0])
self.pool.get('stock.move').write(cr, uid, [pick.move_lines[0].id], {'product_qty': 199, 'product_uos_qty': 199})
pick=self.browse(cr,uid,picking_id[0])
pick.force_assign(cr, uid)
partial_datas = {
'partner_id':pick.address_id.partner_id.id,
'address_id': pick.address_id.id,
'delivery_date' : time.strftime('%Y-%m-%d'),
}
'partner_id':pick.address_id.partner_id.id,
'address_id': pick.address_id.id,
'delivery_date' : time.strftime('%Y-%m-%d'),
}
move = pick.move_lines[0]
partial_datas['move%s'%(move.id)]= {
'product_id': move.product_id.id,
'product_qty': '100',
'product_uom': move.product_uom.id,
}
}
self.do_partial(cr, uid, [pick.id],partial_datas)
-
Then I create invoice from picking
Then I create the invoice from the two partial picking
-
!record {model: stock.invoice.onshipping, id: stock_invoice_onshipping_6}:
invoice_date: '2010-07-17'
@@ -89,21 +90,22 @@
so = self.browse(cr, uid, ref("sale_order_so6"))
assert so.invoice_ids, "Invoices has not been generated for sale_order_so6"
-
I verify that an invoice is created on the basis of shipped quantity
I verify that an invoice is created on the basis of shipped quantities 199 not ordered quantities 200
-
!python {model: account.invoice}: |
sale_order_obj = self.pool.get('sale.order')
so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
picking_obj = self.pool.get('stock.picking')
ids = picking_obj.search(cr, uid, [('origin', '=', so.name)])
pick_brw = picking_obj.browse(cr,uid, ids)[0]
for lines in pick_brw.move_lines:
qty=lines.product_qty
inv_id = self.search(cr, uid, [('origin', '=', so.name)])
ids = picking_obj.search(cr, uid, [('origin', '=', so.name),('type','=','out')])
qty = qty1 = 0.0
for pick_brw in picking_obj.browse(cr,uid, ids):
for lines in pick_brw.move_lines:
qty=lines.product_qty
inv_id = self.search(cr, uid, [('origin', 'like', so.name)])
inv_brw = self.browse(cr,uid,inv_id)[0]
for inv_lines in inv_brw.invoice_line:
qty1=inv_lines.quantity
assert ('qty1','=','qty'), "Quantities are not same"
assert abs(qty1-qty) < 0.001, "Quantities are not the same"
-
I open the Invoice for the SO.
-
@@ -140,10 +142,10 @@
so = sale_order_obj.browse(cr, uid, ref("sale_order_so6"))
invoice_ids = so.invoice_ids
for invoice in invoice_ids:
assert (invoice.state) =='paid', "Invoice for SO is not in done state."
assert invoice.state=='paid', "Invoice for SO is not in done state."
-
I check that Paid has been set to true.
-
!python {model: sale.order}: |
sale_id=self.browse(cr, uid, ref("sale_order_so6"))
assert(sale_id.invoiced == True), "Paid has not been set to true"
assert sale_id.invoiced == True, "Paid has not been set to true"