-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
151 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
logistic_requisition/test/requisition_create_cost_estimate_only.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
- | ||
Given I create a logistic requisition for cost estimate only, without setting a consignee | ||
- | ||
!record {model: logistic.requisition, id: logistic_requisition_cost_estimate_only_01}: | ||
partner_id: base.res_partner_4 | ||
cost_estimate_only: True | ||
date: !eval "time.strftime('%Y-%m-%d')" | ||
date_delivery: !eval "time.strftime('%Y-%m-%d')" | ||
user_id: base.user_demo | ||
incoterm_id: stock.incoterm_FCA | ||
incoterm_address: incoterm address as text | ||
analytic_id: account.analytic_consultancy | ||
pricelist_id: product.list0 | ||
- | ||
And I add a line 1 | ||
- | ||
!record {model: logistic.requisition.line, id: logistic_requisition_line_cost_estimate_only_01}: | ||
requisition_id: logistic_requisition_cost_estimate_only_01 | ||
product_id: product.product_product_32 | ||
description: "[HEAD] Headset standard" | ||
requested_qty: 100 | ||
requested_uom_id: product.product_uom_unit | ||
date_delivery: !eval "time.strftime('%Y-%m-%d')" | ||
logistic_user_id: base.user_demo | ||
- | ||
And I add a source line to the line 1 | ||
- | ||
!record {model: logistic.requisition.source, id: logistic_requisition_source_cost_estimate_only_01}: | ||
requisition_line_id: logistic_requisition_line_cost_estimate_only_01 | ||
proposed_qty: 110 | ||
proposed_product_id: product.product_product_32 | ||
proposed_uom_id: product.product_uom_unit | ||
unit_cost: 8 | ||
procurement_method: wh_dispatch | ||
price_is: fixed | ||
dispatch_location_id: stock.stock_location_components | ||
- | ||
When I confirm the logistic requisition | ||
- | ||
!python {model: logistic.requisition, id: logistic_requisition_cost_estimate_only_01}: | | ||
self.button_confirm() | ||
- | ||
And I source the lines | ||
- | ||
!python {model: logistic.requisition.line}: | | ||
line1_id = ref("logistic_requisition_line_cost_estimate_only_01") | ||
ids = [line1_id, ] | ||
self.button_sourced(cr, uid, ids) | ||
- | ||
I open the wizard to create a cost estimate from the logistic requisition | ||
- | ||
!python {model: logistic.requisition.cost.estimate}: | | ||
context = {'active_model': 'logistic.requisition', | ||
'active_ids': [ref('logistic_requisition_cost_estimate_only_01')], | ||
} | ||
wizard_id = self.create(cr, uid, {}, context=context) | ||
open_action = self.cost_estimate(cr, uid, wizard_id) | ||
cost_estimate_id = open_action['res_id'] | ||
cost_estimate_obj = self.pool.get('sale.order') | ||
cost_estimate = cost_estimate_obj.browse(cr, uid, cost_estimate_id) | ||
assert len(cost_estimate.order_line) == 1, ( | ||
"Cost Estimate should have 1 line, 1 per logistic requisition line") | ||
- | ||
I check if the information of the logistic requisition are propagated correctly | ||
- | ||
!python {model: logistic.requisition, id: logistic_requisition_cost_estimate_only_01}: | | ||
sale_obj = self.env['sale.order'] | ||
sale = sale_obj.search([('requisition_id', '=', self.id)]) | ||
sale.ensure_one() | ||
assert sale.partner_id == self.partner_id | ||
assert sale.partner_invoice_id == self.partner_id | ||
assert sale.consignee_id == self.consignee_id | ||
assert sale.incoterm == self.incoterm_id | ||
assert sale.incoterm_address == self.incoterm_address | ||
assert sale.project_id == self.analytic_id | ||
- | ||
I check if the information of the lines is correct | ||
- | ||
!python {model: logistic.requisition.source}: | | ||
def check_line(self, cr, uid, source_line_id): | ||
# the upper scope is not accessible here, | ||
# that's why self, cr, uid are passed as arguments | ||
location_obj = self.pool['stock.location'] | ||
source = self.browse(cr, uid, source_line_id) | ||
sale_lines = source.requisition_id.line_ids[0].cost_estimate_id.order_line | ||
sale_line = [line for line in sale_lines if line.product_id == source.proposed_product_id][0] | ||
line = source.requisition_line_id | ||
assert sale_line.product_id == source.proposed_product_id, ( | ||
"product_id should be %s, received %s" % | ||
(source.proposed_product_id, sale_line.product_id)) | ||
|
||
assert sale_line.name == line.description, ( | ||
"name should be %s, received %s" % | ||
(line.description, sale_line.name)) | ||
|
||
assert sale_line.product_uom_qty == source.proposed_qty, ( | ||
"qty should be %s, received %s" % | ||
(source.proposed_qty, sale_line.product_uom_qty)) | ||
|
||
assert sale_line.product_uom == source.proposed_uom_id, ( | ||
"unit of measure should be %s, received %s" % | ||
(source.proposed_uom_id, sale_line.product_uom)) | ||
|
||
assert sale_line.price_unit == source.unit_cost, ( | ||
"price_unit should be %s, received %s" % | ||
(source.unit_cost, sale_line.price_unit)) | ||
|
||
assert sale_line.price_is == source.price_is, ( | ||
"price_is should be %s, received %s" % | ||
(source.price_is, sale_line.price_is)) | ||
|
||
loc = source.dispatch_location_id | ||
if location_obj.get_warehouse(cr, uid, loc): | ||
assert sale_line.warehouse_id.id == location_obj.get_warehouse(cr, uid, loc), ( | ||
"dispatch should be %s, received %s" % | ||
(location_obj.get_warehouse(cr, uid, loc), sale_line.warehouse_id.id)) | ||
else: | ||
assert not sale_line.warehouse_id, ( | ||
"No dispatch location on requisition line, but received a " | ||
"location in sale order line") | ||
|
||
source1_id = ref("logistic_requisition_source_cost_estimate_only_01") | ||
check_line(self, cr, uid, source1_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters