Create drop shipment depending on the shipment method
The purchase request may be created later so not having one does not mean that no drop shipment will be created. issue7200 review44111002
This commit is contained in:
1 parent
1b1e5558f9
commit
8c9feb4ed3
4 files changed
+149
-4
No files matched your search
@@ -1,3 +1,5 @@
|
||||
* Create drop shipment depending on the shipment method
|
||||
|
||||
Version 4.6.0 - 2017-10-30
|
||||
* Bug fixes (see mercurial logs for details)
|
||||
|
||||
|
||||
@@ -120,13 +120,14 @@ class SaleLine:
|
||||
"Return True if the sale line can have drop move"
|
||||
if not self.supply_on_sale:
|
||||
return False
|
||||
if not self.purchase_request or not self.purchase_request.customer:
|
||||
if self.purchase_request and not self.purchase_request.customer:
|
||||
return False
|
||||
if self.purchase_request_state == 'cancel':
|
||||
return False
|
||||
purchase_line = self.purchase_request.purchase_line
|
||||
if purchase_line and purchase_line.move_done:
|
||||
return False
|
||||
if self.purchase_request:
|
||||
purchase_line = self.purchase_request.purchase_line
|
||||
if purchase_line and purchase_line.move_done:
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_move(self, shipment_type):
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
=============================================
|
||||
Sale Supply Drop Shipment on Invoice Scenario
|
||||
=============================================
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime
|
||||
>>> from decimal import Decimal
|
||||
>>> from proteus import Model, Wizard
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
>>> from trytond.modules.company.tests.tools import create_company, \
|
||||
... get_company
|
||||
>>> from trytond.modules.account.tests.tools import create_fiscalyear, \
|
||||
... create_chart, get_accounts
|
||||
>>> from trytond.modules.account_invoice.tests.tools import \
|
||||
... set_fiscalyear_invoice_sequences, create_payment_term
|
||||
|
||||
Install sale_supply_drop_shipment::
|
||||
|
||||
>>> config = activate_modules('sale_supply_drop_shipment')
|
||||
|
||||
Create company::
|
||||
|
||||
>>> _ = create_company()
|
||||
>>> company = get_company()
|
||||
|
||||
Create fiscal year::
|
||||
|
||||
>>> fiscalyear = set_fiscalyear_invoice_sequences(
|
||||
... create_fiscalyear(company))
|
||||
>>> fiscalyear.click('create_period')
|
||||
|
||||
Create chart of accounts::
|
||||
|
||||
>>> _ = create_chart(company)
|
||||
>>> accounts = get_accounts(company)
|
||||
|
||||
>>> Journal = Model.get('account.journal')
|
||||
>>> cash_journal, = Journal.find([('type', '=', 'cash')])
|
||||
>>> cash_journal.credit_account = accounts['cash']
|
||||
>>> cash_journal.debit_account = accounts['cash']
|
||||
>>> cash_journal.save()
|
||||
|
||||
Create parties::
|
||||
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> supplier = Party(name='Supplier')
|
||||
>>> supplier.save()
|
||||
>>> customer = Party(name='Customer')
|
||||
>>> customer.save()
|
||||
|
||||
Create product::
|
||||
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> ProductSupplier = Model.get('purchase.product_supplier')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'product'
|
||||
>>> template.default_uom = unit
|
||||
>>> template.type = 'goods'
|
||||
>>> template.purchasable = True
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.account_expense = accounts['expense']
|
||||
>>> template.account_revenue = accounts['revenue']
|
||||
>>> template.supply_on_sale = True
|
||||
>>> template.save()
|
||||
>>> product, = template.products
|
||||
>>> product_supplier = ProductSupplier()
|
||||
>>> product_supplier.product = template
|
||||
>>> product_supplier.party = supplier
|
||||
>>> product_supplier.drop_shipment = True
|
||||
>>> product_supplier.lead_time = datetime.timedelta(0)
|
||||
>>> product_supplier.save()
|
||||
|
||||
Sale 5 products with shipment method on invoice::
|
||||
|
||||
>>> Sale = Model.get('sale.sale')
|
||||
>>> sale = Sale()
|
||||
>>> sale.party = customer
|
||||
>>> sale.shipment_method = 'invoice'
|
||||
>>> sale_line = sale.lines.new()
|
||||
>>> sale_line.product = product
|
||||
>>> sale_line.quantity = 5
|
||||
>>> sale.click('quote')
|
||||
>>> sale.click('confirm')
|
||||
>>> sale.click('process')
|
||||
>>> sale.state
|
||||
u'processing'
|
||||
>>> len(sale.shipments)
|
||||
0
|
||||
>>> len(sale.drop_shipments)
|
||||
0
|
||||
>>> invoice, = sale.invoices
|
||||
>>> sale_line, = sale.lines
|
||||
>>> sale_line.purchase_request
|
||||
|
||||
Pay for 3 products::
|
||||
|
||||
>>> invoice_line, = invoice.lines
|
||||
>>> invoice_line.quantity = 3
|
||||
>>> invoice.click('post')
|
||||
>>> pay = Wizard('account.invoice.pay', [invoice])
|
||||
>>> pay.form.journal = cash_journal
|
||||
>>> pay.execute('choice')
|
||||
|
||||
Not yet a purchase request::
|
||||
|
||||
>>> sale.reload()
|
||||
>>> len(sale.shipments)
|
||||
0
|
||||
>>> len(sale.drop_shipments)
|
||||
0
|
||||
>>> sale_line.reload()
|
||||
>>> sale_line.purchase_request
|
||||
|
||||
Pay for remaining products::
|
||||
|
||||
>>> sale.reload()
|
||||
>>> _, invoice = sale.invoices
|
||||
>>> invoice.click('post')
|
||||
>>> pay = Wizard('account.invoice.pay', [invoice])
|
||||
>>> pay.form.journal = cash_journal
|
||||
>>> pay.execute('choice')
|
||||
|
||||
Check drop shipment::
|
||||
|
||||
>>> sale.reload()
|
||||
>>> sale_line, = sale.lines
|
||||
>>> bool(sale_line.purchase_request)
|
||||
True
|
||||
>>> len(sale.shipments)
|
||||
0
|
||||
>>> len(sale.drop_shipments)
|
||||
0
|
||||
@@ -27,4 +27,9 @@ def suite():
|
||||
tearDown=doctest_teardown, encoding='utf-8',
|
||||
checker=doctest_checker,
|
||||
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
|
||||
suite.addTests(doctest.DocFileSuite(
|
||||
'scenario_sale_supply_drop_shipment_on_invoice.rst',
|
||||
tearDown=doctest_teardown, encoding='utf-8',
|
||||
checker=doctest_checker,
|
||||
optionflags=doctest.REPORT_ONLY_FIRST_FAILURE))
|
||||
return suite
|
||||
Reference in new issue
Block a user